Skip to contentSkip to conversation

virtio: cleanup vhost-user-generic and reduce c&p + vhost-user-input

PATCH In review Alex Bennée 3 participants 16 messages Jan 4, 2024 – Jan 10, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v9 cover virtio: cleanup vhost-user-generic and reduce c&p + vhost-user-input

A lot of our vhost-user stubs are large chunks of boilerplate that do (mostly) the same thing. This series continues the cleanups by splitting the vhost-user-base and vhost-user-generic implementations. After adding a new vq_size property the rng, gpio and i2c vhost-user devices become simple specialisations of the common base defining the ID, number of queues and potentially the config handling.

I've also added Manos' vhost-user-sound and Leo's vhost-user-input stubs which are based on the same base.

Changes
-------

v9
- re-base and fix conflicts
- add Leo's vhost-user-input series

v8
- scrubbed errant Message-Id

v7
- various review comments
- move to async teardown (fixes CI failure)

v6
- re-base to current master
- make vhost-user-device abstract
- mention abstractness in docs

v5
- addressing comments and tags
- improved the docs

v4
- dropped the F_TRANSPORT work for another series
- added vhost-user-sound

Alex Bennée (6):
virtio: split into vhost-user-base and vhost-user-device hw/virtio: convert vhost-user-base to async shutdown hw/virtio: derive vhost-user-rng from vhost-user-base hw/virtio: derive vhost-user-gpio from vhost-user-base hw/virtio: derive vhost-user-i2c from vhost-user-base docs/system: add a basic enumeration of vhost-user devices

Leo Yan (4):
hw/virtio: Support set_config() callback in vhost-user-base docs/system: Add vhost-user-input documentation hw/virtio: Move vhost-user-input into virtio folder hw/virtio: derive vhost-user-input from vhost-user-base

Manos Pitsidianakis (1):
hw/virtio: add vhost-user-snd and virtio-snd-pci devices

 MAINTAINERS                                   |  16 +-
 docs/system/device-emulation.rst              |   1 +
 docs/system/devices/vhost-user-input.rst      |  45 ++
 docs/system/devices/vhost-user-rng.rst        |   2 +
 docs/system/devices/vhost-user.rst            |  72 +++-
 ...{vhost-user-device.h => vhost-user-base.h} |  21 +-
 include/hw/virtio/vhost-user-gpio.h           |  25 +-
 include/hw/virtio/vhost-user-i2c.h            |  14 +-
 include/hw/virtio/vhost-user-rng.h            |  13 +-
 include/hw/virtio/vhost-user-snd.h            |  24 ++
 include/hw/virtio/virtio-input.h              |   6 +-
 hw/input/vhost-user-input.c                   | 136 ------
 hw/virtio/vhost-user-base.c                   | 371 ++++++++++++++++
 hw/virtio/vhost-user-device-pci.c             |  13 +-
 hw/virtio/vhost-user-device.c                 | 338 +--------------
 hw/virtio/vhost-user-gpio.c                   | 407 +-----------------
 hw/virtio/vhost-user-i2c.c                    | 272 +-----------
 hw/virtio/vhost-user-input-pci.c              |   3 -
 hw/virtio/vhost-user-input.c                  |  58 +++
 hw/virtio/vhost-user-rng.c                    | 294 +------------
 hw/virtio/vhost-user-snd-pci.c                |  75 ++++
 hw/virtio/vhost-user-snd.c                    |  67 +++
 hw/input/meson.build                          |   1 -
 hw/virtio/Kconfig                             |   5 +
 hw/virtio/meson.build                         |  27 +-
 25 files changed, 850 insertions(+), 1456 deletions(-)
 create mode 100644 docs/system/devices/vhost-user-input.rst
 rename include/hw/virtio/{vhost-user-device.h => vhost-user-base.h} (71%)
 create mode 100644 include/hw/virtio/vhost-user-snd.h
 delete mode 100644 hw/input/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-base.c
 create mode 100644 hw/virtio/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-snd-pci.c
 create mode 100644 hw/virtio/vhost-user-snd.c
Signature · 1 line
2.39.2
#1 lore raw

PATCH v9 1/11 virtio: split into vhost-user-base and vhost-user-device

Lets keep a cleaner split between the base class and the derived vhost-user-device which we can use for generic vhost-user stubs. This includes an update to introduce the vq_size property so the number of entries in a virtq can be defined.

---
v5
- s/parent/parent_obj/
- remove left over vhost-user-device.h
- use DEFINE_TYPES
v6
- rebase and set .abstract = true for vhost-user-device
v7
- checkpatch line length + MAINTAINERS
- s/abstract = true/dc->user_creatable = false/ for both mmio and pci

---
 MAINTAINERS                                   |   6 +
 ...{vhost-user-device.h => vhost-user-base.h} |  21 +-
 hw/virtio/vhost-user-base.c                   | 346 ++++++++++++++++++
 hw/virtio/vhost-user-device-pci.c             |  13 +-
 hw/virtio/vhost-user-device.c                 | 338 +----------------
 hw/virtio/meson.build                         |   1 +
 6 files changed, 383 insertions(+), 342 deletions(-)
 rename include/hw/virtio/{vhost-user-device.h => vhost-user-base.h} (71%)
 create mode 100644 hw/virtio/vhost-user-base.c
MAINTAINERS +6 -0
index 395f26ba861..0e832fd5d13 100644
@@ -2304,6 +2304,12 @@ F: include/sysemu/rng*.h
 F: backends/rng*.c
 F: tests/qtest/virtio-rng-test.c
 
+vhost-user-stubs
+M: Alex Bennée <[email protected]>
+S: Maintained
+F: hw/virtio/vhost-user-base.c
+F: hw/virtio/vhost-user-device*
+
 vhost-user-rng
 M: Mathieu Poirier <[email protected]>
 S: Supported
