vhost-user for input & GPU
v6 cover vhost-user for input & GPU
Hi,
vhost-user allows to drive a virtio device in a seperate process. After vhost-user-net, we have seen vhost-user-{scsi,blk,crypto} added more recently.
This series, initially proposed ~3 years ago, time flies
(https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg01905.html)
contributes with vhost-user-input and vhost-user-gpu.
You may start a vhost-user-gpu with virgl rendering in a separate process like this:
$ ./vhost-user-gpu --virgl -s vgpu.sock & $ qemu... -chardev socket,id=chr,path=vgpu.sock -device vhost-user-vga,chardev=chr
v6:
- do not install vhost-user-input
- install vhost-user-gpu and json file following the spec
- fix the build when drm-intel-devel missing
- rebase (& resend without already applied patches)
v5:
- remove user-creatable version of vhost-user-backend
- remove optinal management of sub-process in vhost-user-backend
- removed daemonize/pid code
- drop introduction of new input & gpu messages for PCI config space handling, instead use VHOST_USER_PROTOCOL_F_CONFIG
- plain mem & udmabuf fallback for 2d rendering
- rebased, kconfig-ify, rst-ify
Marc-André Lureau (11):
Add vhost-user-backend
Add vhost-user-input-pci
libvhost-user: add PROTOCOL_F_CONFIG if {set,get}_config
contrib: add vhost-user-input
vhost-user: add vhost_user_gpu_set_socket()
virtio: add virtio-gpu bswap helpers header
util: compile drm.o on Linux
contrib: add vhost-user-gpu
virtio-gpu: split virtio-gpu, introduce virtio-gpu-base
virtio-gpu: split virtio-gpu-pci & virtio-vga hw/display: add vhost-user-vga & gpu-pci
contrib/libvhost-user/libvhost-user.h | 1 + contrib/vhost-user-gpu/drm.h | 72 ++ contrib/vhost-user-gpu/virgl.h | 25 + contrib/vhost-user-gpu/vugpu.h | 170 +++ hw/display/virtio-vga.h | 32 + include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/virtio-gpu-bswap.h | 61 + include/hw/virtio/virtio-gpu-pci.h | 40 + include/hw/virtio/virtio-gpu.h | 92 +- include/hw/virtio/virtio-input.h | 14 + include/sysemu/vhost-user-backend.h | 57 + backends/vhost-user.c | 209 ++++ contrib/libvhost-user/libvhost-user.c | 5 + contrib/vhost-user-gpu/drm.c | 341 ++++++ contrib/vhost-user-gpu/main.c | 1236 ++++++++++++++++++++ contrib/vhost-user-gpu/virgl.c | 579 +++++++++ contrib/vhost-user-input/main.c | 427 +++++++ hw/display/vhost-user-gpu-pci.c | 51 + hw/display/vhost-user-gpu.c | 572 +++++++++ hw/display/vhost-user-vga.c | 52 + hw/display/virtio-gpu-3d.c | 49 +- hw/display/virtio-gpu-base.c | 268 +++++ hw/display/virtio-gpu-pci.c | 55 +- hw/display/virtio-gpu.c | 415 ++----- hw/display/virtio-vga.c | 138 +-- hw/input/vhost-user-input.c | 129 ++ hw/virtio/vhost-user-input-pci.c | 53 + hw/virtio/vhost-user.c | 11 + vl.c | 1 + MAINTAINERS | 14 +- Makefile | 27 +- Makefile.objs | 2 + backends/Makefile.objs | 2 + configure | 29 + contrib/vhost-user-gpu/50-qemu-gpu.json.in | 5 + contrib/vhost-user-gpu/Makefile.objs | 10 + contrib/vhost-user-input/Makefile.objs | 1 + docs/interop/index.rst | 2 +- docs/interop/vhost-user-gpu.rst | 238 ++++ docs/interop/vhost-user.txt | 9 + hw/display/Kconfig | 10 + hw/display/Makefile.objs | 5 +- hw/input/Kconfig | 5 + hw/input/Makefile.objs | 1 + hw/virtio/Makefile.objs | 1 + rules.mak | 9 +- util/Makefile.objs | 2 +- 47 files changed, 5070 insertions(+), 459 deletions(-) create mode 100644 contrib/vhost-user-gpu/drm.h create mode 100644 contrib/vhost-user-gpu/virgl.h create mode 100644 contrib/vhost-user-gpu/vugpu.h create mode 100644 hw/display/virtio-vga.h create mode 100644 include/hw/virtio/virtio-gpu-bswap.h create mode 100644 include/hw/virtio/virtio-gpu-pci.h create mode 100644 include/sysemu/vhost-user-backend.h create mode 100644 backends/vhost-user.c create mode 100644 contrib/vhost-user-gpu/drm.c create mode 100644 contrib/vhost-user-gpu/main.c create mode 100644 contrib/vhost-user-gpu/virgl.c create mode 100644 contrib/vhost-user-input/main.c create mode 100644 hw/display/vhost-user-gpu-pci.c create mode 100644 hw/display/vhost-user-gpu.c create mode 100644 hw/display/vhost-user-vga.c create mode 100644 hw/display/virtio-gpu-base.c create mode 100644 hw/input/vhost-user-input.c create mode 100644 hw/virtio/vhost-user-input-pci.c create mode 100644 contrib/vhost-user-gpu/50-qemu-gpu.json.in create mode 100644 contrib/vhost-user-gpu/Makefile.objs create mode 100644 contrib/vhost-user-input/Makefile.objs create mode 100644 docs/interop/vhost-user-gpu.rst
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v6 1/11 Add vhost-user-backend
Create a vhost-user-backend object that holds a connection to a vhost-user backend (or "slave" process) and can be referenced from virtio devices that support it. See later patches for input & gpu usage.
Note: a previous iteration of this object made it user-creatable, and allowed managed sub-process spawning, but that has been dropped for now.
--- include/sysemu/vhost-user-backend.h | 57 ++++++++ backends/vhost-user.c | 209 ++++++++++++++++++++++++++++ MAINTAINERS | 2 + backends/Makefile.objs | 2 + 4 files changed, 270 insertions(+) create mode 100644 include/sysemu/vhost-user-backend.h create mode 100644 backends/vhost-user.c
include/sysemu/vhost-user-backend.h new file +57 -0
@@ -0,0 +1,57 @@ +/* +* QEMU vhost-user backend +* +* Copyright (C) 2018 Red Hat Inc +* +* Authors: +* Marc-André Lureau <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#ifndef QEMU_VHOST_USER_BACKEND_H +#define QEMU_VHOST_USER_BACKEND_H + +#include "qom/object.h" +#include "exec/memory.h" +#include "qemu/option.h" +#include "qemu/bitmap.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "chardev/char-fe.h" +#include "io/channel.h" + +#define TYPE_VHOST_USER_BACKEND "vhost-user-backend" +#define VHOST_USER_BACKEND (obj) \ + OBJECT_CHECK(VhostUserBackend, (obj), TYPE_VHOST_USER_BACKEND) +#define VHOST_USER_BACKEND_GET_CLASS (obj) \ + OBJECT_GET_CLASS(VhostUserBackendClass, (obj), TYPE_VHOST_USER_BACKEND) +#define VHOST_USER_BACKEND_CLASS (klass) \ + OBJECT_CLASS_CHECK(VhostUserBackendClass, (klass), TYPE_VHOST_USER_BACKEND) + +typedef struct VhostUserBackend VhostUserBackend ; +typedef struct VhostUserBackendClass VhostUserBackendClass ; + +struct VhostUserBackendClass { +ObjectClass parent_class; +}; + +struct VhostUserBackend { +/* private */ +Object parent; + +char *chr_name; +CharBackend chr; +VhostUserState vhost_user; +struct vhost_dev dev; +VirtIODevice *vdev; +bool started; +bool completed; +}; + +int vhost_user_backend_dev_init (VhostUserBackend *b,VirtIODevice *vdev, +unsigned nvqs,Error **errp); +void vhost_user_backend_start (VhostUserBackend *b); +void vhost_user_backend_stop (VhostUserBackend *b); + +#endif
backends/vhost-user.c new file +209 -0
209 lines not on this page · raw message
MAINTAINERS +2 -0
@@ -1469,6 +1469,8 @@ F: hw/*/*vhost* F: docs/interop/vhost-user.json F: docs/interop/vhost-user.txt F: contrib/vhost-user-*/ +F: backends/vhost-user.c +F: include/sysemu/vhost-user-backend.h virtio M: Michael S. Tsirkin <[email protected]>
backends/Makefile.objs +2 -0
@@ -14,4 +14,6 @@ common-obj-y += cryptodev-vhost.o common-obj-$(CONFIG_VHOST_CRYPTO) += cryptodev-vhost-user.o endif +common-obj-$(call land,$(CONFIG_VHOST_USER),$(CONFIG_VIRTIO)) += vhost-user.o + common-obj-$(CONFIG_LINUX) += hostmem-memfd.o
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v6 2/11 Add vhost-user-input-pci
In reply to Marc-André LureauAdd a new virtio-input device, which connects to a vhost-user backend.
Instead of reading configuration directly from an input device / evdev (like virtio-input-host), it reads it over vhost-user protocol with {SET,GET}_CONFIG messages. The vhost-user-backend handles the queues & events setup.
--- include/hw/virtio/virtio-input.h | 14 ++++ hw/input/vhost-user-input.c | 129 +++++++++++++++++++++++++++++++ hw/virtio/vhost-user-input-pci.c | 53 +++++++++++++ MAINTAINERS | 1 + hw/input/Kconfig | 5 ++ hw/input/Makefile.objs | 1 + hw/virtio/Makefile.objs | 1 + 7 files changed, 204 insertions(+) create mode 100644 hw/input/vhost-user-input.c create mode 100644 hw/virtio/vhost-user-input-pci.c
include/hw/virtio/virtio-input.h +14 -0
@@ -2,6 +2,7 @@#define QEMU_VIRTIO_INPUT_H #include "ui/input.h" +#include "sysemu/vhost-user-backend.h" /* ----------------------------------------------------------------- */ /* virtio input protocol */
@@ -42,11 +43,18 @@ typedef struct virtio_input_event virtio_input_event;#define VIRTIO_INPUT_HOST_GET_PARENT_CLASS (obj) \ OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST) +#define TYPE_VHOST_USER_INPUT "vhost-user-input" +#define VHOST_USER_INPUT (obj) \ + OBJECT_CHECK(VHostUserInput, (obj), TYPE_VHOST_USER_INPUT) +#define VHOST_USER_INPUT_GET_PARENT_CLASS (obj) \ + OBJECT_GET_PARENT_CLASS(obj, TYPE_VHOST_USER_INPUT) +typedef struct VirtIOInput VirtIOInput ;typedef struct VirtIOInputClass VirtIOInputClass ;typedef struct VirtIOInputConfig VirtIOInputConfig ;typedef struct VirtIOInputHID VirtIOInputHID ;typedef struct VirtIOInputHost VirtIOInputHost ; +typedef struct VHostUserInput VHostUserInput ;struct VirtIOInputConfig {virtio_input_config config;
@@ -98,6 +106,12 @@ struct VirtIOInputHost {int fd; }; +struct VHostUserInput { +VirtIOInput parent_obj; + +VhostUserBackend *vhost; +}; +void virtio_input_send (VirtIOInput *vinput,virtio_input_event *event);void virtio_input_init_config (VirtIOInput *vinput,virtio_input_config *config);
hw/input/vhost-user-input.c new file +129 -0
129 lines not on this page · raw message
hw/virtio/vhost-user-input-pci.c new file +53 -0
53 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -1512,6 +1512,7 @@ L: [email protected] virtio-input M: Gerd Hoffmann <[email protected]> S: Maintained +F: hw/input/vhost-user-input.c F: hw/input/virtio-input*.c F: include/hw/virtio/virtio-input.h
hw/input/Kconfig +5 -0
@@ -29,5 +29,10 @@ config VIRTIO_INPUT_HOST default y depends on VIRTIO && LINUX +config VHOST_USER_INPUT + bool + default y + depends on VIRTIO_INPUT && VHOST_USER + config TSC210X bool
hw/input/Makefile.objs +1 -0
@@ -11,6 +11,7 @@ common-obj-$(CONFIG_VIRTIO_INPUT) += virtio-input.o common-obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-hid.o ifeq ($(CONFIG_LINUX),y) common-obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-host.o +common-obj-$(CONFIG_VHOST_USER_INPUT) += vhost-user-input.o endif obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
hw/virtio/Makefile.objs +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o ifeq ($(CONFIG_VIRTIO_PCI),y) obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-pci.o obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk-pci.o +obj-$(CONFIG_VHOST_USER_INPUT) += vhost-user-input-pci.o obj-$(CONFIG_VHOST_USER_SCSI) += vhost-user-scsi-pci.o obj-$(CONFIG_VHOST_SCSI) += vhost-scsi-pci.o obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host-pci.o
Signature · 1 line
2.21.0.313.ge35b8cb8e2
Re: [Qemu-devel] [PATCH v6 02/11] Add vhost-user-input-pci
Quoted 21 lines
hw/input/vhost-user-input.c new file +21
-0+static void vhost_input_get_config (VirtIODevice *vdev,uint8_t *config_data) +{ +VirtIOInput *vinput =VIRTIO_INPUT (vdev); +VHostUserInput *vhi =VHOST_USER_INPUT (vdev); +int ret; + +memset (config_data,0 , vinput->cfg_size); + + ret =vhost_dev_get_config (&vhi->vhost->dev, config_data, vinput->cfg_size); +if (ret) { +error_report ("vhost-user-input: get device config space failed" ); +return ; + } +} + +static void vhost_input_set_config (VirtIODevice *vdev, +const uint8_t *config_data) +{ +VHostUserInput *vhi =VHOST_USER_INPUT (vdev); +int ret; +
hw/input/vhost-user-input.c line 79
Quoted 10 lines
hw/input/vhost-user-input.c new file +10
-0+ ret =vhost_dev_set_config (&vhi->vhost->dev, config_data, +0 ,sizeof (virtio_input_config), +VHOST_SET_CONFIG_TYPE_MASTER ); +if (ret) { +error_report ("vhost-user-input: set device config space failed" ); +return ; + } + +virtio_notify_config (vdev); +}
These two look rather generic, the only virtio-input specific thing is the config space size. Can we store the size somewhere, then move the functions to common vhost-user code?
cheers,
Gerd
Re: [Qemu-devel] [PATCH v6 02/11] Add vhost-user-input-pci
Hi
Quoted 28 lines · Gerd Hoffmann
Quoted 28 lines
hw/input/vhost-user-input.c new file +27
-0+static void vhost_input_get_config (VirtIODevice *vdev,uint8_t *config_data) +{ +VirtIOInput *vinput =VIRTIO_INPUT (vdev); +VHostUserInput *vhi =VHOST_USER_INPUT (vdev); +int ret; + +memset (config_data,0 , vinput->cfg_size); + + ret =vhost_dev_get_config (&vhi->vhost->dev, config_data, vinput->cfg_size); +if (ret) { +error_report ("vhost-user-input: get device config space failed" ); +return ; + } +} + +static void vhost_input_set_config (VirtIODevice *vdev, +const uint8_t *config_data) +{ +VHostUserInput *vhi =VHOST_USER_INPUT (vdev); +int ret; + + ret =vhost_dev_set_config (&vhi->vhost->dev, config_data, +0 ,sizeof (virtio_input_config), +VHOST_SET_CONFIG_TYPE_MASTER ); +if (ret) { +error_report ("vhost-user-input: set device config space failed" ); +return ;
Quoted 8 lines
hw/input/vhost-user-input.c line 79
Quoted 4 lines
hw/input/vhost-user-input.c new file +4
-0+ } + +virtio_notify_config (vdev); +}These two look rather generic, the only virtio-input specific thing is the config space size. Can we store the size somewhere, then move the functions to common vhost-user code?
vhost-user-input is simple, vhost-user-gpu is fiddling with the config on qemu side.
virtio-input set_config() calls virtio_notify_config(), while virtio-gpu does not (vhost-user versions copy that).
There isn't much code to share at this point.
Signature · 1 line
Marc-André Lureau
PATCH v6 3/11 libvhost-user: add PROTOCOL_F_CONFIG if {set, get}_config
In reply to Marc-André LureauAdd the config protocol feature bit if the set_config & get_config callbacks are implemented.
--- contrib/libvhost-user/libvhost-user.c | 4 ++++ 1 file changed, 4 insertions(+)
contrib/libvhost-user/libvhost-user.c +4 -0
@@ -1157,6 +1157,10 @@ vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg *vmsg) features |=1ULL <<VHOST_USER_PROTOCOL_F_PAGEFAULT ; } +if (dev->iface->get_config && dev->iface->set_config) { + features |=1ULL <<VHOST_USER_PROTOCOL_F_CONFIG ; + } +if (dev->iface->get_protocol_features) { features |= dev->iface->get_protocol_features (dev); }
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v6 4/11 contrib: add vhost-user-input
In reply to Marc-André LureauAdd a vhost-user input backend example, based on virtio-input-host device. It takes an evdev path as argument, and can be associated with a vhost-user-input device via a UNIX socket:
$ vhost-user-input -p /dev/input/eventX -s /tmp/vui.sock
$ qemu ... -chardev socket,id=vuic,path=/tmp/vui.sock -device vhost-user-input-pci,chardev=vuic
This example is intentionally not included in $TOOLS, to not be built and installed by default.
--- contrib/vhost-user-input/main.c | 427 +++++++++++++++++++++++++ MAINTAINERS | 1 + Makefile | 4 + Makefile.objs | 1 + contrib/vhost-user-input/Makefile.objs | 1 + 5 files changed, 434 insertions(+) create mode 100644 contrib/vhost-user-input/main.c create mode 100644 contrib/vhost-user-input/Makefile.objs
contrib/vhost-user-input/main.c new file +427 -0
@@ -0,0 +1,427 @@ +/* +* This work is licensed under the terms of the GNU GPL, version 2 or +* (at your option) any later version. See the COPYING file in the +* top-level directory. +*/ + +#include "qemu/osdep.h" + +#include <glib.h> +#include <linux/input.h> + +#include "qemu/iov.h" +#include "qemu/bswap.h" +#include "contrib/libvhost-user/libvhost-user.h" +#include "contrib/libvhost-user/libvhost-user-glib.h" +#include "standard-headers/linux/virtio_input.h" +#include "qapi/error.h" + +typedef struct virtio_input_event virtio_input_event ; +typedef struct virtio_input_config virtio_input_config ; + +typedef struct VuInput { +VugDev dev; +GSource *evsrc; +int evdevfd; +GArray *config; +virtio_input_config *sel_config; +struct { +virtio_input_event event; +VuVirtqElement *elem; + } *queue; +uint32_t qindex, qsize; +}VuInput ; + +static void vi_input_send (VuInput *vi,struct virtio_input_event *event) +{ +VuDev *dev = &vi->dev.parent; +VuVirtq *vq =vu_get_queue (dev,0 ); +VuVirtqElement *elem; +int i, len; + +/* queue up events ... */ +if (vi->qindex == vi->qsize) { + vi->qsize++; + vi->queue =g_realloc_n (vi->queue, vi->qsize,sizeof (vi->queue[0 ])); + } + vi->queue[vi->qindex++].event = *event; + +/* ... until we see a report sync ... */ +if (event->type !=htole16 (EV_SYN ) || + event->code !=htole16 (SYN_REPORT )) { +return ; + } + +/* ... then check available space ... */ +for (i =0 ; i < vi->qindex; i++) { + elem =vu_queue_pop (dev, vq,sizeof (VuVirtqElement)); +if (!elem) { +while (--i >=0 ) { +vu_queue_unpop (dev, vq, vi->queue[i].elem,0 ); + } + vi->qindex =0 ; +g_warning ("virtio-input queue full" ); +return ; + } + vi->queue[i].elem = elem; + } + +/* ... and finally pass them to the guest */ +for (i =0 ; i < vi->qindex; i++) { + elem = vi->queue[i].elem; + len =iov_from_buf (elem->in_sg, elem->in_num, +0 , &vi->queue[i].event,sizeof (virtio_input_event)); +vu_queue_push (dev, vq, elem, len); +g_free (elem); + } + +vu_queue_notify (&vi->dev.parent, vq); + vi->qindex =0 ; +} + +static void +vi_evdev_watch (VuDev *dev,int condition,void *data) +{ +VuInput *vi = data; +int fd = vi->evdevfd; + +g_debug ("Got evdev condition %x" , condition); + +struct virtio_input_event virtio; +struct input_event evdev; +int rc; + +for (;;) { + rc =read (fd, &evdev,sizeof (evdev)); +if (rc !=sizeof (evdev)) { +break ; + } + +g_debug ("input %d %d %d" , evdev.type, evdev.code, evdev.value); + + virtio.type =htole16 (evdev.type); + virtio.code =htole16 (evdev.code); + virtio.value =htole32 (evdev.value); +vi_input_send (vi, &virtio); + } +} + + +static void vi_handle_status (VuInput *vi,virtio_input_event *event) +{ +struct input_event evdev; +int rc; + +if (gettimeofday (&evdev.time,NULL )) { +perror ("vi_handle_status: gettimeofday" ); +return ; + } + + evdev.type =le16toh (event->type); + evdev.code =le16toh (event->code); + evdev.value =le32toh (event->value); + + rc =write (vi->evdevfd, &evdev,sizeof (evdev)); +if (rc ==-1 ) { +perror ("vi_host_handle_status: write" ); + } +} + +static void vi_handle_sts (VuDev *dev,int qidx) +{ +VuInput *vi =container_of (dev, VuInput, dev.parent); +VuVirtq *vq =vu_get_queue (dev, qidx); +virtio_input_event event; +VuVirtqElement *elem; +int len; + +g_debug ("%s" ,G_STRFUNC ); + +for (;;) { + elem =vu_queue_pop (dev, vq,sizeof (VuVirtqElement)); +if (!elem) { +break ; + } + +memset (&event,0 ,sizeof (event)); + len =iov_to_buf (elem->out_sg, elem->out_num, +0 , &event,sizeof (event)); +vi_handle_status (vi, &event); +vu_queue_push (dev, vq, elem, len); +g_free (elem); + } + +vu_queue_notify (&vi->dev.parent, vq); +} + +static void +vi_panic (VuDev *dev,const char *msg) +{ +g_critical ("%s\n" , msg); +exit (EXIT_FAILURE ); +} + +static void +vi_queue_set_started (VuDev *dev,int qidx,bool started) +{ +VuInput *vi =container_of (dev, VuInput, dev.parent); +VuVirtq *vq =vu_get_queue (dev, qidx); + +g_debug ("queue started %d:%d" , qidx, started); + +if (qidx ==1 ) { +vu_set_queue_handler (dev, vq, started ? vi_handle_sts :NULL ); + } + + started =vu_queue_started (dev,vu_get_queue (dev,0 )) && +vu_queue_started (dev,vu_get_queue (dev,1 )); + +if (started && !vi->evsrc) { + vi->evsrc =vug_source_new (&vi->dev, vi->evdevfd, +G_IO_IN , vi_evdev_watch, vi); + } + +if (!started && vi->evsrc) { +g_source_destroy (vi->evsrc); + vi->evsrc =NULL ; + } +} + +static virtio_input_config * +vi_find_config (VuInput *vi,uint8_t select,uint8_t subsel) +{ +virtio_input_config *cfg; +int i; + +for (i =0 ; i < vi->config->len; i++) { + cfg = &g_array_index (vi->config, virtio_input_config, i); +if (select == cfg->select && subsel == cfg->subsel) { +return cfg; + } + } + +return NULL ; +} + +static int vi_get_config (VuDev *dev,uint8_t *config,uint32_t len) +{ +VuInput *vi =container_of (dev, VuInput, dev.parent); + +g_return_val_if_fail (len <=sizeof (*vi->sel_config),-1 ); + +if (vi->sel_config) { +memcpy (config, vi->sel_config, len); + }else { +memset (config,0 , len); + } + +return 0 ; +} + +static int vi_set_config (VuDev *dev,const uint8_t *data, +uint32_t offset,uint32_t size, +uint32_t flags) +{ +VuInput *vi =container_of (dev, VuInput, dev.parent); +virtio_input_config *config = (virtio_input_config *)data; + + vi->sel_config =vi_find_config (vi, config->select, config->subsel); + +return 0 ; +} + +static const VuDevIface vuiface = { + .queue_set_started = vi_queue_set_started, + .get_config = vi_get_config, + .set_config = vi_set_config, +}; + +static void +vi_bits_config (VuInput *vi,int type,int count) +{ +virtio_input_config bits; +int rc, i, size =0 ; + +memset (&bits,0 ,sizeof (bits)); + rc =ioctl (vi->evdevfd,EVIOCGBIT (type, count /8 ), bits.u.bitmap); +if (rc <0 ) { +return ; + } + +for (i =0 ; i < count /8 ; i++) { +if (bits.u.bitmap[i]) { + size = i +1 ; + } + } +if (size ==0 ) { +return ; + } + + bits.select =VIRTIO_INPUT_CFG_EV_BITS ; + bits.subsel = type; + bits.size = size; +g_array_append_val (vi->config, bits); +} + +static int unix_sock_new (char *path) +{ +int sock; +struct sockaddr_un un; +size_t len; + + sock =socket (AF_UNIX ,SOCK_STREAM ,0 ); +if (sock <=0 ) { +perror ("socket" ); +return -1 ; + } + + un.sun_family =AF_UNIX ; +snprintf (un.sun_path,sizeof (un.sun_path),"%s" , path); + len =sizeof (un.sun_family) +strlen (un.sun_path); + +unlink (path); +if (bind (sock, (struct sockaddr *)&un, len) <0 ) { +perror ("bind" ); + goto fail; + } + +if (listen (sock,1 ) <0 ) { +perror ("listen" ); + goto fail; + } + +return sock; + +fail: +close (sock); + +return -1 ; +} + +static char *opt_evdev; +static int opt_fdnum =-1 ; +static char *opt_socket_path; +static gboolean opt_nograb; +static gboolean opt_print_caps; + +static GOptionEntry entries[] = { + {"print-capabilities" ,'c' ,0 ,G_OPTION_ARG_NONE , &opt_print_caps, +"Print capabilities" ,NULL }, + {"no-grab" ,'n' ,0 ,G_OPTION_ARG_NONE , &opt_nograb, +"Don't grab device" ,NULL }, + {"fd" ,'f' ,0 ,G_OPTION_ARG_INT , &opt_fdnum, +"Use inherited fd socket" ,"FDNUM" }, + {"socket-path" ,'s' ,0 ,G_OPTION_ARG_FILENAME , &opt_socket_path, +"Use UNIX socket path" ,"PATH" }, + {"evdev-path" ,'p' ,0 ,G_OPTION_ARG_FILENAME , &opt_evdev, +"evdev input device path" ,"PATH" }, + {NULL , } +}; + +int +main (int argc,char *argv[]) +{ +GMainLoop *loop =NULL ; +VuInput vi = {0 , }; +int rc, ver, fd; +virtio_input_config id; +struct input_id ids; +GError *error =NULL ; +GOptionContext *context; + + context =g_option_context_new (NULL ); +g_option_context_add_main_entries (context, entries,NULL ); +if (!g_option_context_parse (context, &argc, &argv, &error)) { +g_printerr ("Option parsing failed: %s\n" , error->message); +exit (EXIT_FAILURE ); + } +if (opt_print_caps) { +g_print ("{\n" ); +g_print (" \"type\": \"input\",\n" ); +g_print (" \"features\": [\n" ); +g_print (" \"evdev-path\",\n" ); +g_print (" \"no-grab\"\n" ); +g_print (" ]\n" ); +g_print ("}\n" ); +exit (EXIT_SUCCESS ); + } +if (!opt_evdev) { +g_printerr ("Please specify an evdev path\n" ); +exit (EXIT_FAILURE ); + } +if ((!!opt_socket_path + (opt_fdnum !=-1 )) !=1 ) { +g_printerr ("Please specify either --fd or --socket-path\n" ); +exit (EXIT_FAILURE ); + } + + vi.evdevfd =open (opt_evdev,O_RDWR ); +if (vi.evdevfd <0 ) { +g_printerr ("Failed to open evdev: %s\n" ,g_strerror (errno)); +exit (EXIT_FAILURE ); + } + + rc =ioctl (vi.evdevfd,EVIOCGVERSION , &ver); +if (rc <0 ) { +g_printerr ("%s: is not an evdev device\n" , argv[1 ]); +exit (EXIT_FAILURE ); + } + +if (!opt_nograb) { + rc =ioctl (vi.evdevfd,EVIOCGRAB ,1 ); +if (rc <0 ) { +g_printerr ("Failed to grab device\n" ); +exit (EXIT_FAILURE ); + } + } + + vi.config =g_array_new (false, false,sizeof (virtio_input_config)); +memset (&id,0 ,sizeof (id)); +ioctl (vi.evdevfd,EVIOCGNAME (sizeof (id.u.string) -1 ), id.u.string); + id.select =VIRTIO_INPUT_CFG_ID_NAME ; + id.size =strlen (id.u.string); +g_array_append_val (vi.config, id); + +if (ioctl (vi.evdevfd,EVIOCGID , &ids) ==0 ) { +memset (&id,0 ,sizeof (id)); + id.select =VIRTIO_INPUT_CFG_ID_DEVIDS ; + id.size =sizeof (struct virtio_input_devids ); + id.u.ids.bustype =cpu_to_le16 (ids.bustype); + id.u.ids.vendor =cpu_to_le16 (ids.vendor); + id.u.ids.product =cpu_to_le16 (ids.product); + id.u.ids.version =cpu_to_le16 (ids.version); +g_array_append_val (vi.config, id); + } + +vi_bits_config (&vi,EV_KEY ,KEY_CNT ); +vi_bits_config (&vi,EV_REL ,REL_CNT ); +vi_bits_config (&vi,EV_ABS ,ABS_CNT ); +vi_bits_config (&vi,EV_MSC ,MSC_CNT ); +vi_bits_config (&vi,EV_SW ,SW_CNT ); +g_debug ("config length: %u" , vi.config->len); + +if (opt_socket_path) { +int lsock =unix_sock_new (opt_socket_path); + fd =accept (lsock,NULL ,NULL ); +close (lsock); + }else { + fd = opt_fdnum; + } +if (fd ==-1 ) { +g_printerr ("Invalid socket" ); +exit (EXIT_FAILURE ); + } +vug_init (&vi.dev, fd, vi_panic, &vuiface); + + loop =g_main_loop_new (NULL , FALSE); +g_main_loop_run (loop); +g_main_loop_unref (loop); + +vug_deinit (&vi.dev); + +if (vi.evsrc) { +g_source_unref (vi.evsrc); + } +g_array_free (vi.config, TRUE); +g_free (vi.queue); +return 0 ; +}
MAINTAINERS +1 -0
@@ -1515,6 +1515,7 @@ S: Maintained F: hw/input/vhost-user-input.c F: hw/input/virtio-input*.c F: include/hw/virtio/virtio-input.h +F: contrib/vhost-user-input/* virtio-serial M: Amit Shah <[email protected]>
Makefile +4 -0
@@ -402,6 +402,7 @@ dummy := $(call unnest-vars,, \ libvhost-user-obj-y \ vhost-user-scsi-obj-y \ vhost-user-blk-obj-y \ + vhost-user-input-obj-y \ qga-vss-dll-obj-y \ block-obj-y \ block-obj-m \
@@ -610,6 +611,9 @@ rdmacm-mux$(EXESUF): LIBS += "-libumad" rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS) $(call LINK, $^) +vhost-user-input$(EXESUF): $(vhost-user-input-obj-y) libvhost-user.a libqemuutil.a + $(call LINK, $^) + module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak $(call quiet-command,$(PYTHON) $< $@ \ $(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
Makefile.objs +1 -0
@@ -122,6 +122,7 @@ vhost-user-scsi.o-libs := $(LIBISCSI_LIBS) vhost-user-scsi-obj-y = contrib/vhost-user-scsi/ vhost-user-blk-obj-y = contrib/vhost-user-blk/ rdmacm-mux-obj-y = contrib/rdmacm-mux/ +vhost-user-input-obj-y = contrib/vhost-user-input/ ###################################################################### trace-events-subdirs =
contrib/vhost-user-input/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +vhost-user-input-obj-y = main.o
Signature · 1 line
2.21.0.313.ge35b8cb8e2
Re: [Qemu-devel] [PATCH v6 04/11] contrib: add vhost-user-input
Quoted 11 lines · Marc-André Lureau
Add a vhost-user input backend example, based on virtio-input-host device. It takes an evdev path as argument, and can be associated with a vhost-user-input device via a UNIX socket:
$ vhost-user-input -p /dev/input/eventX -s /tmp/vui.sock$ qemu ... -chardev socket,id=vuic,path=/tmp/vui.sock -device vhost-user-input-pci,chardev=vuicThis example is intentionally not included in $TOOLS, to not be built and installed by default.
I think we should build it by default, so it doesn't bitrot, even if we don't install it by default.
Review
Quoted 2 lines
(quoted diff) +2
-0+static int unix_sock_new(char *path) +{
Move to common code?
cheers,
Gerd
Re: [Qemu-devel] [PATCH v6 04/11] contrib: add vhost-user-input
Hi
Quoted 14 lines · Gerd Hoffmann
Quoted 11 lines · Marc-André Lureau
Add a vhost-user input backend example, based on virtio-input-host device. It takes an evdev path as argument, and can be associated with a vhost-user-input device via a UNIX socket:
$ vhost-user-input -p /dev/input/eventX -s /tmp/vui.sock$ qemu ... -chardev socket,id=vuic,path=/tmp/vui.sock -device vhost-user-input-pci,chardev=vuicThis example is intentionally not included in $TOOLS, to not be built and installed by default.
Quoted 8 lines
I think we should build it by default, so it doesn't bitrot, even if we don't install it by default.
Review
Quoted 2 lines
(quoted diff) +2
-0+static int unix_sock_new(char *path) +{Move to common code?
Better, use existing unix_listen()!
thanks
Signature · 1 line
Marc-André Lureau
PATCH v6 5/11 vhost-user: add vhost_user_gpu_set_socket()
In reply to Marc-André LureauAdd a new vhost-user message to give a unix socket to a vhost-user backend for GPU display updates.
Back when I started that work, I added a new GPU channel because the vhost-user protocol wasn't bidirectional. Since then, there is a vhost-user-slave channel for the slave to send requests to the master. We could extend it with GPU messages. However, the GPU protocol is quite orthogonal to vhost-user, thus I chose to have a new dedicated channel.
See vhost-user-gpu.rst for the protocol details.
--- contrib/libvhost-user/libvhost-user.h | 1 + include/hw/virtio/vhost-backend.h | 2 + contrib/libvhost-user/libvhost-user.c | 1 + hw/virtio/vhost-user.c | 11 ++ MAINTAINERS | 6 + docs/interop/index.rst | 2 +- docs/interop/vhost-user-gpu.rst | 238 ++++++++++++++++++++++++++ docs/interop/vhost-user.txt | 9 + 8 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 docs/interop/vhost-user-gpu.rst
contrib/libvhost-user/libvhost-user.h +1 -0
@@ -94,6 +94,7 @@ typedef enum VhostUserRequest {VHOST_USER_POSTCOPY_END =30 ,VHOST_USER_GET_INFLIGHT_FD =31 ,VHOST_USER_SET_INFLIGHT_FD =32 , +VHOST_USER_GPU_SET_SOCKET =33 , VHOST_USER_MAX } VhostUserRequest;
include/hw/virtio/vhost-backend.h +2 -0
@@ -170,4 +170,6 @@ int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,int vhost_backend_handle_iotlb_msg (struct vhost_dev *dev,struct vhost_iotlb_msg *imsg); +int vhost_user_gpu_set_socket (struct vhost_dev *dev,int fd); +#endif /* VHOST_BACKEND_H */
contrib/libvhost-user/libvhost-user.c +1 -0
@@ -130,6 +130,7 @@ vu_request_to_string(unsigned int req)REQ (VHOST_USER_POSTCOPY_END ),REQ (VHOST_USER_GET_INFLIGHT_FD ),REQ (VHOST_USER_SET_INFLIGHT_FD ), +REQ (VHOST_USER_GPU_SET_SOCKET ), REQ(VHOST_USER_MAX), };#undef REQ
hw/virtio/vhost-user.c +11 -0
@@ -96,6 +96,7 @@ typedef enum VhostUserRequest {VHOST_USER_POSTCOPY_END =30 ,VHOST_USER_GET_INFLIGHT_FD =31 ,VHOST_USER_SET_INFLIGHT_FD =32 , +VHOST_USER_GPU_SET_SOCKET =33 , VHOST_USER_MAX } VhostUserRequest;
@@ -353,6 +354,16 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,return 0 ; } +int vhost_user_gpu_set_socket (struct vhost_dev *dev,int fd) +{ +VhostUserMsg msg = { + .hdr.request =VHOST_USER_GPU_SET_SOCKET , + .hdr.flags =VHOST_USER_VERSION , + }; + +return vhost_user_write (dev, &msg, &fd,1 ); +} +static int vhost_user_set_log_base (struct vhost_dev *dev,uint64_t base,struct vhost_log *log) {
MAINTAINERS +6 -0
@@ -1659,6 +1659,12 @@ F: hw/display/virtio-gpu* F: hw/display/virtio-vga.c F: include/hw/virtio/virtio-gpu.h +vhost-user-gpu +M: Marc-André Lureau <[email protected]> +M: Gerd Hoffmann <[email protected]> +S: Maintained +F: docs/interop/vhost-user-gpu.rst + Cirrus VGA M: Gerd Hoffmann <[email protected]> S: Odd Fixes
docs/interop/index.rst +1 -1
@@ -15,4 +15,4 @@ Contents: bitmaps live-block-operations pr-helper - + vhost-user-gpu
docs/interop/vhost-user-gpu.rst new file +238 -0
238 lines not on this page · raw message
docs/interop/vhost-user.txt +9 -0
@@ -1051,6 +1051,15 @@ Master message types the shared inflight buffer back to slave so that slave could get inflight I/O after a crash or restart. + * VHOST_USER_GPU_SET_SOCKET + Id: 33 + Master payload: N/A + Slave payload: N/A + + Sets the GPU protocol socket file descriptor, which is passed as + ancillary data. The GPU protocol is used to inform the master of + rendering state and updates. See vhost-user-gpu.rst for details. + Slave message types -------------------
Signature · 1 line
2.21.0.313.ge35b8cb8e2
Re: [Qemu-devel] [PATCH v6 05/11] vhost-user: add vhost_user_gpu_set_socket()
Quoted 2 lines · Marc-André Lureau
Add a new vhost-user message to give a unix socket to a vhost-user backend for GPU display updates.
Can you split input/gpu into two patch series?
Quoted 10 lines
docs/interop/vhost-user-gpu.rst new file +10
-0+Wire format +=========== + +Unless specified differently, numbers are in the machine native byte +order. + +A vhost-user-gpu request consists of 2 header fields and a payload. + ++---------+------+---------+ +| request | size | payload |
docs/interop/vhost-user-gpu.rst line 50
Quoted 10 lines
docs/interop/vhost-user-gpu.rst new file +10
-0++---------+------+---------+ + +Header +------ + +:request: ``u32``, type of the request + +:size: ``u32``, size of the payload + +A reply consists only of a payload, whose content depends on the request.
I'd suggest to use the same format for replies, only with "request" meaning "status" in replies. Allows for OK/ERROR status in replies, and having a size field in replies too should make things more robust. Also allows for an empty reply (status=ok,size=0).
cheers,
Gerd
Re: [Qemu-devel] [PATCH v6 05/11] vhost-user: add vhost_user_gpu_set_socket()
Hi
Quoted 24 lines · Gerd Hoffmann
Quoted 2 lines · Marc-André Lureau
Add a new vhost-user message to give a unix socket to a vhost-user backend for GPU display updates.
Can you split input/gpu into two patch series?
Quoted 17 lines
docs/interop/vhost-user-gpu.rst new file +17
-0+Wire format +=========== + +Unless specified differently, numbers are in the machine native byte +order. + +A vhost-user-gpu request consists of 2 header fields and a payload. + ++---------+------+---------+ +| request | size | payload | ++---------+------+---------+ + +Header +------ + +:request: ``u32``, type of the request +
Quoted 8 lines
Review
Quoted 3 lines
+:size: ``u32``, size of the payload
(quoted diff) +2
-0+ +A reply consists only of a payload, whose content depends on the request.I'd suggest to use the same format for replies, only with "request" meaning "status" in replies. Allows for OK/ERROR status in replies, and having a size field in replies too should make things more robust. Also allows for an empty reply (status=ok,size=0).
That brings more questions and ambiguity imho.
Can we leave that for future protocol extensions negotiated with GET/SET_PROTOCOL_FEATURES ?
--
Marc-André Lureau
Re: [Qemu-devel] [PATCH v6 05/11] vhost-user: add vhost_user_gpu_set_socket()
Hi,
Quoted 27 lines
Quoted 17 lines
Quoted 17 lines
docs/interop/vhost-user-gpu.rst new file +17
-0+Wire format +=========== + +Unless specified differently, numbers are in the machine native byte +order. + +A vhost-user-gpu request consists of 2 header fields and a payload. + ++---------+------+---------+ +| request | size | payload | ++---------+------+---------+ + +Header +------ + +:request: ``u32``, type of the request +Quoted 8 lines
Review
Quoted 3 lines
+:size: ``u32``, size of the payload
(quoted diff) +2
-0+ +A reply consists only of a payload, whose content depends on the request.I'd suggest to use the same format for replies, only with "request" meaning "status" in replies. Allows for OK/ERROR status in replies, and having a size field in replies too should make things more robust. Also allows for an empty reply (status=ok,size=0).
Quoted 1 line
That brings more questions and ambiguity imho.
What questions for example?
Quoted 2 lines
Can we leave that for future protocol extensions negotiated with GET/SET_PROTOCOL_FEATURES ?
I don't think negotiating such a basic protocol change is a good idea.
cheers,
Gerd
Re: [Qemu-devel] [PATCH v6 05/11] vhost-user: add vhost_user_gpu_set_socket()
Hi
Quoted 30 lines · Gerd Hoffmann
Hi,
Quoted 27 lines
Quoted 25 lines
Quoted 10 lines
docs/interop/vhost-user-gpu.rst new file +10
-0+Wire format +=========== + +Unless specified differently, numbers are in the machine native byte +order. + +A vhost-user-gpu request consists of 2 header fields and a payload. + ++---------+------+---------+ +| request | size | payload |docs/interop/vhost-user-gpu.rst line 50
Quoted 10 lines
docs/interop/vhost-user-gpu.rst new file +10
-0++---------+------+---------+ + +Header +------ + +:request: ``u32``, type of the request + +:size: ``u32``, size of the payload + +A reply consists only of a payload, whose content depends on the request.I'd suggest to use the same format for replies, only with "request" meaning "status" in replies. Allows for OK/ERROR status in replies, and having a size field in replies too should make things more robust. Also allows for an empty reply (status=ok,size=0).
Quoted 3 lines
Quoted 1 line
That brings more questions and ambiguity imho.
What questions for example?
This opens up different kind of possible replies, and error handling.
With current proposal and needs, the reply (or absence of reply) is entirely driven by the request.
With your proposal, should all request have a reply? which makes a lot more code synchronous, and complicates both sides unnecessarily.
Quoted 5 lines
Quoted 3 lines
Can we leave that for future protocol extensions negotiated with GET/SET_PROTOCOL_FEATURES ?
I don't think negotiating such a basic protocol change is a good idea.
Well, then I would rather focus on improving protocol negociation, rather than adding unnecessary protocol changes.
Given that GET/SET_PROTOCOL_FEATURES is the first messages being sent, why couldn't it have flags indicating new protocol revision?
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH v6 05/11] vhost-user: add vhost_user_gpu_set_socket()
Hi,
Quoted 8 lines
Quoted 1 line
What questions for example?
This opens up different kind of possible replies, and error handling.
With current proposal and needs, the reply (or absence of reply) is entirely driven by the request.
With your proposal, should all request have a reply?
Yes.
Quoted 2 lines
which makes a lot
more code synchronous,
Why? You don't have to wait for the reply before sending the next request.
Adding a request id to the messages might be useful, so it is possible to wait for a reply to a specific message without having to keeping track of all in-flight messages.
Quoted 1 line
and complicates both sides unnecessarily.
Having headers in the reply allows it to process them in generic code. There is a size header for the reply, so you can parse the stream without knowing what replay to expect. You can use the status field to indicate the payload, simliar to virtio-gpu which has response code OK_NODATA, some OK_$whatpayload and some ERR_$failure codes.
You can dispatch based on the response/status code and run *fully* asynchronous without too much trouble.
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
Can we leave that for future protocol extensions negotiated with GET/SET_PROTOCOL_FEATURES ?
I don't think negotiating such a basic protocol change is a good idea.
Well, then I would rather focus on improving protocol negociation, rather than adding unnecessary protocol changes.
Given that GET/SET_PROTOCOL_FEATURES is the first messages being sent, why couldn't it have flags indicating new protocol revision?
A properly structed reply allows a different approach in reply processing (see above). But that only works if it is in the protocol right from the start. As add-on feature it can't provide the benefits because the reply parser must be able to handle both protocol variants.
cheers,
Gerd
Re: [Qemu-devel] [PATCH v6 05/11] vhost-user: add vhost_user_gpu_set_socket()
Hi
Quoted 26 lines · Gerd Hoffmann
Hi,
Quoted 8 lines
Quoted 1 line
What questions for example?
This opens up different kind of possible replies, and error handling.
With current proposal and needs, the reply (or absence of reply) is entirely driven by the request.
With your proposal, should all request have a reply?
Yes.
Quoted 2 lines
which makes a lot
more code synchronous,Why? You don't have to wait for the reply before sending the next request.
Adding a request id to the messages might be useful, so it is possible to wait for a reply to a specific message without having to keeping track of all in-flight messages.
Quoted 1 line
and complicates both sides unnecessarily.
Quoted 8 lines
Having headers in the reply allows it to process them in generic code. There is a size header for the reply, so you can parse the stream without knowing what replay to expect. You can use the status field to indicate the payload, simliar to virtio-gpu which has response code
OK_NODATA, some OK_$whatpayload and some ERR_$failure codes.You can dispatch based on the response/status code and run *fully* asynchronous without too much trouble.
It's really a different level of complexity than what I needed so far.
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Can we leave that for future protocol extensions negotiated with GET/SET_PROTOCOL_FEATURES ?
I don't think negotiating such a basic protocol change is a good idea.
Well, then I would rather focus on improving protocol negociation, rather than adding unnecessary protocol changes.
Quoted 7 lines
Quoted 2 lines
Given that GET/SET_PROTOCOL_FEATURES is the first messages being sent, why couldn't it have flags indicating new protocol revision?
A properly structed reply allows a different approach in reply processing (see above). But that only works if it is in the protocol right from the start. As add-on feature it can't provide the benefits because the reply parser must be able to handle both protocol variants.
You are asking for a full-blown protocol... could we take DBus as an alternative instead?
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH v6 05/11] vhost-user: add vhost_user_gpu_set_socket()
Hi,
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
and complicates both sides unnecessarily.
Having headers in the reply allows it to process them in generic code. There is a size header for the reply, so you can parse the stream without knowing what replay to expect. You can use the status field to indicate the payload, simliar to virtio-gpu which has response code
OK_NODATA, some OK_$whatpayload and some ERR_$failure codes.
Quoted 4 lines
Quoted 2 lines
You can dispatch based on the response/status code and run *fully* asynchronous without too much trouble.
It's really a different level of complexity than what I needed so far.
That is a bit overboard, no?
All I'm asking for is:
(a) A header field telling what kind of payload has been sent, for both requests and replies.
(b) A header field telling what size the payload has.
That hardly is a different level of complexity. And that isn't up for negotiation.
If you absolutely don't want ack all requests, ok. Not sending a reply in case there is no payload to send back and no error to report is something I can live with.
Quoted 7 lines
Quoted 4 lines
A properly structed reply allows a different approach in reply processing (see above). But that only works if it is in the protocol right from the start. As add-on feature it can't provide the benefits because the reply parser must be able to handle both protocol variants.
You are asking for a full-blown protocol... could we take DBus as an alternative instead?
May I suggest QMP instead?
Seriously: If you want reuse something, just use the vhost-user wire format. Which is essentially what I'm asking for, plus an additional flags field in the header.
cheers,
Gerd
Re: [Qemu-devel] [PATCH v6 05/11] vhost-user: add vhost_user_gpu_set_socket()
In reply to Gerd HoffmannQuoted 45 lines · Gerd Hoffmann
Hi,
Quoted 8 lines
Quoted 1 line
What questions for example?
This opens up different kind of possible replies, and error handling.
With current proposal and needs, the reply (or absence of reply) is entirely driven by the request.
With your proposal, should all request have a reply?
Yes.
Quoted 2 lines
which makes a lot
more code synchronous,Why? You don't have to wait for the reply before sending the next request.
Adding a request id to the messages might be useful, so it is possible to wait for a reply to a specific message without having to keeping track of all in-flight messages.
Quoted 1 line
and complicates both sides unnecessarily.
Having headers in the reply allows it to process them in generic code. There is a size header for the reply, so you can parse the stream without knowing what replay to expect. You can use the status field to indicate the payload, simliar to virtio-gpu which has response code
OK_NODATA, some OK_$whatpayload and some ERR_$failure codes.You can dispatch based on the response/status code and run *fully* asynchronous without too much trouble.
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
Can we leave that for future protocol extensions negotiated with GET/SET_PROTOCOL_FEATURES ?
I don't think negotiating such a basic protocol change is a good idea.
Well, then I would rather focus on improving protocol negociation, rather than adding unnecessary protocol changes.
Given that GET/SET_PROTOCOL_FEATURES is the first messages being sent, why couldn't it have flags indicating new protocol revision?
Quoted 7 lines
A properly structed reply allows a different approach in reply processing (see above). But that only works if it is in the protocol right from the start. As add-on feature it can't provide the benefits because the reply parser must be able to handle both protocol variants.
cheers,
Gerd
I think it can in theory - but if we know we want a feature we should just add it as mandatory. More options does imply more overhead.
Signature · 1 line
MST
PATCH v6 6/11 virtio: add virtio-gpu bswap helpers header
In reply to Marc-André LureauThe helper functions are useful to build the vhost-user-gpu backend.
--- include/hw/virtio/virtio-gpu-bswap.h | 61 ++++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 43 +------------------- 2 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 include/hw/virtio/virtio-gpu-bswap.h
include/hw/virtio/virtio-gpu-bswap.h new file +61 -0
@@ -0,0 +1,61 @@ +/* +* Virtio GPU Device +* +* Copyright Red Hat, Inc. 2013-2014 +* +* Authors: +* Dave Airlie <[email protected]> +* Gerd Hoffmann <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_VIRTIO_GPU_BSWAP_H +#define HW_VIRTIO_GPU_BSWAP_H + +#include "qemu/bswap.h" + +static inline void +virtio_gpu_ctrl_hdr_bswap (struct virtio_gpu_ctrl_hdr *hdr) +{ +le32_to_cpus (&hdr->type); +le32_to_cpus (&hdr->flags); +le64_to_cpus (&hdr->fence_id); +le32_to_cpus (&hdr->ctx_id); +le32_to_cpus (&hdr->padding); +} + +static inline void +virtio_gpu_bswap_32 (void *ptr,size_t size) +{ +#ifdef HOST_WORDS_BIGENDIAN + +size_t i; +struct virtio_gpu_ctrl_hdr *hdr = (struct virtio_gpu_ctrl_hdr *) ptr; + +virtio_gpu_ctrl_hdr_bswap (hdr); + + i =sizeof (struct virtio_gpu_ctrl_hdr ); +while (i < size) { +le32_to_cpus ((uint32_t *)(ptr + i)); + i = i +sizeof (uint32_t ); + } + +#endif +} + +static inline void +virtio_gpu_t2d_bswap (struct virtio_gpu_transfer_to_host_2d *t2d) +{ +virtio_gpu_ctrl_hdr_bswap (&t2d->hdr); +le32_to_cpus (&t2d->r.x); +le32_to_cpus (&t2d->r.y); +le32_to_cpus (&t2d->r.width); +le32_to_cpus (&t2d->r.height); +le64_to_cpus (&t2d->offset); +le32_to_cpus (&t2d->resource_id); +le32_to_cpus (&t2d->padding); +} + +#endif
hw/display/virtio-gpu.c +1 -42
55 lines not on this page · raw message
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v6 7/11 util: compile drm.o on Linux
In reply to Marc-André LureauOpenGL isn't required to use DRM rendernodes. The following patches uses it for 2d resources for ex.
--- util/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/Makefile.objs +1 -1
@@ -52,6 +52,6 @@ util-obj-y += systemd.o util-obj-y += iova-tree.o util-obj-$(CONFIG_INOTIFY1) += filemonitor-inotify.o util-obj-$(CONFIG_LINUX) += vfio-helpers.o -util-obj-$(CONFIG_OPENGL) += drm.o +util-obj-$(CONFIG_LINUX) += drm.o stub-obj-y += filemonitor-stub.o
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v6 8/11 contrib: add vhost-user-gpu
In reply to Marc-André LureauAdd a vhost-user gpu backend, based on virtio-gpu/3d device. It is to be associated with a vhost-user-gpu device.
Various TODO and nice to have items:
- multi-head support
- crash & resume handling
- accelerated rendering/display that avoids the waiting round trips
- more drm devices support for 2d surfaces
- edid support
--- contrib/vhost-user-gpu/drm.h | 72 ++ contrib/vhost-user-gpu/virgl.h | 25 + contrib/vhost-user-gpu/vugpu.h | 170 +++ contrib/vhost-user-gpu/drm.c | 341 ++++++ contrib/vhost-user-gpu/main.c | 1236 ++++++++++++++++++++ contrib/vhost-user-gpu/virgl.c | 579 +++++++++ MAINTAINERS | 2 + Makefile | 23 +- Makefile.objs | 1 + configure | 29 + contrib/vhost-user-gpu/50-qemu-gpu.json.in | 5 + contrib/vhost-user-gpu/Makefile.objs | 10 + rules.mak | 9 +- 13 files changed, 2500 insertions(+), 2 deletions(-) create mode 100644 contrib/vhost-user-gpu/drm.h create mode 100644 contrib/vhost-user-gpu/virgl.h create mode 100644 contrib/vhost-user-gpu/vugpu.h create mode 100644 contrib/vhost-user-gpu/drm.c create mode 100644 contrib/vhost-user-gpu/main.c create mode 100644 contrib/vhost-user-gpu/virgl.c create mode 100644 contrib/vhost-user-gpu/50-qemu-gpu.json.in create mode 100644 contrib/vhost-user-gpu/Makefile.objs
contrib/vhost-user-gpu/drm.h new file +72 -0
@@ -0,0 +1,72 @@ +/* +* Virtio vhost-user GPU Device +* +* DRM helpers +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#ifndef VHOST_USER_GPU_DRM_H +#define VHOST_USER_GPU_DRM_H + +#include "qemu/osdep.h" + +#ifdef CONFIG_LIBDRM_INTEL +#include <i915_drm.h> +#include <intel_bufmgr.h> +#endif + +#ifdef CONFIG_MEMFD +#include <sys/mman.h> +#include <sys/ioctl.h> +#endif + +struct drm_buffer ; + +struct drm_device { +bool inited; +int fd; +char *name; +#ifdef CONFIG_LIBDRM_INTEL +drm_intel_bufmgr *bufmgr; +#endif + +bool (*alloc_bo)(struct drm_buffer *buf); +void (*free_bo)(struct drm_buffer *buf); +bool (*export_bo_to_prime)(struct drm_buffer *buf,int *fd); +bool (*map_bo)(struct drm_buffer *buf); +void (*unmap_bo)(struct drm_buffer *buf); +void (*device_destroy)(struct drm_device *dev); +}; + +struct drm_buffer { +struct drm_device *dev; + +#ifdef CONFIG_LIBDRM_INTEL +drm_intel_bo *intel_bo; +#endif /* HAVE_LIBDRM_INTEL */ +#ifdef CONFIG_MEMFD +int memfd; +#endif + +uint32_t gem_handle; +int dmabuf_fd; +uint8_t *mmap; + +int width; +int height; +int bpp; +unsigned long stride; +int format; +}; + +bool drm_device_init (struct drm_device *dev,int fd); +void drm_device_destroy (struct drm_device *dev); + +bool drm_buffer_create (struct drm_buffer *buffer,struct drm_device *dev, +int width,int height); +bool drm_buffer_can_get_dmabuf_fd (struct drm_buffer *buffer); +bool drm_buffer_get_dmabuf_fd (struct drm_buffer *buffer,int *fd); +void drm_buffer_destroy (struct drm_buffer *buffer); + +#endif
contrib/vhost-user-gpu/virgl.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Virtio vhost-user GPU Device +* +* Copyright Red Hat, Inc. 2013-2018 +* +* Authors: +* Dave Airlie <[email protected]> +* Gerd Hoffmann <[email protected]> +* Marc-André Lureau <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ +#ifndef VUGPU_VIRGL_H_ +#define VUGPU_VIRGL_H_ + +#include "vugpu.h" + +bool vg_virgl_init (VuGpu *g); +uint32_t vg_virgl_get_num_capsets (void ); +void vg_virgl_process_cmd (VuGpu *vg,struct virtio_gpu_ctrl_command *cmd); +void vg_virgl_update_cursor_data (VuGpu *g,uint32_t resource_id, +gpointer data); + +#endif
contrib/vhost-user-gpu/vugpu.h new file +170 -0
170 lines not on this page · raw message
contrib/vhost-user-gpu/drm.c new file +341 -0
341 lines not on this page · raw message
contrib/vhost-user-gpu/main.c new file +1236 -0
1,236 lines not on this page · raw message
contrib/vhost-user-gpu/virgl.c new file +579 -0
579 lines not on this page · raw message
MAINTAINERS +2 -0
@@ -1664,6 +1664,8 @@ M: Marc-André Lureau <[email protected]> M: Gerd Hoffmann <[email protected]> S: Maintained F: docs/interop/vhost-user-gpu.rst +F: contrib/vhost-user-gpu +F: hw/display/vhost-user-* Cirrus VGA M: Gerd Hoffmann <[email protected]>
Makefile +22 -1
@@ -308,8 +308,20 @@ $(call set-vpath, $(SRC_PATH)) LIBS+=-lz $(LIBS_TOOLS) +vhost-user-json-y = +HELPERS-y = + HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF) +ifdef CONFIG_LINUX +ifdef CONFIG_VIRGL +ifdef CONFIG_LIBDRM +HELPERS-y += vhost-user-gpu$(EXESUF) +vhost-user-json-y += contrib/vhost-user-gpu/50-qemu-gpu.json +endif +endif +endif + ifdef BUILD_DOCS DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
@@ -403,6 +415,7 @@ dummy := $(call unnest-vars,, \ vhost-user-scsi-obj-y \ vhost-user-blk-obj-y \ vhost-user-input-obj-y \ + vhost-user-gpu-obj-y \ qga-vss-dll-obj-y \ block-obj-y \ block-obj-m \
@@ -420,7 +433,7 @@ dummy := $(call unnest-vars,, \ include $(SRC_PATH)/tests/Makefile.include -all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules +all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y) qemu-version.h: FORCE $(call quiet-command, \
@@ -613,6 +626,8 @@ rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS) vhost-user-input$(EXESUF): $(vhost-user-input-obj-y) libvhost-user.a libqemuutil.a $(call LINK, $^) +vhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) $(libvhost-user-obj-y) libqemuutil.a libqemustub.a + $(call LINK, $^) module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak $(call quiet-command,$(PYTHON) $< $@ \
@@ -805,6 +820,12 @@ endif ifneq ($(HELPERS-y),) $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir)) endif +ifneq ($(vhost-user-json-y),) + $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/vhost-user/" + for x in $(vhost-user-json-y); do \ + $(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)/vhost-user/"; \ + done +endif ifdef CONFIG_TRACE_SYSTEMTAP $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir) endif
Makefile.objs +1 -0
@@ -123,6 +123,7 @@ vhost-user-scsi-obj-y = contrib/vhost-user-scsi/ vhost-user-blk-obj-y = contrib/vhost-user-blk/ rdmacm-mux-obj-y = contrib/rdmacm-mux/ vhost-user-input-obj-y = contrib/vhost-user-input/ +vhost-user-gpu-obj-y = contrib/vhost-user-gpu/ ###################################################################### trace-events-subdirs =
configure +29 -0
@@ -4095,6 +4095,20 @@ libs_softmmu="$libs_softmmu $fdt_libs" ########################################## # opengl probe (for sdl2, gtk, milkymist-tmu2) +libdrm="no" +if $pkg_config libdrm; then + libdrm_cflags="$($pkg_config --cflags libdrm)" + libdrm_libs="$($pkg_config --libs libdrm)" + libdrm="yes" +fi + +libdrm_intel="no" +if $pkg_config libdrm_intel; then + libdrm_intel_cflags="$($pkg_config --cflags libdrm_intel)" + libdrm_intel_libs="$($pkg_config --libs libdrm_intel)" + libdrm_intel="yes" +fi + if test "$opengl" != "no" ; then opengl_pkgs="epoxy gbm" if $pkg_config $opengl_pkgs; then
@@ -6939,6 +6953,18 @@ if test "$opengl" = "yes" ; then fi fi +if test "$libdrm" = "yes" ; then + echo "CONFIG_LIBDRM=y" >> $config_host_mak + echo "LIBDRM_LIBS=$libdrm_libs" >> $config_host_mak + echo "LIBDRM_CFLAGS=$libdrm_cflags" >> $config_host_mak +fi + +if test "$libdrm_intel" = "yes" ; then + echo "CONFIG_LIBDRM_INTEL=y" >> $config_host_mak + echo "LIBDRM_INTEL_LIBS=$libdrm_intel_libs" >> $config_host_mak + echo "LIBDRM_INTEL_CFLAGS=$libdrm_intel_cflags" >> $config_host_mak +fi + if test "$malloc_trim" = "yes" ; then echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak fi
@@ -7832,6 +7858,9 @@ echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak done # for target in $targets +echo "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak +echo "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak + if test -n "$enabled_cross_compilers"; then echo echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
contrib/vhost-user-gpu/50-qemu-gpu.json.in new file +5 -0
@@ -0,0 +1,5 @@ +{ + "description": "QEMU vhost-user-gpu", + "type": "gpu", + "binary": "@libexecdir@/vhost-user-gpu", +}
contrib/vhost-user-gpu/Makefile.objs new file +10 -0
@@ -0,0 +1,10 @@ +vhost-user-gpu-obj-y = main.o virgl.o drm.o + +main.o-cflags := $(PIXMAN_CFLAGS) $(LIBDRM_CFLAGS) $(LIBDRM_INTEL_CFLAGS) +main.o-libs := $(PIXMAN_LIBS) + +virgl.o-cflags := $(VIRGL_CFLAGS) $(LIBDRM_CFLAGS) $(LIBDRM_INTEL_CFLAGS) +virgl.o-libs := $(VIRGL_LIBS) + +drm.o-cflags := $(LIBDRM_CFLAGS) $(LIBDRM_INTEL_CFLAGS) +drm.o-libs := $(LIBDRM_LIBS) $(LIBDRM_INTEL_LIBS)
rules.mak +8 -1
@@ -144,7 +144,7 @@ cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ >/dev/null 2>&1 && echo OK), $2, $3) -VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconfig% +VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconfig% %.json.in set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) # install-prog list, dir
@@ -392,3 +392,10 @@ TEXI2MAN = $(call quiet-command, \ $(call TEXI2MAN) %.8: $(call TEXI2MAN) + +GEN_SUBST = $(call quiet-command, \ + sed -e "s!@libexecdir@!$(libexecdir)!g" < $< > $@, \ + "GEN","$@") + +%.json: %.json.in + $(call GEN_SUBST)
Signature · 1 line
2.21.0.313.ge35b8cb8e2
Re: [Qemu-devel] [PATCH v6 08/11] contrib: add vhost-user-gpu
Hi,
contrib/vhost-user-gpu/drm.c line 142
Quoted 10 lines
contrib/vhost-user-gpu/drm.c new file +10
-0+#ifdef CONFIG_LIBDRM_INTEL +static bool +intel_alloc_bo (struct drm_buffer *buf) +{ +uint32_t tiling =I915_TILING_NONE ; + + buf->intel_bo =drm_intel_bo_alloc_tiled (buf->dev->bufmgr,"vhost-user-gpu" , + buf->width, buf->height, + (buf->bpp /8 ), &tiling, + &buf->stride,0 );
Why do you go for intel specific code here?
Can't you do the same with gbm_bo_create() orgbm_bo_create_with_modifiers() ?
contrib/vhost-user-gpu/drm.c line 167
Quoted 6 lines
contrib/vhost-user-gpu/drm.c new file +6
-0+static bool +intel_map_bo (struct drm_buffer *buf) +{ +if (drm_intel_gem_bo_map_gtt (buf->intel_bo) !=0 ) { +return false; + }
gbm_bo_map()
contrib/vhost-user-gpu/drm.c line 179
Quoted 6 lines
contrib/vhost-user-gpu/drm.c new file +6
-0+static bool +intel_export_bo_to_prime (struct drm_buffer *buffer,int *fd) +{ +if (drm_intel_bo_gem_export_to_prime (buffer->intel_bo, fd) <0 ) { +return false; + }
gbm_bo_get_fd()
contrib/vhost-user-gpu/main.c line 262
Quoted 6 lines
contrib/vhost-user-gpu/main.c new file +6
-0+get_pixman_format(uint32_t virtio_gpu_format) +{ +switch (virtio_gpu_format) { +#ifdef HOST_WORDS_BIGENDIAN +case VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM : +return PIXMAN_b8g8r8x8;
Move that to a header for sharing? Simliar to the bswap helpers?
Quoted 12 lines
contrib/vhost-user-gpu/virgl.c new file +12
-0+static void +virgl_cmd_create_resource_3d (VuGpu *g, +struct virtio_gpu_ctrl_command *cmd) +{ +struct virtio_gpu_resource_create_3d c3d; +struct virgl_renderer_resource_create_args args; + +VUGPU_FILL_CMD (c3d); + + args.handle = c3d.resource_id; + args.target = c3d.target; + args.format = c3d.format;
contrib/vhost-user-gpu/virgl.c line 101
Quoted 10 lines
contrib/vhost-user-gpu/virgl.c new file +10
-0+ args.bind = c3d.bind; + args.width = c3d.width; + args.height = c3d.height; + args.depth = c3d.depth; + args.array_size = c3d.array_size; + args.last_level = c3d.last_level; + args.nr_samples = c3d.nr_samples; + args.flags = c3d.flags; +virgl_renderer_resource_create (&args,NULL ,0 ); +}
The virtio_gpu_resource_create_3d -> virgl_renderer_resource_create_args mapping looks like an opportunity for code sharing too.
Hmm, but virgl_renderer_resource_create seems to be the only call with an args struct, so maybe not worth the effort for this single case.
cheers,
Gerd
Re: [Qemu-devel] [PATCH v6 08/11] contrib: add vhost-user-gpu
Hi
Quoted 16 lines · Gerd Hoffmann
Hi,
contrib/vhost-user-gpu/drm.c line 142
Quoted 10 lines
contrib/vhost-user-gpu/drm.c new file +10
-0+#ifdef CONFIG_LIBDRM_INTEL +static bool +intel_alloc_bo (struct drm_buffer *buf) +{ +uint32_t tiling =I915_TILING_NONE ; + + buf->intel_bo =drm_intel_bo_alloc_tiled (buf->dev->bufmgr,"vhost-user-gpu" , + buf->width, buf->height, + (buf->bpp /8 ), &tiling, + &buf->stride,0 );Why do you go for intel specific code here?
No idea, most likely some functions were lacking when I looked at it. GBM is fine now.
Quoted 2 lines
Can't you do the same with
gbm_bo_create()orgbm_bo_create_with_modifiers()?
It's not clear to me how to properly use gbm_bo_create_with_modifiers(). I went with gbm_bo_create() for now, it "works for me".
Quoted 19 lines
contrib/vhost-user-gpu/drm.c line 167
Quoted 7 lines
contrib/vhost-user-gpu/drm.c new file +6
-0+static bool +intel_map_bo (struct drm_buffer *buf) +{ +if (drm_intel_gem_bo_map_gtt (buf->intel_bo) !=0 ) { +return false; + }
gbm_bo_map()contrib/vhost-user-gpu/drm.c line 179
Quoted 6 lines
contrib/vhost-user-gpu/drm.c new file +6
-0+static bool +intel_export_bo_to_prime (struct drm_buffer *buffer,int *fd) +{ +if (drm_intel_bo_gem_export_to_prime (buffer->intel_bo, fd) <0 ) { +return false; + }
gbm_bo_get_fd()
Quoted 8 lines
contrib/vhost-user-gpu/main.c line 262
Quoted 6 lines
contrib/vhost-user-gpu/main.c new file +6
-0+get_pixman_format(uint32_t virtio_gpu_format) +{ +switch (virtio_gpu_format) { +#ifdef HOST_WORDS_BIGENDIAN +case VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM : +return PIXMAN_b8g8r8x8;Move that to a header for sharing? Simliar to the bswap helpers?
ack
Quoted 27 lines
Quoted 13 lines
contrib/vhost-user-gpu/virgl.c new file +12
-0+static void +virgl_cmd_create_resource_3d (VuGpu *g, +struct virtio_gpu_ctrl_command *cmd) +{ +struct virtio_gpu_resource_create_3d c3d; +struct virgl_renderer_resource_create_args args; + +VUGPU_FILL_CMD (c3d); + + args.handle = c3d.resource_id; + args.target = c3d.target; + args.format = c3d.format;contrib/vhost-user-gpu/virgl.c line 101
Quoted 10 lines
contrib/vhost-user-gpu/virgl.c new file +10
-0+ args.bind = c3d.bind; + args.width = c3d.width; + args.height = c3d.height; + args.depth = c3d.depth; + args.array_size = c3d.array_size; + args.last_level = c3d.last_level; + args.nr_samples = c3d.nr_samples; + args.flags = c3d.flags; +virgl_renderer_resource_create (&args,NULL ,0 ); +}The
virtio_gpu_resource_create_3d->virgl_renderer_resource_create_argsmapping looks like an opportunity for code sharing too.
Quoted 2 lines
Hmm, but
virgl_renderer_resource_createseems to be the only call with an args struct, so maybe not worth the effort for this single case.
yeah, I will not bother for now
thanks!
Signature · 1 line
Marc-André Lureau
PATCH v6 9/11 virtio-gpu: split virtio-gpu, introduce virtio-gpu-base
In reply to Marc-André LureauAdd a base class that is common to virtio-gpu and vhost-user-gpu devices.
The VirtIOGPUBase base class provides common functionalities necessary for both virtio-gpu and vhost-user-gpu:
- common configuration (max-outputs, initial resolution, flags)
- virtio device initialization, including queue setup
- device pre-conditions checks (iommu)
- migration blocker
- virtio device callbacks
- hooking up to qemu display subsystem
- a few common helper functions to reset the device, retrieve display informations
- a class callback to unblock the rendering (for GL updates)
What is left to the virtio-gpu subdevice to take care of, in short, are all the virtio queues handling, command processing and migration.
--- include/hw/virtio/virtio-gpu.h | 73 +++++-- hw/display/virtio-gpu-3d.c | 49 +++-- hw/display/virtio-gpu-base.c | 268 ++++++++++++++++++++++++ hw/display/virtio-gpu-pci.c | 2 +- hw/display/virtio-gpu.c | 372 +++++++++------------------------ hw/display/virtio-vga.c | 11 +- hw/display/Makefile.objs | 2 +- 7 files changed, 458 insertions(+), 319 deletions(-) create mode 100644 hw/display/virtio-gpu-base.c
include/hw/virtio/virtio-gpu.h +56 -17
@@ -22,6 +22,14 @@#include "standard-headers/linux/virtio_gpu.h" +#define TYPE_VIRTIO_GPU_BASE "virtio-gpu-base" +#define VIRTIO_GPU_BASE (obj) \ + OBJECT_CHECK(VirtIOGPUBase, (obj), TYPE_VIRTIO_GPU_BASE) +#define VIRTIO_GPU_BASE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(VirtIOGPUBaseClass, obj, TYPE_VIRTIO_GPU_BASE) +#define VIRTIO_GPU_BASE_CLASS (klass) \ + OBJECT_CLASS_CHECK(VirtIOGPUBaseClass, klass, TYPE_VIRTIO_GPU_BASE) +#define TYPE_VIRTIO_GPU "virtio-gpu-device"#define VIRTIO_GPU (obj) \ OBJECT_CHECK(VirtIOGPU, (obj), TYPE_VIRTIO_GPU)
@@ -58,7 +66,7 @@ struct virtio_gpu_requested_state {int x, y; }; -enum virtio_gpu_conf_flags { +enum virtio_gpu_base_conf_flags {VIRTIO_GPU_FLAG_VIRGL_ENABLED =1 ,VIRTIO_GPU_FLAG_STATS_ENABLED ,VIRTIO_GPU_FLAG_EDID_ENABLED ,
@@ -71,8 +79,7 @@ enum virtio_gpu_conf_flags {#define virtio_gpu_edid_enabled (_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_EDID_ENABLED)) -struct virtio_gpu_conf { -uint64_t max_hostmem; +struct virtio_gpu_base_conf {uint32_t max_outputs;uint32_t flags;uint32_t xres;
@@ -88,31 +95,55 @@ struct virtio_gpu_ctrl_command {QTAILQ_ENTRY (virtio_gpu_ctrl_command) next; }; -typedef struct VirtIOGPU { +typedef struct VirtIOGPUBase {VirtIODevice parent_obj; - QEMUBH *ctrl_bh; - QEMUBH *cursor_bh; +Error *migration_blocker; + +struct virtio_gpu_base_conf conf; +struct virtio_gpu_config virtio_config; + +bool use_virgl_renderer; +int renderer_blocked; +int enable; + +struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS ]; + +int enabled_output_bitmask; +struct virtio_gpu_requested_state req_state[VIRTIO_GPU_MAX_SCANOUTS ]; +}VirtIOGPUBase ; + +typedef struct VirtIOGPUBaseClass { +VirtioDeviceClass parent; + +void (*gl_unblock)(VirtIOGPUBase *g); +}VirtIOGPUBaseClass ; + +#define VIRTIO_GPU_BASE_PROPERTIES (_state, _conf) \ + DEFINE_PROP_UINT32("max_outputs", _state, _conf.max_outputs, 1), \ + DEFINE_PROP_BIT("edid", _state, _conf.flags, \ + VIRTIO_GPU_FLAG_EDID_ENABLED, false), \ + DEFINE_PROP_UINT32("xres", _state, _conf.xres, 1024), \ + DEFINE_PROP_UINT32("yres", _state, _conf.yres, 768) + +typedef struct VirtIOGPU { + VirtIOGPUBase parent_obj; + + uint64_t conf_max_hostmem; + VirtQueue *ctrl_vq; VirtQueue *cursor_vq; - int enable; + QEMUBH *ctrl_bh; + QEMUBH *cursor_bh; QTAILQ_HEAD(, virtio_gpu_simple_resource) reslist; QTAILQ_HEAD(, virtio_gpu_ctrl_command) cmdq; QTAILQ_HEAD(, virtio_gpu_ctrl_command) fenceq; - struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; - struct virtio_gpu_requested_state req_state[VIRTIO_GPU_MAX_SCANOUTS]; - - struct virtio_gpu_conf conf; uint64_t hostmem; - int enabled_output_bitmask; - struct virtio_gpu_config virtio_config; - bool use_virgl_renderer; bool renderer_inited; - int renderer_blocked; bool renderer_reset; QEMUTimer *fence_poll; QEMUTimer *print_stats;
@@ -124,8 +155,6 @@ typedef struct VirtIOGPU {uint32_t req_3d;uint32_t bytes_3d; } stats; - -Error *migration_blocker; } VirtIOGPU;extern const GraphicHwOps virtio_gpu_ops;
@@ -148,6 +177,15 @@ extern const GraphicHwOps virtio_gpu_ops; } \ }while (0 ) +/* virtio-gpu-base.c */ +bool virtio_gpu_base_device_realize(DeviceState *qdev, + VirtIOHandleOutput ctrl_cb, + VirtIOHandleOutput cursor_cb, + Error **errp); +void virtio_gpu_base_reset (VirtIOGPUBase *g); +void virtio_gpu_base_fill_display_info (VirtIOGPUBase *g, +struct virtio_gpu_resp_display_info *dpy_info); +/* virtio-gpu.c */ void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd,
@@ -175,4 +213,5 @@ void virtio_gpu_virgl_fence_poll(VirtIOGPU *g);void virtio_gpu_virgl_reset (VirtIOGPU *g);int virtio_gpu_virgl_init (VirtIOGPU *g);int virtio_gpu_virgl_get_num_capsets (VirtIOGPU *g); +#endif
hw/display/virtio-gpu-3d.c +26 -23
131 lines not on this page · raw message
hw/display/virtio-gpu-base.c new file +268 -0
268 lines not on this page · raw message
hw/display/virtio-gpu-pci.c +1 -1
@@ -41,7 +41,7 @@ static Property virtio_gpu_pci_properties[] = {static void virtio_gpu_pci_realize (VirtIOPCIProxy *vpci_dev,Error **errp) {VirtIOGPUPCI *vgpu =VIRTIO_GPU_PCI (vpci_dev); -VirtIOGPU *g = &vgpu->vdev; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vgpu->vdev);DeviceState *vdev =DEVICE (&vgpu->vdev);int i;Error *local_error =NULL ;
hw/display/virtio-gpu.c +99 -273
628 lines not on this page · raw message
hw/display/virtio-vga.c +7 -4
@@ -32,8 +32,9 @@ typedef struct VirtIOVGAClass {static void virtio_vga_invalidate_display (void *opaque) {VirtIOVGA *vvga = opaque; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vvga->vdev); -if (vvga->vdev.enable) { +if (g->enable) { virtio_gpu_ops.invalidate (&vvga->vdev); }else { vvga->vga.hw_ops->invalidate (&vvga->vga);
@@ -43,8 +44,9 @@ static void virtio_vga_invalidate_display(void *opaque)static void virtio_vga_update_display (void *opaque) {VirtIOVGA *vvga = opaque; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vvga->vdev); -if (vvga->vdev.enable) { +if (g->enable) { virtio_gpu_ops.gfx_update (&vvga->vdev); }else { vvga->vga.hw_ops->gfx_update (&vvga->vga);
@@ -54,8 +56,9 @@ static void virtio_vga_update_display(void *opaque)static void virtio_vga_text_update (void *opaque,console_ch_t *chardata) {VirtIOVGA *vvga = opaque; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vvga->vdev); -if (vvga->vdev.enable) { +if (g->enable) {if (virtio_gpu_ops.text_update) { virtio_gpu_ops.text_update (&vvga->vdev, chardata); }
@@ -108,7 +111,7 @@ static const VMStateDescription vmstate_virtio_vga = {static void virtio_vga_realize (VirtIOPCIProxy *vpci_dev,Error **errp) {VirtIOVGA *vvga =VIRTIO_VGA (vpci_dev); -VirtIOGPU *g = &vvga->vdev; +VirtIOGPUBase *g =VIRTIO_GPU_BASE (&vvga->vdev);VGACommonState *vga = &vvga->vga;Error *err =NULL ;uint32_t offset;
hw/display/Makefile.objs +1 -1
@@ -42,7 +42,7 @@ obj-$(CONFIG_VGA) += vga.o common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o -obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu.o virtio-gpu-3d.o +obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v6 10/11 virtio-gpu: split virtio-gpu-pci & virtio-vga
In reply to Marc-André LureauAdd base classes that are common to vhost-user-gpu-pci and vhost-user-vga.
--- hw/display/virtio-vga.h | 32 +++++++++ hw/display/virtio-gpu-pci.c | 52 +++++++++----- hw/display/virtio-vga.c | 135 ++++++++++++++++++------------------ MAINTAINERS | 2 +- 4 files changed, 137 insertions(+), 84 deletions(-) create mode 100644 hw/display/virtio-vga.h
hw/display/virtio-vga.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef VIRTIO_VGA_H_ +#define VIRTIO_VGA_H_ + +#include "hw/virtio/virtio-pci.h" +#include "vga_int.h" + +/* +* virtio-vga-base: This extends VirtioPCIProxy. +*/ +#define TYPE_VIRTIO_VGA_BASE "virtio-vga-base" +#define VIRTIO_VGA_BASE (obj) \ + OBJECT_CHECK(VirtIOVGABase, (obj), TYPE_VIRTIO_VGA_BASE) +#define VIRTIO_VGA_BASE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(VirtIOVGABaseClass, obj, TYPE_VIRTIO_VGA_BASE) +#define VIRTIO_VGA_BASE_CLASS (klass) \ + OBJECT_CLASS_CHECK(VirtIOVGABaseClass, klass, TYPE_VIRTIO_VGA_BASE) + +typedef struct VirtIOVGABase { +VirtIOPCIProxy parent_obj; + +VirtIOGPUBase *vgpu; +VGACommonState vga; +MemoryRegion vga_mrs[3 ]; +}VirtIOVGABase ; + +typedef struct VirtIOVGABaseClass { +VirtioPCIClass parent_class; + +DeviceReset parent_reset; +}VirtIOVGABaseClass ; + +#endif /* VIRTIO_VGA_H_ */
hw/display/virtio-gpu-pci.c +36 -16
102 lines not on this page · raw message
hw/display/virtio-vga.c +68 -67
248 lines not on this page · raw message
MAINTAINERS +1 -1
@@ -1656,7 +1656,7 @@ virtio-gpu M: Gerd Hoffmann <[email protected]> S: Maintained F: hw/display/virtio-gpu* -F: hw/display/virtio-vga.c +F: hw/display/virtio-vga.* F: include/hw/virtio/virtio-gpu.h vhost-user-gpu
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v6 11/11 hw/display: add vhost-user-vga & gpu-pci
In reply to Marc-André LureauAdd new virtio-gpu devices with a "vhost-user" property. The associated vhost-user backend is used to handle the virtio rings and provide rendering results thanks to the vhost-user-gpu protocol.
Example usage:
-object vhost-user-backend,id=vug,cmd="./vhost-user-gpu" -device vhost-user-vga,vhost-user=vug
--- hw/display/virtio-vga.h | 2 +- include/hw/virtio/virtio-gpu-pci.h | 40 ++ include/hw/virtio/virtio-gpu.h | 19 +- hw/display/vhost-user-gpu-pci.c | 51 +++ hw/display/vhost-user-gpu.c | 572 +++++++++++++++++++++++++++++ hw/display/vhost-user-vga.c | 52 +++ hw/display/virtio-gpu-pci.c | 17 +- vl.c | 1 + hw/display/Kconfig | 10 + hw/display/Makefile.objs | 3 + 10 files changed, 744 insertions(+), 23 deletions(-) create mode 100644 include/hw/virtio/virtio-gpu-pci.h create mode 100644 hw/display/vhost-user-gpu-pci.c create mode 100644 hw/display/vhost-user-gpu.c create mode 100644 hw/display/vhost-user-vga.c
hw/display/virtio-vga.h +1 -1
@@ -1,7 +1,7 @@#ifndef VIRTIO_VGA_H_ #define VIRTIO_VGA_H_ -#include "hw/virtio/virtio-pci.h" +#include "hw/virtio/virtio-gpu-pci.h" #include "vga_int.h" /*
include/hw/virtio/virtio-gpu-pci.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Virtio GPU PCI Device +* +* Copyright Red Hat, Inc. 2013-2014 +* +* Authors: +* Dave Airlie <[email protected]> +* Gerd Hoffmann <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. +* See the COPYING file in the top-level directory. +*/ + +#ifndef HW_VIRTIO_GPU_PCI_H +#define HW_VIRTIO_GPU_PCI_H + +#include "hw/virtio/virtio-pci.h" +#include "hw/virtio/virtio-gpu.h" + +typedef struct VirtIOGPUPCIBase VirtIOGPUPCIBase ; + +/* +* virtio-gpu-pci-base: This extends VirtioPCIProxy. +*/ +#define TYPE_VIRTIO_GPU_PCI_BASE "virtio-gpu-pci-base" +#define VIRTIO_GPU_PCI_BASE (obj) \ + OBJECT_CHECK(VirtIOGPUPCIBase, (obj), TYPE_VIRTIO_GPU_PCI_BASE) + +struct VirtIOGPUPCIBase { +VirtIOPCIProxy parent_obj; +VirtIOGPUBase *vgpu; +}; + +/* to share between PCI and VGA */ +#define DEFINE_VIRTIO_GPU_PCI_PROPERTIES (_state) \ + DEFINE_PROP_BIT("ioeventfd", _state, flags, \ + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false), \ + DEFINE_PROP_UINT32("vectors", _state, nvectors, 3) + +#endif /* HW_VIRTIO_GPU_PCI_H */
include/hw/virtio/virtio-gpu.h +13 -6
@@ -19,6 +19,7 @@#include "ui/console.h" #include "hw/virtio/virtio.h" #include "qemu/log.h" +#include "sysemu/vhost-user-backend.h" #include "standard-headers/linux/virtio_gpu.h"
@@ -34,6 +35,8 @@#define VIRTIO_GPU (obj) \ OBJECT_CHECK(VirtIOGPU, (obj), TYPE_VIRTIO_GPU) +#define TYPE_VHOST_USER_GPU "vhost-user-gpu" +#define VIRTIO_ID_GPU 16struct virtio_gpu_simple_resource {
@@ -157,13 +160,17 @@ typedef struct VirtIOGPU { } stats; } VirtIOGPU; -extern const GraphicHwOps virtio_gpu_ops; +typedef struct VhostUserGPU { +VirtIOGPUBase parent_obj; -/* to share between PCI and VGA */ -#define DEFINE_VIRTIO_GPU_PCI_PROPERTIES (_state) \ - DEFINE_PROP_BIT("ioeventfd", _state, flags, \ - VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false), \ - DEFINE_PROP_UINT32("vectors", _state, nvectors, 3) +VhostUserBackend *vhost; +int vhost_gpu_fd;/* closed by the chardev */ +CharBackend vhost_chr; +QemuDmaBuf dmabuf[VIRTIO_GPU_MAX_SCANOUTS ]; +bool backend_blocked; +}VhostUserGPU ; + +extern const GraphicHwOps virtio_gpu_ops;#define VIRTIO_GPU_FILL_CMD (out) do { \ size_t s; \
hw/display/vhost-user-gpu-pci.c new file +51 -0
51 lines not on this page · raw message
hw/display/vhost-user-gpu.c new file +572 -0
572 lines not on this page · raw message
hw/display/vhost-user-vga.c new file +52 -0
52 lines not on this page · raw message
hw/display/virtio-gpu-pci.c +1 -16
@@ -16,22 +16,7 @@#include "hw/pci/pci.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-bus.h" -#include "hw/virtio/virtio-pci.h" -#include "hw/virtio/virtio-gpu.h" - -typedef struct VirtIOGPUPCIBase VirtIOGPUPCIBase ; - -/* -* virtio-gpu-pci-base: This extends VirtioPCIProxy. -*/ -#define TYPE_VIRTIO_GPU_PCI_BASE "virtio-gpu-pci-base" -#define VIRTIO_GPU_PCI_BASE (obj) \ - OBJECT_CHECK(VirtIOGPUPCIBase, (obj), TYPE_VIRTIO_GPU_PCI_BASE) - -struct VirtIOGPUPCIBase { -VirtIOPCIProxy parent_obj; -VirtIOGPUBase *vgpu; -}; +#include "hw/virtio/virtio-gpu-pci.h" static Property virtio_gpu_pci_base_properties[] = {DEFINE_VIRTIO_GPU_PCI_PROPERTIES (VirtIOPCIProxy),
vl.c +1 -0
@@ -238,6 +238,7 @@ static struct { { .driver = "qxl-vga", .flag = &default_vga }, { .driver = "virtio-vga", .flag = &default_vga }, { .driver = "ati-vga", .flag = &default_vga }, + { .driver = "vhost-user-vga", .flag = &default_vga }, }; static QemuOptsList qemu_rtc_opts = {
hw/display/Kconfig +10 -0
@@ -104,6 +104,16 @@ config VIRTIO_VGA depends on VIRTIO_PCI select VGA +config VHOST_USER_GPU + bool + default y + depends on VIRTIO_GPU && VHOST_USER + +config VHOST_USER_VGA + bool + default y + depends on VIRTIO_VGA && VHOST_USER_GPU + config DPCD bool
hw/display/Makefile.objs +3 -0
@@ -43,8 +43,11 @@ obj-$(CONFIG_VGA) += vga.o common-obj-$(CONFIG_QXL) += qxl.o qxl-logger.o qxl-render.o obj-$(CONFIG_VIRTIO_GPU) += virtio-gpu-base.o virtio-gpu.o virtio-gpu-3d.o +obj-$(CONFIG_VHOST_USER_GPU) += vhost-user-gpu.o obj-$(call land,$(CONFIG_VIRTIO_GPU),$(CONFIG_VIRTIO_PCI)) += virtio-gpu-pci.o +obj-$(call land,$(CONFIG_VHOST_USER_GPU),$(CONFIG_VIRTIO_PCI)) += vhost-user-gpu-pci.o obj-$(CONFIG_VIRTIO_VGA) += virtio-vga.o +obj-$(CONFIG_VHOST_USER_VGA) += vhost-user-vga.o virtio-gpu.o-cflags := $(VIRGL_CFLAGS) virtio-gpu.o-libs += $(VIRGL_LIBS) virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
Signature · 1 line
2.21.0.313.ge35b8cb8e2
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: [Qemu-devel] [PATCH v6 00/11] vhost-user for input & GPU
=== 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 Switched to a new branch 'test'dae2bdda06 hw/display: add vhost-user-vga & gpu-pci 5085d87320 virtio-gpu: split virtio-gpu-pci & virtio-vga 4b0acd3384 virtio-gpu: split virtio-gpu, introduce virtio-gpu-base c1d833191f contrib: add vhost-user-gpucba97fa704 util: compile drm.o on Linuxb7f05f9505 virtio: add virtio-gpu bswap helpers header 567cb03399 vhost-user: add vhost_user_gpu_set_socket() e42b84bcb3 contrib: add vhost-user-input455270bf34 libvhost-user: add PROTOCOL_F_CONFIG if {set, get}_config 4cce0394b0 Add vhost-user-input-pci34a8518660 Add vhost-user-backend
=== OUTPUT BEGIN ===
1/11 Checking commit 34a851866041 (Add vhost-user-backend)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #44:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #143: FILE: backends/vhost-user.c:95:
+ /* guest_notifier_mask/pending not used yet, so just unmask
total: 0 errors, 2 warnings, 280 lines checked
Patch 1/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/11 Checking commit 4cce0394b02c (Add vhost-user-input-pci)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #58:
new file mode 100644
total: 0 errors, 1 warnings, 250 lines checked
Patch 2/11 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/11 Checking commit 455270bf3492 (libvhost-user: add PROTOCOL_F_CONFIG if {set, get}_config) 4/11 Checking commit e42b84bcb3fc (contrib: add vhost-user-input)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#69:
new file mode 100644
total: 0 errors, 1 warnings, 458 lines checked
Patch 4/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/11 Checking commit 567cb0339958 (vhost-user: add vhost_user_gpu_set_socket())
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #74:
new file mode 100644
total: 0 errors, 1 warnings, 313 lines checked
Patch 5/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/11 Checking commit b7f05f95058d (virtio: add virtio-gpu bswap helpers header)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #74:
new file mode 100644
total: 0 errors, 1 warnings, 116 lines checked
Patch 6/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
7/11 Checking commit cba97fa704c1 (util: compile drm.o on Linux) 8/11 Checking commit c1d833191f34 (contrib: add vhost-user-gpu)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #164:
new file mode 100644
total: 0 errors, 1 warnings, 2573 lines checked
Patch 8/11 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
9/11 Checking commit 4b0acd33848a (virtio-gpu: split virtio-gpu, introduce virtio-gpu-base)
WARNING: Block comments use a leading /* on a separate line
#100: FILE: hw/display/virtio-gpu-3d.c:181:
+ info.flags & 1 /* FIXME: Y_0_TOP */,
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #188:
new file mode 100644
ERROR: Macros with complex values should be enclosed in parenthesis #1253: FILE: include/hw/virtio/virtio-gpu.h:122:
+#define VIRTIO_GPU_BASE_PROPERTIES(_state, _conf) \
+ DEFINE_PROP_UINT32("max_outputs", _state, _conf.max_outputs, 1), \
+ DEFINE_PROP_BIT("edid", _state, _conf.flags, \
+ VIRTIO_GPU_FLAG_EDID_ENABLED, false), \
+ DEFINE_PROP_UINT32("xres", _state, _conf.xres, 1024), \
+ DEFINE_PROP_UINT32("yres", _state, _conf.yres, 768)
total: 1 errors, 2 warnings, 1184 lines checked
Patch 9/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
10/11 Checking commit 5085d87320e8 (virtio-gpu: split virtio-gpu-pci & virtio-vga)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #392:
new file mode 100644
total: 0 errors, 1 warnings, 390 lines checked
Patch 10/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/11 Checking commit dae2bdda06e1 (hw/display: add vhost-user-vga & gpu-pci)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #56:
new file mode 100644
ERROR: Macros with complex values should be enclosed in parenthesis #829: FILE: include/hw/virtio/virtio-gpu-pci.h:35:
+#define DEFINE_VIRTIO_GPU_PCI_PROPERTIES(_state) \
+ DEFINE_PROP_BIT("ioeventfd", _state, flags, \
+ VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false), \+ DEFINE_PROP_UINT32("vectors", _state, nvectors, 3)
total: 1 errors, 1 warnings, 818 lines checked
Patch 11/11 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]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===
CC qmp.o
CC hmp.o
CC cpus-common.o
/tmp/qemu-test/src/contrib/libvhost-user/libvhost-user.c:546:32: error: taking address of packed member 'payload' of class or structure 'VhostUserMsg' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
VhostUserMemory *memory = &vmsg->payload.memory;
^~~~~~~~~~~~~~~~~~~~
/tmp/qemu-test/src/contrib/libvhost-user/libvhost-user.c:688:32: error: taking address of packed member 'payload' of class or structure 'VhostUserMsg' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
VhostUserMemory *memory = &vmsg->payload.memory;
^~~~~~~~~~~~~~~~~~~~
/tmp/qemu-test/src/contrib/libvhost-user/libvhost-user.c:817:37: error: taking address of packed member 'payload' of class or structure 'VhostUserMsg' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
struct vhost_vring_addr *vra = &vmsg->payload.addr;
^~~~~~~~~~~~~~~~~~3 errors generated.
The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 9 lines · Marc-André Lureau
Hi,
vhost-user allows to drive a virtio device in a seperate process. After vhost-user-net, we have seen vhost-user-{scsi,blk,crypto} added more recently.
This series, initially proposed ~3 years ago, time flies
(https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg01905.html)
contributes with vhost-user-input and vhost-user-gpu.
Pls note asan errors reported by patchew.
Quoted 109 lines
You may start a vhost-user-gpu with virgl rendering in a separate process like this:
$ ./vhost-user-gpu --virgl -s vgpu.sock & $ qemu... -chardev socket,id=chr,path=vgpu.sock -device vhost-user-vga,chardev=chrv6:
- do not install vhost-user-input
- install vhost-user-gpu and json file following the spec
- fix the build when drm-intel-devel missing
- rebase (& resend without already applied patches)v5:
- remove user-creatable version of vhost-user-backend
- remove optinal management of sub-process in vhost-user-backend
- removed daemonize/pid code
- drop introduction of new input & gpu messages for PCI config space handling, instead useVHOST_USER_PROTOCOL_F_CONFIG
- plain mem & udmabuf fallback for 2d rendering
- rebased, kconfig-ify, rst-ifyMarc-André Lureau (11):
Add vhost-user-backend
Add vhost-user-input-pci
libvhost-user: addPROTOCOL_F_CONFIGif {set,get}_config
contrib: add vhost-user-input
vhost-user: addvhost_user_gpu_set_socket()
virtio: add virtio-gpu bswap helpers header
util: compile drm.o on Linux
contrib: add vhost-user-gpu
virtio-gpu: split virtio-gpu, introduce virtio-gpu-base
virtio-gpu: split virtio-gpu-pci & virtio-vga hw/display: add vhost-user-vga & gpu-pcicontrib/libvhost-user/libvhost-user.h | 1 + contrib/vhost-user-gpu/drm.h | 72 ++ contrib/vhost-user-gpu/virgl.h | 25 + contrib/vhost-user-gpu/vugpu.h | 170 +++ hw/display/virtio-vga.h | 32 + include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/virtio-gpu-bswap.h | 61 + include/hw/virtio/virtio-gpu-pci.h | 40 + include/hw/virtio/virtio-gpu.h | 92 +- include/hw/virtio/virtio-input.h | 14 + include/sysemu/vhost-user-backend.h | 57 + backends/vhost-user.c | 209 ++++ contrib/libvhost-user/libvhost-user.c | 5 + contrib/vhost-user-gpu/drm.c | 341 ++++++ contrib/vhost-user-gpu/main.c | 1236 ++++++++++++++++++++ contrib/vhost-user-gpu/virgl.c | 579 +++++++++ contrib/vhost-user-input/main.c | 427 +++++++ hw/display/vhost-user-gpu-pci.c | 51 + hw/display/vhost-user-gpu.c | 572 +++++++++ hw/display/vhost-user-vga.c | 52 + hw/display/virtio-gpu-3d.c | 49 +- hw/display/virtio-gpu-base.c | 268 +++++ hw/display/virtio-gpu-pci.c | 55 +- hw/display/virtio-gpu.c | 415 ++----- hw/display/virtio-vga.c | 138 +-- hw/input/vhost-user-input.c | 129 ++ hw/virtio/vhost-user-input-pci.c | 53 + hw/virtio/vhost-user.c | 11 + vl.c | 1 + MAINTAINERS | 14 +- Makefile | 27 +- Makefile.objs | 2 + backends/Makefile.objs | 2 + configure | 29 + contrib/vhost-user-gpu/50-qemu-gpu.json.in | 5 + contrib/vhost-user-gpu/Makefile.objs | 10 + contrib/vhost-user-input/Makefile.objs | 1 + docs/interop/index.rst | 2 +- docs/interop/vhost-user-gpu.rst | 238 ++++ docs/interop/vhost-user.txt | 9 + hw/display/Kconfig | 10 + hw/display/Makefile.objs | 5 +- hw/input/Kconfig | 5 + hw/input/Makefile.objs | 1 + hw/virtio/Makefile.objs | 1 + rules.mak | 9 +- util/Makefile.objs | 2 +- 47 files changed, 5070 insertions(+), 459 deletions(-) create mode 100644 contrib/vhost-user-gpu/drm.h create mode 100644 contrib/vhost-user-gpu/virgl.h create mode 100644 contrib/vhost-user-gpu/vugpu.h create mode 100644 hw/display/virtio-vga.h create mode 100644 include/hw/virtio/virtio-gpu-bswap.h create mode 100644 include/hw/virtio/virtio-gpu-pci.h create mode 100644 include/sysemu/vhost-user-backend.h create mode 100644 backends/vhost-user.c create mode 100644 contrib/vhost-user-gpu/drm.c create mode 100644 contrib/vhost-user-gpu/main.c create mode 100644 contrib/vhost-user-gpu/virgl.c create mode 100644 contrib/vhost-user-input/main.c create mode 100644 hw/display/vhost-user-gpu-pci.c create mode 100644 hw/display/vhost-user-gpu.c create mode 100644 hw/display/vhost-user-vga.c create mode 100644 hw/display/virtio-gpu-base.c create mode 100644 hw/input/vhost-user-input.c create mode 100644 hw/virtio/vhost-user-input-pci.c create mode 100644 contrib/vhost-user-gpu/50-qemu-gpu.json.in create mode 100644 contrib/vhost-user-gpu/Makefile.objs create mode 100644 contrib/vhost-user-input/Makefile.objs create mode 100644 docs/interop/vhost-user-gpu.rstSignature · 1 line
2.21.0.313.ge35b8cb8e2
Hi
Quoted 8 lines · Michael S. Tsirkin
Quoted 6 lines · Marc-André Lureau
Hi,
vhost-user allows to drive a virtio device in a seperate process. After vhost-user-net, we have seen vhost-user-{scsi,blk,crypto} added more recently.
Quoted 6 lines
Quoted 3 lines
This series, initially proposed ~3 years ago, time flies
(https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg01905.html)
contributes with vhost-user-input and vhost-user-gpu.Pls note asan errors reported by patchew.
Those are pre-existing, and I thought we had patches on the list for them, but I can't find them.
A quick fix could be:
(quoted diff) +0 -0
b/contrib/libvhost-user/libvhost-user.c
index c9823a1354..944d5c9c4f 100644
contrib/libvhost-user/libvhost-user.c +3 -3
@@ -543,7 +543,7 @@ static bool vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg *vmsg) {int i; -VhostUserMemory *memory = &vmsg->payload.memory; +VhostUserMemory m = vmsg->payload.memory, *memory = &m; dev->nregions = memory->nregions;DPRINT ("Nregions: %d\n" , memory->nregions);
@@ -685,7 +685,7 @@ static bool vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg) {int i; -VhostUserMemory *memory = &vmsg->payload.memory; +VhostUserMemory m = vmsg->payload.memory, *memory = &m;for (i =0 ; i < dev->nregions; i++) {VuDevRegion *r = &dev->regions[i];
@@ -814,7 +814,7 @@ vu_set_vring_num_exec(VuDev *dev, VhostUserMsg *vmsg)static bool vu_set_vring_addr_exec (VuDev *dev,VhostUserMsg *vmsg) { -struct vhost_vring_addr *vra = &vmsg->payload.addr; +struct vhost_vring_addr addr = vmsg->payload.addr, *vra = &addr;unsigned int index = vra->index;VuVirtq *vq = &dev->vq[index];
Quoted 112 lines
Quoted 111 lines
You may start a vhost-user-gpu with virgl rendering in a separate process like this:
$ ./vhost-user-gpu --virgl -s vgpu.sock & $ qemu... -chardev socket,id=chr,path=vgpu.sock -device vhost-user-vga,chardev=chrv6:
- do not install vhost-user-input
- install vhost-user-gpu and json file following the spec
- fix the build when drm-intel-devel missing
- rebase (& resend without already applied patches)v5:
- remove user-creatable version of vhost-user-backend
- remove optinal management of sub-process in vhost-user-backend
- removed daemonize/pid code
- drop introduction of new input & gpu messages for PCI config space handling, instead useVHOST_USER_PROTOCOL_F_CONFIG
- plain mem & udmabuf fallback for 2d rendering
- rebased, kconfig-ify, rst-ifyMarc-André Lureau (11):
Add vhost-user-backend
Add vhost-user-input-pci
libvhost-user: addPROTOCOL_F_CONFIGif {set,get}_config
contrib: add vhost-user-input
vhost-user: addvhost_user_gpu_set_socket()
virtio: add virtio-gpu bswap helpers header
util: compile drm.o on Linux
contrib: add vhost-user-gpu
virtio-gpu: split virtio-gpu, introduce virtio-gpu-base
virtio-gpu: split virtio-gpu-pci & virtio-vga hw/display: add vhost-user-vga & gpu-pcicontrib/libvhost-user/libvhost-user.h | 1 + contrib/vhost-user-gpu/drm.h | 72 ++ contrib/vhost-user-gpu/virgl.h | 25 + contrib/vhost-user-gpu/vugpu.h | 170 +++ hw/display/virtio-vga.h | 32 + include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/virtio-gpu-bswap.h | 61 + include/hw/virtio/virtio-gpu-pci.h | 40 + include/hw/virtio/virtio-gpu.h | 92 +- include/hw/virtio/virtio-input.h | 14 + include/sysemu/vhost-user-backend.h | 57 + backends/vhost-user.c | 209 ++++ contrib/libvhost-user/libvhost-user.c | 5 + contrib/vhost-user-gpu/drm.c | 341 ++++++ contrib/vhost-user-gpu/main.c | 1236 ++++++++++++++++++++ contrib/vhost-user-gpu/virgl.c | 579 +++++++++ contrib/vhost-user-input/main.c | 427 +++++++ hw/display/vhost-user-gpu-pci.c | 51 + hw/display/vhost-user-gpu.c | 572 +++++++++ hw/display/vhost-user-vga.c | 52 + hw/display/virtio-gpu-3d.c | 49 +- hw/display/virtio-gpu-base.c | 268 +++++ hw/display/virtio-gpu-pci.c | 55 +- hw/display/virtio-gpu.c | 415 ++----- hw/display/virtio-vga.c | 138 +-- hw/input/vhost-user-input.c | 129 ++ hw/virtio/vhost-user-input-pci.c | 53 + hw/virtio/vhost-user.c | 11 + vl.c | 1 + MAINTAINERS | 14 +- Makefile | 27 +- Makefile.objs | 2 + backends/Makefile.objs | 2 + configure | 29 + contrib/vhost-user-gpu/50-qemu-gpu.json.in | 5 + contrib/vhost-user-gpu/Makefile.objs | 10 + contrib/vhost-user-input/Makefile.objs | 1 + docs/interop/index.rst | 2 +- docs/interop/vhost-user-gpu.rst | 238 ++++ docs/interop/vhost-user.txt | 9 + hw/display/Kconfig | 10 + hw/display/Makefile.objs | 5 +- hw/input/Kconfig | 5 + hw/input/Makefile.objs | 1 + hw/virtio/Makefile.objs | 1 + rules.mak | 9 +- util/Makefile.objs | 2 +- 47 files changed, 5070 insertions(+), 459 deletions(-) create mode 100644 contrib/vhost-user-gpu/drm.h create mode 100644 contrib/vhost-user-gpu/virgl.h create mode 100644 contrib/vhost-user-gpu/vugpu.h create mode 100644 hw/display/virtio-vga.h create mode 100644 include/hw/virtio/virtio-gpu-bswap.h create mode 100644 include/hw/virtio/virtio-gpu-pci.h create mode 100644 include/sysemu/vhost-user-backend.h create mode 100644 backends/vhost-user.c create mode 100644 contrib/vhost-user-gpu/drm.c create mode 100644 contrib/vhost-user-gpu/main.c create mode 100644 contrib/vhost-user-gpu/virgl.c create mode 100644 contrib/vhost-user-input/main.c create mode 100644 hw/display/vhost-user-gpu-pci.c create mode 100644 hw/display/vhost-user-gpu.c create mode 100644 hw/display/vhost-user-vga.c create mode 100644 hw/display/virtio-gpu-base.c create mode 100644 hw/input/vhost-user-input.c create mode 100644 hw/virtio/vhost-user-input-pci.c create mode 100644 contrib/vhost-user-gpu/50-qemu-gpu.json.in create mode 100644 contrib/vhost-user-gpu/Makefile.objs create mode 100644 contrib/vhost-user-input/Makefile.objs create mode 100644 docs/interop/vhost-user-gpu.rst--
2.21.0.313.ge35b8cb8e2
Signature · 1 line
Marc-André Lureau