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/[email protected]/
[3] https://github.com/chromeos/virtio-media/tree/main/driver
[4] 
https://lore.kernel.org/all/[email protected]/
[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


Reply via email to