include/hw/virtio/vhost-user-base.h renamed from include/hw/virtio/vhost-user-device.h +12 -9
similarity index 71%
rename from include/hw/virtio/vhost-user-device.h
rename to include/hw/virtio/vhost-user-base.h
index 3ddf88a146a..51d0968b893 100644
@@ -6,8 +6,8 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
-#ifndef QEMU_VHOST_USER_DEVICE_H
-#define QEMU_VHOST_USER_DEVICE_H
+#ifndef QEMU_VHOST_USER_BASE_H
+#define QEMU_VHOST_USER_BASE_H
 
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/vhost-user.h"
@@ -17,11 +17,13 @@
 OBJECT_DECLARE_TYPE(VHostUserBase, VHostUserBaseClass, VHOST_USER_BASE)
 
 struct VHostUserBase {
-    VirtIODevice parent;
+    VirtIODevice parent_obj;
+
     /* Properties */
     CharBackend chardev;
     uint16_t virtio_id;
     uint32_t num_vqs;
+    uint32_t vq_size; /* can't exceed VIRTIO_QUEUE_MAX */
     uint32_t config_size;
     /* State tracking */
     VhostUserState vhost_user;
@@ -31,16 +33,17 @@ struct VHostUserBase {
     bool connected;
 };
 
-    /* needed so we can use the base realize after specialisation
-       tweaks */
+/*
+ * Needed so we can use the base realize after specialisation
+ * tweaks
+ */
 struct VHostUserBaseClass {
-    /*< private >*/
     VirtioDeviceClass parent_class;
-    /*< public >*/
+
     DeviceRealize parent_realize;
 };
 
-/* shared for the benefit of the derived pci class */
+
 #define TYPE_VHOST_USER_DEVICE "vhost-user-device"
 
-#endif /* QEMU_VHOST_USER_DEVICE_H */
+#endif /* QEMU_VHOST_USER_BASE_H */
hw/virtio/vhost-user-base.c new file +346 -0

346 lines not on this page · raw message

hw/virtio/vhost-user-device-pci.c +7 -6
index 41f9b7905b4..efaf55d3dd4 100644
@@ -9,21 +9,18 @@
 
 #include "qemu/osdep.h"
 #include "hw/qdev-properties.h"
-#include "hw/virtio/vhost-user-device.h"
+#include "hw/virtio/vhost-user-base.h"
 #include "hw/virtio/virtio-pci.h"
 
 struct VHostUserDevicePCI {
     VirtIOPCIProxy parent_obj;
+
     VHostUserBase vub;
 };
 
-typedef struct VHostUserDevicePCI VHostUserDevicePCI;
-
 #define TYPE_VHOST_USER_DEVICE_PCI "vhost-user-device-pci-base"
 
-DECLARE_INSTANCE_CHECKER(VHostUserDevicePCI,
-                         VHOST_USER_DEVICE_PCI,
-                         TYPE_VHOST_USER_DEVICE_PCI)
+OBJECT_DECLARE_SIMPLE_TYPE(VHostUserDevicePCI, VHOST_USER_DEVICE_PCI)
 
 static void vhost_user_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
 {
@@ -39,6 +36,10 @@ static void vhost_user_device_pci_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
     PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+
+    /* Reason: stop users confusing themselves */
+    dc->user_creatable = false;
+
     k->realize = vhost_user_device_pci_realize;
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
     pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
hw/virtio/vhost-user-device.c +11 -327

373 lines not on this page · raw message

hw/virtio/meson.build +1 -0
index c0055a78326..51c3f97c2d0 100644
@@ -17,6 +17,7 @@ if have_vhost
   if have_vhost_user
     # fixme - this really should be generic
     specific_virtio_ss.add(files('vhost-user.c'))
+    system_virtio_ss.add(files('vhost-user-base.c'))
     system_virtio_ss.add(files('vhost-user-device.c'))
     system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c'))
   endif
Signature · 1 line
2.39.2
#2 lore raw

Re: [PATCH v9 01/11] virtio: split into vhost-user-base and vhost-user-device

Quoted 30 lines · Alex Bennée

Lets keep a cleaner split between the base class and the derived vhost-user-device which we can use for generic vhost-user stubs. This includes an update to introduce the vq_size property so the number of entries in a virtq can be defined.

---
v5
- s/parent/parent_obj/
- remove left over vhost-user-device.h
- use DEFINE_TYPES
v6
- rebase and set .abstract = true for vhost-user-device
v7
- checkpatch line length + MAINTAINERS
- s/abstract = true/dc->user_creatable = false/ for both mmio and pci

---
  MAINTAINERS                                   |   6 +
  ...{vhost-user-device.h => vhost-user-base.h} |  21 +-
  hw/virtio/vhost-user-base.c                   | 346 ++++++++++++++++++
  hw/virtio/vhost-user-device-pci.c             |  13 +-
  hw/virtio/vhost-user-device.c                 | 338 +----------------
  hw/virtio/meson.build                         |   1 +
  6 files changed, 383 insertions(+), 342 deletions(-)

rename include/hw/virtio/{vhost-user-device.h => vhost-user-base.h} (71%) create mode 100644 hw/virtio/vhost-user-base.c

hw/virtio/vhost-user-device.c static void vud_class_init(ObjectClass *klass, void *data) · line 46

Quoted 5 lines
hw/virtio/vhost-user-device.c +2 -0
@@ -358,6 +42,9 @@ static void vud_class_init(ObjectClass *klass, void *data)
  {
      DeviceClass *dc = DEVICE_CLASS(klass);
 
+    /* Reason: stop inexperienced users confusing themselves */
+    dc->user_creatable = false;

What about making VHOST_USER_DEVICE_PCI and TYPE_VHOST_USER_DEVICE TypeInfos abstract instead?

Quoted 12 lines
hw/virtio/vhost-user-device.c +1 -2
+
      device_class_set_props(dc, vud_properties);
      dc->vmsd = &vud_vmstate;
      set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
@@ -366,14 +53,11 @@ static void vud_class_init(ObjectClass *klass, void *data)
  static const TypeInfo vud_info = {
      .name = TYPE_VHOST_USER_DEVICE,
      .parent = TYPE_VHOST_USER_BASE,
-    .instance_size = sizeof(VHostUserBase),
      .class_init = vud_class_init,
-    .class_size = sizeof(VHostUserBaseClass),
  };
#3 lore raw

Re: [PATCH v9 01/11] virtio: split into vhost-user-base and vhost-user-device

Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 25 lines · Alex Bennée

Lets keep a cleaner split between the base class and the derived vhost-user-device which we can use for generic vhost-user stubs. This includes an update to introduce the vq_size property so the number of entries in a virtq can be defined.

---
v5
- s/parent/parent_obj/
- remove left over vhost-user-device.h
- use DEFINE_TYPES
v6
- rebase and set .abstract = true for vhost-user-device
v7
- checkpatch line length + MAINTAINERS
- s/abstract = true/dc->user_creatable = false/ for both mmio and pci

---
  MAINTAINERS                                   |   6 +
  ...{vhost-user-device.h => vhost-user-base.h} |  21 +-
  hw/virtio/vhost-user-base.c                   | 346 ++++++++++++++++++
  hw/virtio/vhost-user-device-pci.c             |  13 +-
  hw/virtio/vhost-user-device.c                 | 338 +----------------
  hw/virtio/meson.build                         |   1 +
  6 files changed, 383 insertions(+), 342 deletions(-)

rename include/hw/virtio/{vhost-user-device.h => vhost-user-base.h} (71%) create mode 100644 hw/virtio/vhost-user-base.c

Quoted 9 lines

hw/virtio/vhost-user-device.c static void vud_class_init(ObjectClass *klass, void *data) · line 45

Quoted 5 lines
hw/virtio/vhost-user-device.c +1 -0
@@ -358,6 +42,9 @@ static void vud_class_init(ObjectClass *klass, void *data)
  {
      DeviceClass *dc = DEVICE_CLASS(klass);
  +    /* Reason: stop inexperienced users confusing themselves */
+    dc->user_creatable = false;

What about making VHOST_USER_DEVICE_PCI and TYPE_VHOST_USER_DEVICE TypeInfos abstract instead?

I had in a previous iteration (v7) but AIUI abstract really means something different - the device can be instantiated but we just want to stop the user from creating it arbitrarily.

Quoted 13 lines
Quoted 13 lines
hw/virtio/vhost-user-device.c +1 -2
+
      device_class_set_props(dc, vud_properties);
      dc->vmsd = &vud_vmstate;
      set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
@@ -366,14 +53,11 @@ static void vud_class_init(ObjectClass *klass, void *data)
  static const TypeInfo vud_info = {
      .name = TYPE_VHOST_USER_DEVICE,
      .parent = TYPE_VHOST_USER_BASE,
-    .instance_size = sizeof(VHostUserBase),
      .class_init = vud_class_init,
-    .class_size = sizeof(VHostUserBaseClass),
  };
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#4 lore raw

PATCH v9 2/11 hw/virtio: convert vhost-user-base to async shutdown

In reply to Alex Bennée

We are about to convert at least one stubs which was using the async teardown so lets use it for all the cases.

---
 hw/virtio/vhost-user-base.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
hw/virtio/vhost-user-base.c +12 -4
index 620fa5cb4a4..78cfa9a5bbc 100644
@@ -201,6 +201,8 @@ static int vub_connect(DeviceState *dev)
     return 0;
 }
 
+static void vub_event(void *opaque, QEMUChrEvent event);
+
 static void vub_disconnect(DeviceState *dev)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
@@ -211,9 +213,13 @@ static void vub_disconnect(DeviceState *dev)
     }
     vub->connected = false;
 
-    if (vhost_dev_is_started(&vub->vhost_dev)) {
-        vub_stop(vdev);
-    }
+    vub_stop(vdev);
+    vhost_dev_cleanup(&vub->vhost_dev);
+
+    /* Re-instate the event handler for new connections */
+    qemu_chr_fe_set_handlers(&vub->chardev,
+                             NULL, NULL, vub_event,
+                             NULL, dev, NULL, true);
 }
 
 static void vub_event(void *opaque, QEMUChrEvent event)
@@ -230,7 +236,9 @@ static void vub_event(void *opaque, QEMUChrEvent event)
         }
         break;
     case CHR_EVENT_CLOSED:
-        vub_disconnect(dev);
+        /* defer close until later to avoid circular close */
+        vhost_user_async_close(dev, &vub->chardev, &vub->vhost_dev,
+                               vub_disconnect, vub_event);
         break;
     case CHR_EVENT_BREAK:
     case CHR_EVENT_MUX_IN:
Signature · 1 line
2.39.2
#5 lore raw

PATCH v9 3/11 hw/virtio: derive vhost-user-rng from vhost-user-base

In reply to Alex Bennée

Now we can take advantage of our new base class and make vhost-user-rng a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once.

---
v5
- don't remove the in-QEMU RNG emulation!
v7
- s/parent/parent_obj/
v8
- fix merge conflict (idx == VIRTIO_CONFIG_IRQ_IDX not needed as base doesn't use notifiers)

---
 include/hw/virtio/vhost-user-rng.h |  13 +-
 hw/virtio/vhost-user-rng.c         | 294 +++--------------------------
 hw/virtio/meson.build              |   9 +-
 3 files changed, 31 insertions(+), 285 deletions(-)
include/hw/virtio/vhost-user-rng.h +2 -11
index ddd9f01eea6..10868c7de4d 100644
@@ -12,22 +12,13 @@
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/vhost-user.h"
-#include "chardev/char-fe.h"
+#include "hw/virtio/vhost-user-base.h"
 
 #define TYPE_VHOST_USER_RNG "vhost-user-rng"
 OBJECT_DECLARE_SIMPLE_TYPE(VHostUserRNG, VHOST_USER_RNG)
 
 struct VHostUserRNG {
-    /*< private >*/
-    VirtIODevice parent;
-    CharBackend chardev;
-    struct vhost_virtqueue *vhost_vq;
-    struct vhost_dev vhost_dev;
-    VhostUserState vhost_user;
-    VirtQueue *req_vq;
-    bool connected;
-
-    /*< public >*/
+    VHostUserBase parent_obj;
 };
 
 #endif /* QEMU_VHOST_USER_RNG_H */
hw/virtio/vhost-user-rng.c +22 -272

326 lines not on this page · raw message

hw/virtio/meson.build +7 -2
index 51c3f97c2d0..b5c1a461e34 100644
@@ -18,8 +18,15 @@ if have_vhost
     # fixme - this really should be generic
     specific_virtio_ss.add(files('vhost-user.c'))
     system_virtio_ss.add(files('vhost-user-base.c'))
+
+    # MMIO Stubs
     system_virtio_ss.add(files('vhost-user-device.c'))
+    system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
+
+    # PCI Stubs
     system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c'))
+    system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'],
+                         if_true: files('vhost-user-rng-pci.c'))
   endif
   if have_vhost_vdpa
     system_virtio_ss.add(files('vhost-vdpa.c'))
@@ -37,7 +44,6 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-us
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c'))
@@ -49,7 +55,6 @@ virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vs
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input-pci.c'))
-virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c'))
Signature · 1 line
2.39.2
#6 lore raw

PATCH v9 4/11 hw/virtio: derive vhost-user-gpio from vhost-user-base

In reply to Alex Bennée

Now the new base class supports config handling we can take advantage and make vhost-user-gpio a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once.

---
v7
- s/parent/parent_obj/
v8
- fix merge conflicts

---
 include/hw/virtio/vhost-user-gpio.h |  25 +-
 hw/virtio/vhost-user-gpio.c         | 407 ++--------------------------
 hw/virtio/meson.build               |   5 +-
 3 files changed, 22 insertions(+), 415 deletions(-)
include/hw/virtio/vhost-user-gpio.h +2 -23
index a9d3f9b049f..5814a8400a0 100644
@@ -12,34 +12,13 @@
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/vhost-user.h"
-#include "standard-headers/linux/virtio_gpio.h"
-#include "chardev/char-fe.h"
+#include "hw/virtio/vhost-user-base.h"
 
 #define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device"
 OBJECT_DECLARE_SIMPLE_TYPE(VHostUserGPIO, VHOST_USER_GPIO);
 
 struct VHostUserGPIO {
-    /*< private >*/
-    VirtIODevice parent_obj;
-    CharBackend chardev;
-    struct virtio_gpio_config config;
-    struct vhost_virtqueue *vhost_vqs;
-    struct vhost_dev vhost_dev;
-    VhostUserState vhost_user;
-    VirtQueue *command_vq;
-    VirtQueue *interrupt_vq;
-    /**
-     * There are at least two steps of initialization of the
-     * vhost-user device. The first is a "connect" step and
-     * second is a "start" step. Make a separation between
-     * those initialization phases by using two fields.
-     *
-     * @connected: see vu_gpio_connect()/vu_gpio_disconnect()
-     * @started_vu: see vu_gpio_start()/vu_gpio_stop()
-     */
-    bool connected;
-    bool started_vu;
-    /*< public >*/
+    VHostUserBase parent_obj;
 };
 
 #endif /* _QEMU_VHOST_USER_GPIO_H */
hw/virtio/vhost-user-gpio.c +17 -390

436 lines not on this page · raw message

hw/virtio/meson.build +3 -2
index b5c1a461e34..87042e59017 100644
@@ -21,10 +21,13 @@ if have_vhost
 
     # MMIO Stubs
     system_virtio_ss.add(files('vhost-user-device.c'))
+    system_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
 
     # PCI Stubs
     system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c'))
+    system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'],
+                         if_true: files('vhost-user-gpio-pci.c'))
     system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'],
                          if_true: files('vhost-user-rng-pci.c'))
   endif
@@ -44,8 +47,6 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-us
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
-specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.c'))
 
Signature · 1 line
2.39.2
#7 lore raw

PATCH v9 5/11 hw/virtio: derive vhost-user-i2c from vhost-user-base

In reply to Alex Bennée

Now we can take advantage of the new base class and make vhost-user-i2c a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once.

---
v7
- s/parent/parent_obj/

---
 include/hw/virtio/vhost-user-i2c.h |  14 +-
 hw/virtio/vhost-user-i2c.c         | 272 ++---------------------------
 hw/virtio/meson.build              |   5 +-
 3 files changed, 23 insertions(+), 268 deletions(-)
include/hw/virtio/vhost-user-i2c.h +4 -10
index 0f7acd40e3a..a9b5612ad01 100644
@@ -9,23 +9,17 @@
 #ifndef QEMU_VHOST_USER_I2C_H
 #define QEMU_VHOST_USER_I2C_H
 
+#include "hw/virtio/virtio.h"
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/vhost-user.h"
+#include "hw/virtio/vhost-user-base.h"
 
 #define TYPE_VHOST_USER_I2C "vhost-user-i2c-device"
+
 OBJECT_DECLARE_SIMPLE_TYPE(VHostUserI2C, VHOST_USER_I2C)
 
 struct VHostUserI2C {
-    VirtIODevice parent;
-    CharBackend chardev;
-    struct vhost_virtqueue *vhost_vq;
-    struct vhost_dev vhost_dev;
-    VhostUserState vhost_user;
-    VirtQueue *vq;
-    bool connected;
+    VHostUserBase parent_obj;
 };
 
-/* Virtio Feature bits */
-#define VIRTIO_I2C_F_ZERO_LENGTH_REQUEST		0
-
 #endif /* QEMU_VHOST_USER_I2C_H */
hw/virtio/vhost-user-i2c.c +16 -256

299 lines not on this page · raw message

hw/virtio/meson.build +3 -2
index 87042e59017..0a4d29ace64 100644
@@ -22,12 +22,15 @@ if have_vhost
     # MMIO Stubs
     system_virtio_ss.add(files('vhost-user-device.c'))
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
+    system_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c'))
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
 
     # PCI Stubs
     system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c'))
     system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'],
                          if_true: files('vhost-user-gpio-pci.c'))
+    system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_I2C'],
+                         if_true: files('vhost-user-i2c-pci.c'))
     system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'],
                          if_true: files('vhost-user-rng-pci.c'))
   endif
@@ -46,7 +49,6 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.c'))
 
@@ -54,7 +56,6 @@ virtio_pci_ss = ss.source_set()
 virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk-pci.c'))
-virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c'))
Signature · 1 line
2.39.2
#8 lore raw

PATCH v9 6/11 hw/virtio: add vhost-user-snd and virtio-snd-pci devices

In reply to Alex Bennée

From: Manos Pitsidianakis <[email protected]>

Tested with rust-vmm vhost-user-sound daemon:

    RUST_LOG=trace cargo run --bin vhost-user-sound -- --socket /tmp/snd.sock --backend null

Invocation:

    qemu-system-x86_64  \
            -qmp unix:./qmp-sock,server,wait=off  \
            -m 4096 \
            -numa node,memdev=mem \
            -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \
            -D qemu.log \
            -d guest_errors,trace:\*snd\*,trace:\*sound\*,trace:\*vhost\* \
            -chardev socket,id=vsnd,path=/tmp/snd.sock \
            -device vhost-user-snd-pci,chardev=vsnd,id=snd \
            /path/to/disk

[AJB: imported from https://github.com/epilys/qemu-virtio-snd/commit/54ae1cdd15fef2d88e9e387a175f099a38c636f4.patch]

---
v7
- s/parent/parent_obj/
- add MAINTAINERS
- add missing s-o-b

---
 MAINTAINERS                        |  7 +++
 include/hw/virtio/vhost-user-snd.h | 24 ++++++++++
 hw/virtio/vhost-user-snd-pci.c     | 75 ++++++++++++++++++++++++++++++
 hw/virtio/vhost-user-snd.c         | 67 ++++++++++++++++++++++++++
 hw/virtio/Kconfig                  |  5 ++
 hw/virtio/meson.build              |  3 ++
 6 files changed, 181 insertions(+)
 create mode 100644 include/hw/virtio/vhost-user-snd.h
 create mode 100644 hw/virtio/vhost-user-snd-pci.c
 create mode 100644 hw/virtio/vhost-user-snd.c
MAINTAINERS +7 -0
index 0e832fd5d13..607f71817f8 100644
@@ -2327,6 +2327,13 @@ F: hw/virtio/vhost-user-gpio*
 F: include/hw/virtio/vhost-user-gpio.h
 F: tests/qtest/libqos/virtio-gpio.*
 
+vhost-user-snd
+M: Alex Bennée <[email protected]>
+R: Manos Pitsidianakis <[email protected]>
+S: Maintained
+F: hw/virtio/vhost-user-snd*
+F: include/hw/virtio/vhost-user-snd.h
+
 vhost-user-scmi
 R: [email protected]
 S: Supported
include/hw/virtio/vhost-user-snd.h new file +24 -0
new file mode 100644
index 00000000000..f9260116a73
@@ -0,0 +1,24 @@
+/*
+ * Vhost-user Sound virtio device
+ *
+ * Copyright (c) 2021 Mathieu Poirier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_VHOST_USER_SND_H
+#define QEMU_VHOST_USER_SND_H
+
+#include "hw/virtio/virtio.h"
+#include "hw/virtio/vhost.h"
+#include "hw/virtio/vhost-user.h"
+#include "hw/virtio/vhost-user-base.h"
+
+#define TYPE_VHOST_USER_SND "vhost-user-snd"
+OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSound, VHOST_USER_SND)
+
+struct VHostUserSound {
+    VHostUserBase parent_obj;
+};
+
+#endif /* QEMU_VHOST_USER_SND_H */
hw/virtio/vhost-user-snd-pci.c new file +75 -0

75 lines not on this page · raw message

hw/virtio/vhost-user-snd.c new file +67 -0

67 lines not on this page · raw message

hw/virtio/Kconfig +5 -0
index 92c9cf6c96c..aa63ff7fd41 100644
@@ -101,6 +101,11 @@ config VHOST_VDPA_DEV
     default y
     depends on VIRTIO && VHOST_VDPA && LINUX
 
+config VHOST_USER_SND
+    bool
+    default y
+    depends on VIRTIO && VHOST_USER
+
 config VHOST_USER_SCMI
     bool
     default y
hw/virtio/meson.build +3 -0
index 0a4d29ace64..118d4d4da7c 100644
@@ -24,6 +24,7 @@ if have_vhost
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c'))
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
+    system_virtio_ss.add(when: 'CONFIG_VHOST_USER_SND', if_true: files('vhost-user-snd.c'))
 
     # PCI Stubs
     system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c'))
@@ -33,6 +34,8 @@ if have_vhost
                          if_true: files('vhost-user-i2c-pci.c'))
     system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'],
                          if_true: files('vhost-user-rng-pci.c'))
+    system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SND'],
+                         if_true: files('vhost-user-snd-pci.c'))
   endif
   if have_vhost_vdpa
     system_virtio_ss.add(files('vhost-vdpa.c'))
Signature · 1 line
2.39.2
#9 lore raw

PATCH v9 7/11 docs/system: add a basic enumeration of vhost-user devices

In reply to Alex Bennée

Make it clear the vhost-user-device is intended for expert use only.

---
v5
- split vhost-user-device out of the table
- sort the table alphabetically
- add sound and scmi devices
v6
- add note re vhost-user-device
v7
- fix patching description

---
 docs/system/devices/vhost-user-rng.rst |  2 +
 docs/system/devices/vhost-user.rst     | 70 +++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 1 deletion(-)
docs/system/devices/vhost-user-rng.rst +2 -0
index a145d4105c1..ead14053264 100644
@@ -1,3 +1,5 @@
+.. _vhost_user_rng:
+
 QEMU vhost-user-rng - RNG emulation
 ===================================
 
docs/system/devices/vhost-user.rst +69 -1

82 lines not on this page · raw message

Signature · 1 line
2.39.2
#10 lore raw

PATCH v9 8/11 hw/virtio: Support set_config() callback in vhost-user-base

In reply to Alex Bennée

From: Leo Yan <[email protected]>

The Virtio input device invokes set_config() callback for retrieving the event configuration info, but the callback is not supported in vhost-user-base.

This patch adds support set_config() callback in vhost-user-base.

Message-Id: <[email protected]>

---
 hw/virtio/vhost-user-base.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
hw/virtio/vhost-user-base.c +17 -0
index 78cfa9a5bbc..a83167191ee 100644
@@ -140,6 +140,22 @@ static void vub_get_config(VirtIODevice *vdev, uint8_t *config)
     }
 }
 
+static void vub_set_config(VirtIODevice *vdev, const uint8_t *config_data)
+{
+    VHostUserBase *vub = VHOST_USER_BASE(vdev);
+    int ret;
+
+    g_assert(vub->config_size && vub->vhost_user.supports_config == true);
+
+    ret = vhost_dev_set_config(&vub->vhost_dev, config_data,
+                               0, vub->config_size,
+                               VHOST_SET_CONFIG_TYPE_FRONTEND);
+    if (ret) {
+        error_report("vhost guest set device config space failed: %d", ret);
+        return;
+    }
+}
+
 /*
  * When the daemon signals an update to the config we just need to
  * signal the guest as we re-read the config on demand above.
@@ -337,6 +353,7 @@ static void vub_class_init(ObjectClass *klass, void *data)
     vdc->unrealize = vub_device_unrealize;
     vdc->get_features = vub_get_features;
     vdc->get_config = vub_get_config;
+    vdc->set_config = vub_set_config;
     vdc->set_status = vub_set_status;
 }
 
Signature · 1 line
2.39.2
#11 lore raw

PATCH v9 9/11 docs/system: Add vhost-user-input documentation

In reply to Alex Bennée

From: Leo Yan <[email protected]>

This adds basic documentation for vhost-user-input.

Message-Id: <[email protected]>

---
 MAINTAINERS                              |  1 +
 docs/system/device-emulation.rst         |  1 +
 docs/system/devices/vhost-user-input.rst | 45 ++++++++++++++++++++++++
 docs/system/devices/vhost-user.rst       |  4 ++-
 4 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 docs/system/devices/vhost-user-input.rst
MAINTAINERS +1 -0
index 607f71817f8..ff70987aeb3 100644
@@ -2274,6 +2274,7 @@ L: [email protected]
 virtio-input
 M: Gerd Hoffmann <[email protected]>
 S: Odd Fixes
+F: docs/system/devices/vhost-user-input.rst
 F: hw/input/vhost-user-input.c
 F: hw/input/virtio-input*.c
 F: include/hw/virtio/virtio-input.h
docs/system/device-emulation.rst +1 -0
index d1f3277cb02..f19777411cd 100644
@@ -94,6 +94,7 @@ Emulated Devices
    devices/virtio-gpu.rst
    devices/virtio-pmem.rst
    devices/virtio-snd.rst
+   devices/vhost-user-input.rst
    devices/vhost-user-rng.rst
    devices/canokey.rst
    devices/usb-u2f.rst
docs/system/devices/vhost-user-input.rst new file +45 -0

45 lines not on this page · raw message

docs/system/devices/vhost-user.rst +3 -1
index c6afc4836f9..9b2da106cec 100644
@@ -42,7 +42,7 @@ platform details for what sort of virtio bus to use.
     - See https://github.com/rust-vmm/vhost-device
   * - vhost-user-input
     - Generic input driver
-    - See contrib/vhost-user-input
+    - :ref:`vhost_user_input`
   * - vhost-user-rng
     - Entropy driver
     - :ref:`vhost_user_rng`
@@ -91,6 +91,8 @@ following the :ref:`vhost_user_proto`. There are a number of daemons
 that can be built when enabled by the project although any daemon that
 meets the specification for a given device can be used.
 
+.. _shared_memory_object:
+
 Shared memory object
 ====================
 
Signature · 1 line
2.39.2
#12 lore raw

PATCH v9 10/11 hw/virtio: Move vhost-user-input into virtio folder

In reply to Alex Bennée

From: Leo Yan <[email protected]>

vhost-user-input is in the input folder. On the other hand, the folder 'hw/virtio' maintains other virtio stubs (e.g. I2C, RNG, GPIO, etc).

This patch moves vhost-user-input into the virtio folder for better code organization. No functionality change.

Message-Id: <[email protected]>

---
 MAINTAINERS                             | 2 +-
 hw/{input => virtio}/vhost-user-input.c | 0
 hw/input/meson.build                    | 1 -
 hw/virtio/meson.build                   | 4 +++-
 4 files changed, 4 insertions(+), 3 deletions(-)
 rename hw/{input => virtio}/vhost-user-input.c (100%)
MAINTAINERS +1 -1
index ff70987aeb3..66bd1eadc78 100644
@@ -2275,8 +2275,8 @@ virtio-input
 M: Gerd Hoffmann <[email protected]>
 S: Odd Fixes
 F: docs/system/devices/vhost-user-input.rst
-F: hw/input/vhost-user-input.c
 F: hw/input/virtio-input*.c
+F: hw/virtio/vhost-user-input.c
 F: include/hw/virtio/virtio-input.h
 F: contrib/vhost-user-input/*
 
hw/virtio/vhost-user-input.c renamed from hw/input/vhost-user-input.c +0 -0
similarity index 100%
rename from hw/input/vhost-user-input.c
rename to hw/virtio/vhost-user-input.c
hw/input/meson.build +0 -1
index 640556bbbcc..3cc8ab85f0c 100644
@@ -11,7 +11,6 @@ system_ss.add(when: 'CONFIG_TSC2005', if_true: files('tsc2005.c'))
 system_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-input.c'))
 system_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-input-hid.c'))
 system_ss.add(when: 'CONFIG_VIRTIO_INPUT_HOST', if_true: files('virtio-input-host.c'))
-system_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input.c'))
 
 system_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_keypad.c'))
 system_ss.add(when: 'CONFIG_TSC210X', if_true: files('tsc210x.c'))
hw/virtio/meson.build +3 -1
index 118d4d4da7c..c924afcafc0 100644
@@ -25,6 +25,7 @@ if have_vhost
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c'))
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
     system_virtio_ss.add(when: 'CONFIG_VHOST_USER_SND', if_true: files('vhost-user-snd.c'))
+    system_virtio_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input.c'))
 
     # PCI Stubs
     system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c'))
@@ -36,6 +37,8 @@ if have_vhost
                          if_true: files('vhost-user-rng-pci.c'))
     system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SND'],
                          if_true: files('vhost-user-snd-pci.c'))
+    system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_INPUT'],
+                         if_true: files('vhost-user-input-pci.c'))
   endif
   if have_vhost_vdpa
     system_virtio_ss.add(files('vhost-vdpa.c'))
@@ -59,7 +62,6 @@ virtio_pci_ss = ss.source_set()
 virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk-pci.c'))
-virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c'))
 virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c'))
Signature · 1 line
2.39.2
#13 lore raw

PATCH v9 11/11 hw/virtio: derive vhost-user-input from vhost-user-base

In reply to Alex Bennée

From: Leo Yan <[email protected]>

This patch derives vhost-user-input from vhost-user-base class, so make the input stub as a simpler boilerplate wrapper.

With the refactoring, vhost-user-input adds the property 'chardev', this leads to conflict with the vhost-user-input-pci adds the same property. To resolve the error, remove the duplicate property from vhost-user-input-pci.

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio-input.h |   6 +-
 hw/virtio/vhost-user-input-pci.c |   3 -
 hw/virtio/vhost-user-input.c     | 114 +++++--------------------------
 3 files changed, 21 insertions(+), 102 deletions(-)
include/hw/virtio/virtio-input.h +3 -3
index a6c97036440..e69c0aeca38 100644
@@ -1,6 +1,8 @@
 #ifndef QEMU_VIRTIO_INPUT_H
 #define QEMU_VIRTIO_INPUT_H
 
+#include "hw/virtio/vhost-user.h"
+#include "hw/virtio/vhost-user-base.h"
 #include "ui/input.h"
 #include "sysemu/vhost-user-backend.h"
 
@@ -97,9 +99,7 @@ struct VirtIOInputHost {
 };
 
 struct VHostUserInput {
-    VirtIOInput                       parent_obj;
-
-    VhostUserBackend                  *vhost;
+    VHostUserBase parent_obj;
 };
 
 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
hw/virtio/vhost-user-input-pci.c +0 -3
index b858898a363..3f4761ce88a 100644
@@ -30,9 +30,6 @@ static void vhost_user_input_pci_instance_init(Object *obj)
 
     virtio_instance_init_common(obj, &dev->vhi, sizeof(dev->vhi),
                                 TYPE_VHOST_USER_INPUT);
-
-    object_property_add_alias(obj, "chardev",
-                              OBJECT(&dev->vhi), "chardev");
 }
 
 static const VirtioPCIDeviceTypeInfo vhost_user_input_pci_info = {
hw/virtio/vhost-user-input.c +18 -96

141 lines not on this page · raw message

Signature · 1 line
2.39.2
#14 lore raw
In reply to Alex Bennée
Quoted 9 lines · Alex Bennée

A lot of our vhost-user stubs are large chunks of boilerplate that do (mostly) the same thing. This series continues the cleanups by splitting the vhost-user-base and vhost-user-generic implementations. After adding a new vq_size property the rng, gpio and i2c vhost-user devices become simple specialisations of the common base defining the ID, number of queues and potentially the config handling.

I've also added Manos' vhost-user-sound and Leo's vhost-user-input stubs which are based on the same base.

Ping MST,

Are you waiting for anything else before pulling this into your queue?

Quoted 79 lines

Changes
-------

v9
- re-base and fix conflicts
- add Leo's vhost-user-input series

v8
- scrubbed errant Message-Id

v7
- various review comments
- move to async teardown (fixes CI failure)

v6
- re-base to current master
- make vhost-user-device abstract
- mention abstractness in docs

v5
- addressing comments and tags
- improved the docs

v4
- dropped the F_TRANSPORT work for another series
- added vhost-user-sound

Alex Bennée (6):
virtio: split into vhost-user-base and vhost-user-device hw/virtio: convert vhost-user-base to async shutdown hw/virtio: derive vhost-user-rng from vhost-user-base hw/virtio: derive vhost-user-gpio from vhost-user-base hw/virtio: derive vhost-user-i2c from vhost-user-base docs/system: add a basic enumeration of vhost-user devices

Leo Yan (4):
hw/virtio: Support set_config() callback in vhost-user-base docs/system: Add vhost-user-input documentation hw/virtio: Move vhost-user-input into virtio folder hw/virtio: derive vhost-user-input from vhost-user-base

Manos Pitsidianakis (1):
hw/virtio: add vhost-user-snd and virtio-snd-pci devices

 MAINTAINERS                                   |  16 +-
 docs/system/device-emulation.rst              |   1 +
 docs/system/devices/vhost-user-input.rst      |  45 ++
 docs/system/devices/vhost-user-rng.rst        |   2 +
 docs/system/devices/vhost-user.rst            |  72 +++-
 ...{vhost-user-device.h => vhost-user-base.h} |  21 +-
 include/hw/virtio/vhost-user-gpio.h           |  25 +-
 include/hw/virtio/vhost-user-i2c.h            |  14 +-
 include/hw/virtio/vhost-user-rng.h            |  13 +-
 include/hw/virtio/vhost-user-snd.h            |  24 ++
 include/hw/virtio/virtio-input.h              |   6 +-
 hw/input/vhost-user-input.c                   | 136 ------
 hw/virtio/vhost-user-base.c                   | 371 ++++++++++++++++
 hw/virtio/vhost-user-device-pci.c             |  13 +-
 hw/virtio/vhost-user-device.c                 | 338 +--------------
 hw/virtio/vhost-user-gpio.c                   | 407 +-----------------
 hw/virtio/vhost-user-i2c.c                    | 272 +-----------
 hw/virtio/vhost-user-input-pci.c              |   3 -
 hw/virtio/vhost-user-input.c                  |  58 +++
 hw/virtio/vhost-user-rng.c                    | 294 +------------
 hw/virtio/vhost-user-snd-pci.c                |  75 ++++
 hw/virtio/vhost-user-snd.c                    |  67 +++
 hw/input/meson.build                          |   1 -
 hw/virtio/Kconfig                             |   5 +
 hw/virtio/meson.build                         |  27 +-
 25 files changed, 850 insertions(+), 1456 deletions(-)
 create mode 100644 docs/system/devices/vhost-user-input.rst
 rename include/hw/virtio/{vhost-user-device.h => vhost-user-base.h} (71%)
 create mode 100644 include/hw/virtio/vhost-user-snd.h
 delete mode 100644 hw/input/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-base.c
 create mode 100644 hw/virtio/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-snd-pci.c
 create mode 100644 hw/virtio/vhost-user-snd.c
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#15 lore raw
Quoted 9 lines · Alex Bennée
Quoted 7 lines · Alex Bennée

A lot of our vhost-user stubs are large chunks of boilerplate that do (mostly) the same thing. This series continues the cleanups by splitting the vhost-user-base and vhost-user-generic implementations. After adding a new vq_size property the rng, gpio and i2c vhost-user devices become simple specialisations of the common base defining the ID, number of queues and potentially the config handling.

Quoted 6 lines
Quoted 2 lines

I've also added Manos' vhost-user-sound and Leo's vhost-user-input stubs which are based on the same base.

Ping MST,

Are you waiting for anything else before pulling this into your queue?

Tagged, thanks!

Quoted 83 lines
Quoted 79 lines

Changes
-------

v9
- re-base and fix conflicts
- add Leo's vhost-user-input series

v8
- scrubbed errant Message-Id

v7
- various review comments
- move to async teardown (fixes CI failure)

v6
- re-base to current master
- make vhost-user-device abstract
- mention abstractness in docs

v5
- addressing comments and tags
- improved the docs

v4
- dropped the F_TRANSPORT work for another series
- added vhost-user-sound

Alex Bennée (6):
virtio: split into vhost-user-base and vhost-user-device hw/virtio: convert vhost-user-base to async shutdown hw/virtio: derive vhost-user-rng from vhost-user-base hw/virtio: derive vhost-user-gpio from vhost-user-base hw/virtio: derive vhost-user-i2c from vhost-user-base docs/system: add a basic enumeration of vhost-user devices

Leo Yan (4):
hw/virtio: Support set_config() callback in vhost-user-base docs/system: Add vhost-user-input documentation hw/virtio: Move vhost-user-input into virtio folder hw/virtio: derive vhost-user-input from vhost-user-base

Manos Pitsidianakis (1):
hw/virtio: add vhost-user-snd and virtio-snd-pci devices

 MAINTAINERS                                   |  16 +-
 docs/system/device-emulation.rst              |   1 +
 docs/system/devices/vhost-user-input.rst      |  45 ++
 docs/system/devices/vhost-user-rng.rst        |   2 +
 docs/system/devices/vhost-user.rst            |  72 +++-
 ...{vhost-user-device.h => vhost-user-base.h} |  21 +-
 include/hw/virtio/vhost-user-gpio.h           |  25 +-
 include/hw/virtio/vhost-user-i2c.h            |  14 +-
 include/hw/virtio/vhost-user-rng.h            |  13 +-
 include/hw/virtio/vhost-user-snd.h            |  24 ++
 include/hw/virtio/virtio-input.h              |   6 +-
 hw/input/vhost-user-input.c                   | 136 ------
 hw/virtio/vhost-user-base.c                   | 371 ++++++++++++++++
 hw/virtio/vhost-user-device-pci.c             |  13 +-
 hw/virtio/vhost-user-device.c                 | 338 +--------------
 hw/virtio/vhost-user-gpio.c                   | 407 +-----------------
 hw/virtio/vhost-user-i2c.c                    | 272 +-----------
 hw/virtio/vhost-user-input-pci.c              |   3 -
 hw/virtio/vhost-user-input.c                  |  58 +++
 hw/virtio/vhost-user-rng.c                    | 294 +------------
 hw/virtio/vhost-user-snd-pci.c                |  75 ++++
 hw/virtio/vhost-user-snd.c                    |  67 +++
 hw/input/meson.build                          |   1 -
 hw/virtio/Kconfig                             |   5 +
 hw/virtio/meson.build                         |  27 +-
 25 files changed, 850 insertions(+), 1456 deletions(-)
 create mode 100644 docs/system/devices/vhost-user-input.rst
 rename include/hw/virtio/{vhost-user-device.h => vhost-user-base.h} (71%)
 create mode 100644 include/hw/virtio/vhost-user-snd.h
 delete mode 100644 hw/input/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-base.c
 create mode 100644 hw/virtio/vhost-user-input.c
 create mode 100644 hw/virtio/vhost-user-snd-pci.c
 create mode 100644 hw/virtio/vhost-user-snd.c
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro