Skip to contentSkip to conversation

Input 20190513 v2 patches

GIT PULL Applied Gerd Hoffmann 2 participants 9 messages May 13, 2019

lore
Share & tools
lore
#1 lore raw

[Qemu-devel] [PULL 5/7] util: simplify unix_listen()

In reply to Gerd Hoffmann

From: Marc-André Lureau <[email protected]>

The only caller of unix_listen() left is qga/channel-posix.c.

There is no need to deal with legacy coma-trailing options ",...".

Message-id: [email protected]

---
 util/qemu-sockets.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)
util/qemu-sockets.c +2 -16
index ba6335e71a95..8850a280a84b 100644
@@ -970,26 +970,12 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp)
 /* compatibility wrapper */
 int unix_listen(const char *str, Error **errp)
 {
-    char *path, *optstr;
-    int sock, len;
     UnixSocketAddress *saddr;
+    int sock;
 
     saddr = g_new0(UnixSocketAddress, 1);
-
-    optstr = strchr(str, ',');
-    if (optstr) {
-        len = optstr - str;
-        if (len) {
-            path = g_malloc(len+1);
-            snprintf(path, len+1, "%.*s", len, str);
-            saddr->path = path;
-        }
-    } else {
-        saddr->path = g_strdup(str);
-    }
-
+    saddr->path = g_strdup(str);
     sock = unix_listen_saddr(saddr, errp);
-
     qapi_free_UnixSocketAddress(saddr);
     return sock;
 }
Signature · 1 line
2.18.1
#2 lore raw

[Qemu-devel] [PULL 3/7] Add vhost-user-backend

In reply to Gerd Hoffmann

From: Marc-André Lureau <[email protected]>

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.

Message-id: [email protected]

---
 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
new file mode 100644
index 000000000000..9abf8f06a1b9
@@ -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
index 66ddbda9c958..2e40390ebcdb 100644
@@ -1478,6 +1478,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
index ff619d31b461..981e8e122f2c 100644
@@ -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.18.1
#3 lore raw

[Qemu-devel] [PULL 4/7] Add vhost-user-input-pci

In reply to Gerd Hoffmann

From: Marc-André Lureau <[email protected]>

Add 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.

Message-id: [email protected]

[ kraxel: drop -{non-,}transitional variants ]
[ kraxel: fix "make check" on !linux ]

---
 include/hw/virtio/virtio-input.h |  14 ++++
 hw/input/vhost-user-input.c      | 129 +++++++++++++++++++++++++++++++
 hw/virtio/vhost-user-input-pci.c |  50 ++++++++++++
 MAINTAINERS                      |   1 +
 hw/input/Kconfig                 |   5 ++
 hw/input/Makefile.objs           |   1 +
 hw/virtio/Makefile.objs          |   1 +
 7 files changed, 201 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
index 054c38836f11..4fca03e7969e 100644
@@ -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 +50 -0

50 lines not on this page · raw message

MAINTAINERS +1 -0
index 2e40390ebcdb..6d4a10b3903f 100644
@@ -1521,6 +1521,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
index e2e66f085862..50e55e353847 100644
@@ -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
index c8b00f71ec50..3eddf00f2bba 100644
@@ -12,6 +12,7 @@ common-obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-hid.o
 ifeq ($(CONFIG_LINUX),y)
 common-obj-$(CONFIG_VIRTIO_INPUT) += virtio-input-host.o
 endif
+common-obj-$(CONFIG_VHOST_USER_INPUT) += vhost-user-input.o
 
 obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
 obj-$(CONFIG_PXA2XX) += pxa2xx_keypad.o
hw/virtio/Makefile.objs +1 -0
index f2ab667a2118..5570ea8df805 100644
@@ -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.18.1
#4 lore raw

[Qemu-devel] [PULL 6/7] virtio-input-host-pci: cleanup types

In reply to Gerd Hoffmann

virtio input is virtio-1.0 only, so we don't need the -transitional and -non-transitional variants.

Message-id: [email protected]

---
 hw/virtio/virtio-input-host-pci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/virtio/virtio-input-host-pci.c +2 -5
index 725a51ad30b4..124c4f344742 100644
@@ -13,7 +13,7 @@
 
 typedef struct VirtIOInputHostPCI VirtIOInputHostPCI;
 
-#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci-base"
+#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci"
 #define VIRTIO_INPUT_HOST_PCI(obj) \
         OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI)
 
