vhost-user for input & GPU
v5 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
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
Gerd Hoffmann (1):
curses: fix wchar_t printf warning
Greg Kurz (1):
spapr_pci: Fix broken naming of PCI bus
Marc-André Lureau (10):
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
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
Peter Maydell (1):
Update version for v4.0.0-rc3 release
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v5 1/13 Update version for v4.0.0-rc3 release
From: Peter Maydell <[email protected]>
--- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
VERSION +1 -1
@@ -1 +1 @@ -3.1.92 +3.1.93
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v5 2/13 spapr_pci: Fix broken naming of PCI bus
In reply to Marc-André LureauFrom: Greg Kurz <[email protected]>
Recent commit 5cf0d326a0fe fixed a regression which was preventing the guest to access the extended config space of a PCIe device. This was done by introducing a new PCI bus subtype for PAPR. The original fix was causing PCI busses to be named "spapr-pci-host-bridge-root-bus.N" instead of "pci.N", which was making upper layers unhappy of course. This got worked around by hardcoding the PCI bus name to "pci.0", but this only works for the default PHB. And we're now hitting:
# qemu-system-ppc64 \
-device spapr-pci-host-bridge,index=1 \
-device e1000e,bus=pci.0 \
-device e1000e,bus=pci.1
qemu-system-ppc64: -device e1000e,bus=pci.1: Bus 'pci.1' not foundDavid already posted some patches [1] to control PCI extended config space accesses with a new flag in the base PCI bus class instead of subtyping. These patches are a bit more intrusive though, and are targetted for 4.1.
When no name is passed to pci_register_bus(), the core device code generates a lowercase name based on the QOM typename. The typename for the base PCI bus class is "PCI", hence the "pci.0", "pci.1" bus names. Rename the type of the PAPR PCI bus to "pci", so that the QOM code can generate proper names. This is a hack but it is enough to fix the regression. And all this will be reworked properly in 4.1.
[1] https://patchwork.ozlabs.org/project/qemu-devel/list/?series=100486
Message-Id: <155500034416.646888.1307366522340665522.stgit@bahia.lab.toulouse-stg.fr.ibm.com>
--- hw/ppc/spapr_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ppc/spapr_pci.c +2 -2
@@ -1652,7 +1652,7 @@ static void spapr_phb_root_bus_class_init(ObjectClass *klass, void *data) pbc->allows_extended_config_space = spapr_phb_allows_extended_config_space; } -#define TYPE_SPAPR_PHB_ROOT_BUS "spapr-pci-host-bridge-root-bus" +#define TYPE_SPAPR_PHB_ROOT_BUS "pci"static const TypeInfo spapr_phb_root_bus_info = { .name =TYPE_SPAPR_PHB_ROOT_BUS ,
@@ -1761,7 +1761,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)memory_region_add_subregion (get_system_memory (), sphb->io_win_addr, &sphb->iowindow); - bus = pci_register_root_bus(dev, "pci.0", + bus = pci_register_root_bus(dev, NULL, pci_spapr_set_irq, pci_spapr_map_irq, sphb, &sphb->memspace, &sphb->iospace, PCI_DEVFN(0, 0), PCI_NUM_PINS,
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v5 3/13 curses: fix wchar_t printf warning
In reply to Marc-André LureauFrom: Gerd Hoffmann <[email protected]>
On some systems wchar_t is "long int", on others just "int". So go cast to "long int" and adjust the printf format accordingly.
Message-id: [email protected]
--- ui/curses.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ui/curses.c +2 -2
@@ -453,8 +453,8 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv) swch =sizeof (wch);if (iconv (conv, &pwch, &swch, &pch, &sch) == (size_t )-1 ) { -fprintf (stderr,"Could not convert 0x%02x from WCHAR_T to UCS-2: %s\n" , - wch,strerror (errno)); +fprintf (stderr,"Could not convert 0x%02lx from WCHAR_T to UCS-2: %s\n" , + (unsigned long )wch,strerror (errno));return 0xFFFD ; }
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v5 4/13 Add vhost-user-backend
In reply to Marc-André LureauCreate 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 v5 5/13 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
PATCH v5 6/13 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 v5 7/13 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
--- contrib/vhost-user-input/main.c | 427 +++++++++++++++++++++++++ MAINTAINERS | 1 + Makefile | 3 + Makefile.objs | 1 + configure | 3 + contrib/vhost-user-input/Makefile.objs | 1 + 6 files changed, 436 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 +3 -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 \
@@ -609,6 +610,8 @@ vhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a 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) $< $@ \
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 =
configure +3 -0
@@ -6044,6 +6044,9 @@ if test "$want_tools" = "yes" ; then if [ "$curl" = "yes" ]; then tools="elf2dmp\$(EXESUF) $tools" fi + if [ "$vhost_user" = "yes" ] && [ "$linux" = "yes" ] ; then + tools="vhost-user-input\$(EXESUF) $tools" + fi fi if test "$softmmu" = yes ; then if test "$linux" = yes; then
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
PATCH v5 8/13 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
PATCH v5 9/13 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 v5 10/13 contrib: add vhost-user-gpu
In reply to Marc-André LureauAdd a vhost-user gpu backend example, 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 | 1235 +++++++++++++++++++++++ contrib/vhost-user-gpu/virgl.c | 579 +++++++++++ MAINTAINERS | 2 + Makefile | 3 + Makefile.objs | 1 + configure | 32 + contrib/vhost-user-gpu/50-qemu-gpu.json | 5 + contrib/vhost-user-gpu/Makefile.objs | 10 + 12 files changed, 2475 insertions(+) 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 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 +1235 -0
1,235 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 +3 -0
@@ -403,6 +403,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 \
@@ -612,6 +613,8 @@ 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, $^) +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) $< $@ \
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 +32 -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
@@ -6047,6 +6061,9 @@ if test "$want_tools" = "yes" ; then if [ "$vhost_user" = "yes" ] && [ "$linux" = "yes" ] ; then tools="vhost-user-input\$(EXESUF) $tools" fi + if [ "$linux" = "yes" -a "$virglrenderer" = "yes" -a "$libdrm" = "yes" ] ; then + tools="vhost-user-gpu\$(EXESUF) $tools" + fi fi if test "$softmmu" = yes ; then if test "$linux" = yes; then
@@ -6942,6 +6959,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
@@ -7835,6 +7864,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 new file +5 -0
@@ -0,0 +1,5 @@ +{ + "description": "QEMU vhost-user-gpu", + "type": "gpu", + "binary": "/usr/libexec/qemu/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) +main.o-libs := $(PIXMAN_LIBS) + +virgl.o-cflags := $(VIRGL_CFLAGS) +virgl.o-libs := $(VIRGL_LIBS) + +drm.o-cflags := $(LIBDRM_CFLAGS) $(LIBDRM_INTEL_CFLAGS) +drm.o-libs := $(LIBDRM_LIBS) $(LIBDRM_INTEL_LIBS)
Signature · 1 line
2.21.0.313.ge35b8cb8e2
PATCH v5 11/13 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 v5 12/13 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 v5 13/13 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
Hi
Quoted 46 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.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=chrv5:
- 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-ifyGerd Hoffmann (1):
curses: fixwchar_tprintf warningGreg Kurz (1):
spapr_pci: Fix broken naming of PCI busMarc-André Lureau (10):
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
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
Quoted 3 lines
Peter Maydell (1):
Update version for v4.0.0-rc3 release
oops, some bonus patches :) my bad, please ignore
Signature · 1 line
Marc-André Lureau
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 ===
In file included from /tmp/qemu-test/src/contrib/vhost-user-gpu/virgl.c:16:
In file included from /tmp/qemu-test/src/contrib/vhost-user-gpu/virgl.h:17:
In file included from /tmp/qemu-test/src/contrib/vhost-user-gpu/vugpu.h:25:/tmp/qemu-test/src/contrib/vhost-user-gpu/drm.h:15:10: fatal error: 'i915_drm.h' file not found
#include <i915_drm.h>
^~~~~~~~~~~~ CC blockjob.o
---
make: *** Waiting for unfinished jobs....
In file included from /tmp/qemu-test/src/contrib/vhost-user-gpu/main.c:21:
In file included from /tmp/qemu-test/src/contrib/vhost-user-gpu/vugpu.h:25:/tmp/qemu-test/src/contrib/vhost-user-gpu/drm.h:15:10: fatal error: 'i915_drm.h' file not found
#include <i915_drm.h>
^~~~~~~~~~~~
/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]
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:
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v5 00/13] vhost-user for input & GPU
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
e1be98540e..13c24edaa7 master -> master * [new tag] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'd5cc322df5 hw/display: add vhost-user-vga & gpu-pci 3e48843814 virtio-gpu: split virtio-gpu-pci & virtio-vga 27de3a9c6e virtio-gpu: split virtio-gpu, introduce virtio-gpu-base 3d2340a207 contrib: add vhost-user-gpu9a14706dd9 virtio: add virtio-gpu bswap helpers header 03da2a93d1 vhost-user: add vhost_user_gpu_set_socket() e47966fdc8 contrib: add vhost-user-inputbeb467adc0 libvhost-user: add PROTOCOL_F_CONFIG if {set, get}_config 0cf7f81cf7 Add vhost-user-input-pci2ce13ff56b Add vhost-user-backend68dc09b28e qemu-img: fix .hx and .texi disparity
=== OUTPUT BEGIN ===
1/11 Checking commit 68dc09b28e31 (qemu-img: fix .hx and .texi disparity) 2/11 Checking commit 2ce13ff56b22 (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 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 0cf7f81cf724 (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 3/11 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
4/11 Checking commit beb467adc013 (libvhost-user: add PROTOCOL_F_CONFIG if {set, get}_config) 5/11 Checking commit e47966fdc89a (contrib: add vhost-user-input)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#79:
new file mode 100644
total: 0 errors, 1 warnings, 466 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 03da2a93d186 (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 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 9a14706dd99f (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 7/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
8/11 Checking commit 3d2340a20702 (contrib: add vhost-user-gpu)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #131:
new file mode 100644
total: 0 errors, 1 warnings, 2523 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 27de3a9c6ece (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 3e4884381437 (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 d5cc322df527 (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]