Skip to content

libkrunfw: Add virtio-media driver support - #139

Open
dorindabassey wants to merge 1 commit into
libkrun:mainfrom
dorindabassey:vhost-media
Open

libkrunfw: Add virtio-media driver support#139
dorindabassey wants to merge 1 commit into
libkrun:mainfrom
dorindabassey:vhost-media

Conversation

@dorindabassey

Copy link
Copy Markdown

Add virtio-media driver patches v4 from upstream kernel mailing list to enable vhost-user media device support in libkrun. The driver proxies V4L2 operations between guest userspace and the virtio host backend, supporting MMAP buffer sharing through a shared memory region.

Changes:

  • Add patches 0031-0038 from [PATCH v4 0/8] media: Add virtio-media driver (lore.kernel.org/linux-media)
  • Enable media kernel configs (CONFIG_MEDIA_SUPPORT, CONFIG_MEDIA_CAMERA_SUPPORT, CONFIG_VIDEO_DEV, CONFIG_MEDIA_VIRTIO)

Fixes (kernel 6.12 backport):

  • v4l2_fh_add()/v4l2_fh_del() signature: drop second argument (mainline changed to 2-arg in 6.13+)
  • kzalloc_obj() does not exist in 6.12: replace with kzalloc(sizeof(*session), GFP_KERNEL)
  • file_to_v4l2_fh() does not exist in 6.12: add compat macro in virtio_media.h
  • VIRTIO_ID_MEDIA not in 6.12 virtio_ids.h: add definition (separate patch 0038)
  • Kconfig: add ARM64 to depends line (upstream only lists X86 and 32-bit ARM which is dead code with 64BIT)

The driver has been tested with rust-vmm vhost-device-media backend and a webcam, capturing video through the full SHMEM MMAP path.

Upstream patch authors:

Alexandre Courbot gnurou@gmail.com
Brian Daniels briandaniels@google.com

@aesteve-rh

Copy link
Copy Markdown

The VIRTIO_ID_MEDIA patch is available in https://lore.kernel.org/all/20260310-virtio-media-id-v1-1-be211bcf682b@redhat.com/

@dorindabassey

Copy link
Copy Markdown
Author

Thanks Albert! I could pick it up and drop the local patch.

Add virtio-media driver patches v4 from upstream kernel mailing
list to enable vhost-user media device support in libkrun.
Also add the VIRTIO_ID_MEDIA preperatory patch. The driver
proxies V4L2 operations between guest userspace and the
virtio host backend, supporting MMAP buffer sharing through
a shared memory region.

Changes:

- Add patches 0031-0038 from [PATCH v4 0/8] media: Add
  virtio-media driver (lore.kernel.org/linux-media)
- Enable media kernel configs (CONFIG_MEDIA_SUPPORT,
  CONFIG_MEDIA_CAMERA_SUPPORT, CONFIG_VIDEO_DEV,
  CONFIG_MEDIA_VIRTIO)

Fixes (kernel 6.12 backport):

- v4l2_fh_add()/v4l2_fh_del() signature: drop second
  argument (mainline changed to 2-arg in 6.13+)
- kzalloc_obj() does not exist in 6.12: replace with
  kzalloc(sizeof(*session), GFP_KERNEL)
- file_to_v4l2_fh() does not exist in 6.12: add compat
  macro in virtio_media.h
- Kconfig: add ARM64 to depends line (upstream only lists
  X86 and 32-bit ARM which is dead code with 64BIT)

The driver has been tested with rust-vmm vhost-device-media
backend and a webcam, capturing video through the full
SHMEM MMAP path.

Upstream patch authors:

Alexandre Courbot <gnurou@gmail.com>
Brian Daniels <briandaniels@google.com>
Albert Esteve <aesteve@redhat.com>

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants