[PATCH 0/3] hw/display: add vhost-user-media device

Albert Esteve posted 3 patches 3 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260630112310.552606-1-aesteve@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Cornelia Huck <cohuck@redhat.com>
hw/display/Kconfig                          |   5 +
hw/display/meson.build                      |   3 +
hw/display/vhost-user-media-pci.c           | 105 ++++++
hw/display/vhost-user-media.c               | 397 ++++++++++++++++++++
hw/virtio/virtio.c                          |   3 +-
include/hw/virtio/vhost-user-media.h        |  47 +++
include/standard-headers/linux/virtio_ids.h |   1 +
7 files changed, 560 insertions(+), 1 deletion(-)
create mode 100644 hw/display/vhost-user-media-pci.c
create mode 100644 hw/display/vhost-user-media.c
create mode 100644 include/hw/virtio/vhost-user-media.h
[PATCH 0/3] hw/display: add vhost-user-media device
Posted by Albert Esteve 3 weeks, 4 days ago
This series introduces the QEMU frontend for the virtio-media device,
a VirtIO device that exposes V4L2 video device functionality to the guest
over the virtio-media protocol, as specified in the VirtIO specification
v1.4, section 5.22 [1].

Note on patch 1
---------------
Patch 1 adds a temporary virtio-media device ID to QEMU's copy of the
Linux standard headers. It is included to unblock testing but is marked
"DO NOT MERGE": it will be superseded once the corresponding kernel-side
patch [2] is merged upstream and QEMU's headers are updated to match.
Patches 2 and 3 depend on patch 1 for the VIRTIO_ID_MEDIA definition.

Overview
--------
Patch 2 introduces the vhost-user-media device frontend as defined by
the specification.

Patch 3 adds a 4 GiB shared memory PCI BAR (BAR 2) used by the guest
driver as a DMA cache for video buffer exchange with the host backend.
The region is exposed to the guest through a VirtIO shared memory
capability.

Testing
-------
The series was tested with:

  Guest driver: the virtio-media out-of-tree Linux kernel driver [3].
  An upstream series for this driver has also been posted [4].

  Host backend: the rust-vmm vhost-device-media backend [5]:
      cargo run -- -s /path/to/media.sock -d /dev/video0 --backend v4l2-proxy

  Full QEMU invocation:

      qemu-system-x86_64 \
          -chardev socket,path=/tmp/media.sock,id=media \
          -device vhost-user-media-pci,chardev=media,id=media \
          -object memory-backend-memfd,id=mem,size=4G,share=on \
          -numa node,memdev=mem

[1] https://docs.oasis-open.org/virtio/virtio/v1.4/cs01/virtio-v1.4-cs01.html
[2] https://lore.kernel.org/all/20260310-virtio-media-id-v1-1-be211bcf682b@redhat.com/
[3] https://github.com/chromeos/virtio-media/tree/main/driver
[4] https://lore.kernel.org/all/20260622204343.1994418-1-briandaniels@google.com/
[5] https://github.com/rust-vmm/vhost-device/pull/944

Albert Esteve (3):
  virtio_ids: Add ID for virtio media
  hw/display: add vhost-user-media device
  hw/display/vhost-user-media: add shared memory cache BAR

 hw/display/Kconfig                          |   5 +
 hw/display/meson.build                      |   3 +
 hw/display/vhost-user-media-pci.c           | 105 ++++++
 hw/display/vhost-user-media.c               | 397 ++++++++++++++++++++
 hw/virtio/virtio.c                          |   3 +-
 include/hw/virtio/vhost-user-media.h        |  47 +++
 include/standard-headers/linux/virtio_ids.h |   1 +
 7 files changed, 560 insertions(+), 1 deletion(-)
 create mode 100644 hw/display/vhost-user-media-pci.c
 create mode 100644 hw/display/vhost-user-media.c
 create mode 100644 include/hw/virtio/vhost-user-media.h

-- 
2.54.0
Re: [PATCH 0/3] hw/display: add vhost-user-media device
Posted by Dorinda Bassey 1 week, 3 days ago
Tested with vhost-device-media (v4l2-proxy backend) on Fedora 43 guest
(kernel 6.17.1), proxying a host integrated camera. Device detected and
frame capture works via v4l2-ctl --stream-mmap.

Tested-by: Dorinda Bassey <dbassey@redhat.com>