This patch covers the required steps to add support for virtio cross-device resource sharing[1], which support is already available in the kernel.
The main usecase will be sharing dma buffers from virtio-gpu devices (as the exporter -see VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID in [2]), to virtio-video (under discussion) devices (as the buffer-user or importer). Therefore, even though virtio specs talk about resources or objects[3], this patch adds the infrastructure with dma-bufs in mind. Note that virtio specs let the devices themselves define what a vitio object is. These are the main parts that are covered in the patch: Shared resources table, to hold all resources that can be shared in the host and their assigned UUID Internal shared table API for virtio devices to add, lookup and remove resources Unit test to verify the API. New message to the vhost-user protocol to allow backend to interact with the shared table API through the control socket Applies cleanly to 4ebc33f [1] - https://lwn.net/Articles/828988/ [2] - https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-3730006 [3] - https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-10500011 Albert Esteve (4): virtio-dmabuf: introduce virtio-dmabuf vhost-user: add shared_object msg vhost-user: refactor send_resp code libvhost-user: add write_msg cb to dev struct docs/interop/vhost-user.rst | 15 +++ hw/display/meson.build | 1 + hw/display/virtio-dmabuf.c | 88 +++++++++++++++++ hw/virtio/vhost-user.c | 90 ++++++++++++++--- include/hw/virtio/virtio-dmabuf.h | 58 +++++++++++ subprojects/libvhost-user/libvhost-user.c | 40 ++++++++ subprojects/libvhost-user/libvhost-user.h | 46 +++++++++ tests/unit/meson.build | 1 + tests/unit/test-virtio-dmabuf.c | 112 ++++++++++++++++++++++ 9 files changed, 438 insertions(+), 13 deletions(-) create mode 100644 hw/display/virtio-dmabuf.c create mode 100644 include/hw/virtio/virtio-dmabuf.h create mode 100644 tests/unit/test-virtio-dmabuf.c -- 2.40.0