vhost-vdmabuf: Add virtio based Dmabuf device
cover vhost-vdmabuf: Add virtio based Dmabuf device
The Virtio based Dmabuf (Vdmabuf) device provides a way to transfer a dmabuf created in the Guest to the Host. This patch is still a WIP but is still posted to the ML to provide additional details and context for the discussion associated with the vhost-vdmabuf and virtio-vdmabuf kernel drivers here:
https://lists.linuxfoundation.org/pipermail/virtualization/2021-February/052233.html
Vivek Kasireddy (1):
vhost-vdmabuf: Add virtio based Dmabuf device
configure | 8 + hw/virtio/meson.build | 1 + hw/virtio/vhost-backend.c | 10 + hw/virtio/vhost-vdmabuf.c | 526 ++++++++++++++++++++ include/hw/pci/pci.h | 1 + include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/vhost-vdmabuf.h | 76 +++ include/standard-headers/linux/virtio_ids.h | 1 + include/ui/console.h | 1 + linux-headers/linux/vhost.h | 3 + meson.build | 1 + ui/console.c | 7 + 12 files changed, 637 insertions(+) create mode 100644 hw/virtio/vhost-vdmabuf.c create mode 100644 include/hw/virtio/vhost-vdmabuf.h
Signature · 1 line
2.26.2
RFC 1/1 vhost-vdmabuf: Add virtio based Dmabuf device
This patch provides the implementation of the virtio dmabuf device that is used to share a dmabuf created in the Guest with the Host. Once the vhost vdmabuf kernel driver on the Host alerts Qemu about a new dmabuf from the Guest, it is first imported and then converted into a texture using EGL and eventually displayed on the screen.
--- configure | 8 + hw/virtio/meson.build | 1 + hw/virtio/vhost-backend.c | 10 + hw/virtio/vhost-vdmabuf.c | 526 ++++++++++++++++++++ include/hw/pci/pci.h | 1 + include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/vhost-vdmabuf.h | 76 +++ include/standard-headers/linux/virtio_ids.h | 1 + include/ui/console.h | 1 + linux-headers/linux/vhost.h | 3 + meson.build | 1 + ui/console.c | 7 + 12 files changed, 637 insertions(+) create mode 100644 hw/virtio/vhost-vdmabuf.c create mode 100644 include/hw/virtio/vhost-vdmabuf.h
configure +8 -0
@@ -345,6 +345,7 @@ vhost_net="$default_feature" vhost_crypto="$default_feature" vhost_scsi="$default_feature" vhost_vsock="$default_feature" +vhost_vdmabuf="$default_feature" vhost_user="no" vhost_user_blk_server="auto" vhost_user_fs="$default_feature"
@@ -1263,6 +1264,10 @@ for opt do ;; --enable-vhost-vsock) vhost_vsock="yes" ;; + --disable-vhost-vdmabuf) vhost_vdmabuf="no" + ;; + --enable-vhost-vdmabuf) vhost_vdmabuf="yes" + ;; --disable-vhost-user-blk-server) vhost_user_blk_server="disabled" ;; --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
@@ -5766,6 +5771,9 @@ if test "$vhost_vsock" = "yes" ; then echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak fi fi +if test "$vhost_vdmabuf" = "yes" ; then + echo "CONFIG_VHOST_VDMABUF=y" >> $config_host_mak +fi if test "$vhost_kernel" = "yes" ; then echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak fi
hw/virtio/meson.build +1 -0
@@ -21,6 +21,7 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs.c')) virtio_ss.add(when: ['CONFIG_VHOST_USER_FS', 'CONFIG_VIRTIO_PCI'], if_true: files('vhost-user-fs-pci.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true: files('virtio-pmem.c')) virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c', 'vhost-vsock-common.c')) +virtio_ss.add(when: 'CONFIG_VHOST_VDMABUF', if_true: files('vhost-vdmabuf.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c', 'vhost-vsock-common.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
hw/virtio/vhost-backend.c +10 -0
@@ -214,6 +214,13 @@ static int vhost_kernel_vsock_set_running(struct vhost_dev *dev, int start) }#endif /* CONFIG_VHOST_VSOCK */ +#ifdef CONFIG_VHOST_VDMABUF +static int vhost_kernel_vdmabuf_set_running (struct vhost_dev *dev,int start) +{ +return vhost_kernel_call (dev,VHOST_VDMABUF_SET_RUNNING , &start); +} +#endif /* CONFIG_VHOST_VDMABUF */ +static void vhost_kernel_iotlb_read (void *opaque) {struct vhost_dev *dev = opaque;
@@ -321,6 +328,9 @@ static const VhostOps kernel_ops = { .vhost_vsock_set_guest_cid = vhost_kernel_vsock_set_guest_cid, .vhost_vsock_set_running = vhost_kernel_vsock_set_running,#endif /* CONFIG_VHOST_VSOCK */ +#ifdef CONFIG_VHOST_VDMABUF + .vhost_vdmabuf_set_running = vhost_kernel_vdmabuf_set_running, +#endif /* CONFIG_VHOST_VDMABUF */ .vhost_set_iotlb_callback = vhost_kernel_set_iotlb_callback, .vhost_send_device_iotlb_msg = vhost_kernel_send_device_iotlb_msg, };
hw/virtio/vhost-vdmabuf.c new file +526 -0
526 lines not on this page · raw message
include/hw/pci/pci.h +1 -0
@@ -89,6 +89,7 @@ extern bool pci_available;#define PCI_DEVICE_ID_VIRTIO_PMEM 0x1013#define PCI_DEVICE_ID_VIRTIO_IOMMU 0x1014#define PCI_DEVICE_ID_VIRTIO_MEM 0x1015 +#define PCI_DEVICE_ID_VIRTIO_VDMABUF 0x1016#define PCI_VENDOR_ID_REDHAT 0x1b36#define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001
include/hw/virtio/vhost-backend.h +2 -0
@@ -89,6 +89,7 @@ typedef bool (*vhost_backend_can_merge_op)(struct vhost_dev *dev,typedef int (*vhost_vsock_set_guest_cid_op )(struct vhost_dev *dev,uint64_t guest_cid);typedef int (*vhost_vsock_set_running_op )(struct vhost_dev *dev,int start); +typedef int (*vhost_vdmabuf_set_running_op )(struct vhost_dev *dev,int start);typedef void (*vhost_set_iotlb_callback_op )(struct vhost_dev *dev,int enabled); typedef int (*vhost_send_device_iotlb_msg_op)(struct vhost_dev *dev,
@@ -157,6 +158,7 @@ typedef struct VhostOps {vhost_backend_can_merge_op vhost_backend_can_merge;vhost_vsock_set_guest_cid_op vhost_vsock_set_guest_cid;vhost_vsock_set_running_op vhost_vsock_set_running; +vhost_vdmabuf_set_running_op vhost_vdmabuf_set_running;vhost_set_iotlb_callback_op vhost_set_iotlb_callback;vhost_send_device_iotlb_msg_op vhost_send_device_iotlb_msg;vhost_get_config_op vhost_get_config;
include/hw/virtio/vhost-vdmabuf.h new file +76 -0
76 lines not on this page · raw message
include/standard-headers/linux/virtio_ids.h +1 -0
@@ -54,5 +54,6 @@#define VIRTIO_ID_FS 26/* virtio filesystem */ #define VIRTIO_ID_PMEM 27/* virtio pmem */ #define VIRTIO_ID_MAC80211_HWSIM 29/* virtio mac80211-hwsim */ +#define VIRTIO_ID_VDMABUF 37/* virtio vdmabuf */ #endif /* _LINUX_VIRTIO_IDS_H */
include/ui/console.h +1 -0
@@ -400,6 +400,7 @@ void graphic_console_close(QemuConsole *con);void graphic_hw_update (QemuConsole *con);void graphic_hw_update_done (QemuConsole *con); +void graphic_hw_dpy_refresh (QemuConsole *con);void graphic_hw_invalidate (QemuConsole *con);void graphic_hw_text_update (QemuConsole *con,console_ch_t *chardata);void graphic_hw_gl_block (QemuConsole *con,bool block);
linux-headers/linux/vhost.h +3 -0
@@ -150,4 +150,7 @@/* Get the valid iova range */ #define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ struct vhost_vdpa_iova_range) +/* VHOST_VDMABUF specific defines */ +#define VHOST_VDMABUF_SET_RUNNING _IOW(VHOST_VIRTIO, 0x79, int) +#endif
meson.build +1 -0
@@ -2417,6 +2417,7 @@ summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')} summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')} summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')} summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')} +summary_info += {'vhost-vdmabuf support': config_host.has_key('CONFIG_VHOST_VDMABUF')} summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')} summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server} summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
ui/console.c +7 -0
@@ -284,6 +284,13 @@ void graphic_hw_update(QemuConsole *con) } } +void graphic_hw_dpy_refresh (QemuConsole *con) +{ +DisplayState *ds = con ? con->ds : active_console->ds; + +dpy_refresh (ds); +} +void graphic_hw_gl_block (QemuConsole *con,bool block) {assert (con !=NULL );
Signature · 1 line
2.26.2
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [RFC 0/1] vhost-vdmabuf: Add virtio based Dmabuf device
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
1835e33 vhost-vdmabuf: Add virtio based Dmabuf device
=== OUTPUT BEGIN ===
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #106:
new file mode 100644
ERROR: do not initialise statics to 0 or NULL
#155: FILE: hw/virtio/vhost-vdmabuf.c:45:
+static bool have_event = false;
ERROR: code indent should never use tabs
#287: FILE: hw/virtio/vhost-vdmabuf.c:177:
+^I return;$
ERROR: code indent should never use tabs
#288: FILE: hw/virtio/vhost-vdmabuf.c:178:
+^I}$
ERROR: code indent should never use tabs
#397: FILE: hw/virtio/vhost-vdmabuf.c:287:
+^Ireturn NULL;$
ERROR: code indent should never use tabs
#415: FILE: hw/virtio/vhost-vdmabuf.c:305:
+^I^I^I^I^I VDMABUFDisplay *dpy,$
ERROR: braces {} are necessary for all arms of this statement #425: FILE: hw/virtio/vhost-vdmabuf.c:315:
+ if (ioctl(fd, VIRTIO_VDMABUF_IOCTL_RELEASE, &msg))
[...]
ERROR: braces {} are necessary for all arms of this statement #456: FILE: hw/virtio/vhost-vdmabuf.c:346:
+ if (!have_event)
[...]
ERROR: trailing whitespace
#531: FILE: hw/virtio/vhost-vdmabuf.c:421:
+ $
ERROR: code indent should never use tabs
#705: FILE: include/hw/virtio/vhost-vdmabuf.h:31:
+^I__u64 id;$
ERROR: code indent should never use tabs
#706: FILE: include/hw/virtio/vhost-vdmabuf.h:32:
+^I/* 8B long Random number */$
ERROR: code indent should never use tabs
#707: FILE: include/hw/virtio/vhost-vdmabuf.h:33:
+^Iint rng_key[2];$
ERROR: code indent should never use tabs
#711: FILE: include/hw/virtio/vhost-vdmabuf.h:37:
+^I/* buf_id of new buf */$
ERROR: code indent should never use tabs
#712: FILE: include/hw/virtio/vhost-vdmabuf.h:38:
+^Ivirtio_vdmabuf_buf_id_t buf_id;$
ERROR: code indent should never use tabs
#713: FILE: include/hw/virtio/vhost-vdmabuf.h:39:
+^I/* size of private data */$
ERROR: code indent should never use tabs
#714: FILE: include/hw/virtio/vhost-vdmabuf.h:40:
+^Iint size;$
ERROR: code indent should never use tabs
#718: FILE: include/hw/virtio/vhost-vdmabuf.h:44:
+^Istruct virtio_vdmabuf_e_hdr hdr;$
ERROR: code indent should never use tabs
#719: FILE: include/hw/virtio/vhost-vdmabuf.h:45:
+^I/* ptr to private data */$
ERROR: code indent should never use tabs
#720: FILE: include/hw/virtio/vhost-vdmabuf.h:46:
+^Ivoid *data;$
ERROR: code indent should never use tabs
#728: FILE: include/hw/virtio/vhost-vdmabuf.h:54:
+^I/* IN parameters */$
ERROR: code indent should never use tabs
#729: FILE: include/hw/virtio/vhost-vdmabuf.h:55:
+^I/* vdmabuf id to be imported */$
ERROR: code indent should never use tabs
#730: FILE: include/hw/virtio/vhost-vdmabuf.h:56:
+^Ivirtio_vdmabuf_buf_id_t buf_id;$
ERROR: code indent should never use tabs
#731: FILE: include/hw/virtio/vhost-vdmabuf.h:57:
+^I/* flags */$
ERROR: code indent should never use tabs
#732: FILE: include/hw/virtio/vhost-vdmabuf.h:58:
+^Iint flags;$
ERROR: code indent should never use tabs
#733: FILE: include/hw/virtio/vhost-vdmabuf.h:59:
+^I/* OUT parameters */$
ERROR: code indent should never use tabs
#734: FILE: include/hw/virtio/vhost-vdmabuf.h:60:
+^I/* exported dma buf fd */$
ERROR: code indent should never use tabs
#735: FILE: include/hw/virtio/vhost-vdmabuf.h:61:
+^Iint fd;$
ERROR: code indent should never use tabs
#741: FILE: include/hw/virtio/vhost-vdmabuf.h:67:
+^I/* IN parameters */$
ERROR: code indent should never use tabs
#742: FILE: include/hw/virtio/vhost-vdmabuf.h:68:
+^I/* DMA buf fd to be exported */$
ERROR: code indent should never use tabs
#743: FILE: include/hw/virtio/vhost-vdmabuf.h:69:
+^Iint fd;$
ERROR: code indent should never use tabs
#744: FILE: include/hw/virtio/vhost-vdmabuf.h:70:
+^I/* exported dma buf id */$
ERROR: code indent should never use tabs
#745: FILE: include/hw/virtio/vhost-vdmabuf.h:71:
+^Ivirtio_vdmabuf_buf_id_t buf_id;$
ERROR: code indent should never use tabs
#746: FILE: include/hw/virtio/vhost-vdmabuf.h:72:
+^Iint sz_priv;$
ERROR: code indent should never use tabs
#747: FILE: include/hw/virtio/vhost-vdmabuf.h:73:
+^Ichar *priv;$
total: 33 errors, 1 warnings, 718 lines checked
Commit 1835e330d677 (vhost-vdmabuf: Add virtio based Dmabuf device) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]