@@ -31,10 +31,7 @@ static void virtio_host_initfn(Object *obj)
 }
 
 static const VirtioPCIDeviceTypeInfo virtio_input_host_pci_info = {
-    .base_name             = TYPE_VIRTIO_INPUT_HOST_PCI,
-    .generic_name          = "virtio-input-host-pci",
-    .transitional_name     = "virtio-input-host-pci-transitional",
-    .non_transitional_name = "virtio-input-host-pci-non-transitional",
+    .generic_name  = TYPE_VIRTIO_INPUT_HOST_PCI,
     .parent        = TYPE_VIRTIO_INPUT_PCI,
     .instance_size = sizeof(VirtIOInputHostPCI),
     .instance_init = virtio_host_initfn,
Signature · 1 line
2.18.1
#5 lore raw

[Qemu-devel] [PULL 1/7] libvhost-user: fix -Waddress-of-packed-member

In reply to Gerd Hoffmann

From: Marc-André Lureau <[email protected]>

/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c: In function ‘vu_set_mem_table_exec_postcopy’:
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c:546:31: warning: taking address of packed member of ‘struct VhostUserMsg’ may result in an unaligned pointer value [-Waddress-of-packed-member]

  546 |     VhostUserMemory *memory = &vmsg->payload.memory;
      |                               ^~~~~~~~~~~~~~~~~~~~~
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c: In function ‘vu_set_mem_table_exec’:
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c:688:31: warning: taking address of packed member of ‘struct VhostUserMsg’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  688 |     VhostUserMemory *memory = &vmsg->payload.memory;
      |                               ^~~~~~~~~~~~~~~~~~~~~
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c: In function ‘vu_set_vring_addr_exec’:
/home/elmarco/src/qemu/contrib/libvhost-user/libvhost-user.c:817:36: warning: taking address of packed member of ‘struct VhostUserMsg’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  817 |     struct vhost_vring_addr *vra = &vmsg->payload.addr;
      |                                    ^~~~~~~~~~~~~~~~~~~

Message-id: [email protected]

---
 contrib/libvhost-user/libvhost-user.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
contrib/libvhost-user/libvhost-user.c +3 -3
index e08d6c7b9741..dcf4a969f238 100644
@@ -542,7 +542,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);
@@ -684,7 +684,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];
@@ -813,7 +813,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];
 
Signature · 1 line
2.18.1
#6 lore raw

[Qemu-devel] [PULL 2/7] libvhost-user: add PROTOCOL_F_CONFIG if {set, get}_config

In reply to Gerd Hoffmann

From: Marc-André Lureau <[email protected]>

Add the config protocol feature bit if the set_config & get_config callbacks are implemented.

Message-id: [email protected]

---
 contrib/libvhost-user/libvhost-user.c | 4 ++++
 1 file changed, 4 insertions(+)
contrib/libvhost-user/libvhost-user.c +4 -0
index dcf4a969f238..74d42177c5c8 100644
@@ -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.18.1
#0 lore raw

The following changes since commit 812b835fb4d23dd108b2f9802158472d50b73579:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-05-07' into staging (2019-05-09 16:31:12 +0100)

are available in the Git repository at:

git://git.kraxel.org/qemu tags/input-20190513-v2-pull-request

for you to fetch changes up to 503591cb6c28c3ddbe38ea50cab2f0dd3d6cd929:

virtio-input: fix Kconfig dependency and Makefile (2019-05-13 08:49:30 +0200)

----------------------------------------------------------------
input: add vhost-user-input, virtio-input fixes.

----------------------------------------------------------------

Gerd Hoffmann (2):
virtio-input-host-pci: cleanup types
virtio-input: fix Kconfig dependency and Makefile

Marc-André Lureau (5):
libvhost-user: fix -Waddress-of-packed-member
libvhost-user: add PROTOCOL_F_CONFIG if {set, get}_config Add vhost-user-backend
Add vhost-user-input-pci
util: simplify unix_listen()

 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 |  10 +-
 hw/input/vhost-user-input.c           | 129 ++++++++++++++++
 hw/virtio/vhost-user-input-pci.c      |  50 ++++++
 hw/virtio/virtio-input-host-pci.c     |   7 +-
 util/qemu-sockets.c                   |  18 +--
 MAINTAINERS                           |   3 +
 backends/Makefile.objs                |   2 +
 hw/input/Kconfig                      |   7 +-
 hw/input/Makefile.objs                |   5 +-
 hw/virtio/Makefile.objs               |   1 +
 13 files changed, 484 insertions(+), 28 deletions(-)
 create mode 100644 include/sysemu/vhost-user-backend.h
 create mode 100644 backends/vhost-user.c
 create mode 100644 hw/input/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-input-pci.c
Signature · 1 line
2.18.1
#7 lore raw

[Qemu-devel] [PULL 7/7] virtio-input: fix Kconfig dependency and Makefile

Make VIRTIO_INPUT_HOST depend on VIRTIO_INPUT.
Use CONFIG_VIRTIO_INPUT_HOST in Makefile.

Message-id: [email protected]

---
 hw/input/Kconfig       | 2 +-
 hw/input/Makefile.objs | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
hw/input/Kconfig +1 -1
index 50e55e353847..889363d8aef1 100644
@@ -27,7 +27,7 @@ config VIRTIO_INPUT
 config VIRTIO_INPUT_HOST
     bool
     default y
-    depends on VIRTIO && LINUX
+    depends on VIRTIO_INPUT && LINUX
 
 config VHOST_USER_INPUT
     bool
hw/input/Makefile.objs +1 -3
index 3eddf00f2bba..d1de30770854 100644
@@ -9,9 +9,7 @@ common-obj-$(CONFIG_TSC2005) += tsc2005.o
 
 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
-endif
+common-obj-$(CONFIG_VIRTIO_INPUT_HOST) += virtio-input-host.o
 common-obj-$(CONFIG_VHOST_USER_INPUT) += vhost-user-input.o
 
 obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
Signature · 1 line
2.18.1
#8 lore raw
In reply to Gerd Hoffmann
Quoted 9 lines · Gerd Hoffmann

The following changes since commit 812b835fb4d23dd108b2f9802158472d50b73579:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-05-07' into staging (2019-05-09 16:31:12 +0100)

are available in the Git repository at:

git://git.kraxel.org/qemu tags/input-20190513-v2-pull-request

Quoted 8 lines

for you to fetch changes up to 503591cb6c28c3ddbe38ea50cab2f0dd3d6cd929:

virtio-input: fix Kconfig dependency and Makefile (2019-05-13 08:49:30 +0200)

----------------------------------------------------------------
input: add vhost-user-input, virtio-input fixes.

----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM