A lot of our vhost-user stubs are large chunks of boilerplate that do (mostly) the same thing. This series attempts to fix that by defining a new base class for vhost-user devices and then converting the rng and gpio devices to be based off them. You can even use vhost-user-device directly if you supply it with the right magic numbers (which is helpful for development).
However the final patch runs into the weeds because I don't yet have a clean way to represent in QOM the fixing of certain properties for the specialised classes. The series is a net reduction in code and an increase in documentation but obviously needs to iron out a few more warts. I'm open to suggestions on the best way to tweak the QOM stuff. Alex. Alex Bennée (12): hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments include/hw/virtio: document virtio_notify_config include/hw/virtio: add kerneldoc for virtio_init include/hw/virtio: document some more usage of notifiers virtio: add generic vhost-user-device virtio: add PCI stub for vhost-user-device include: attempt to document device_class_set_props qom: allow for properties to become "fixed" hw/virtio: derive vhost-user-rng from vhost-user-device hw/virtio: add config support to vhost-user-device hw/virtio: derive vhost-user-gpio from vhost-user-device (!BROKEN) docs/system: add a basic enumeration of vhost-user devices docs/system/devices/vhost-user-rng.rst | 2 + docs/system/devices/vhost-user.rst | 41 +++ qapi/qom.json | 2 + include/hw/qdev-core.h | 9 + include/hw/virtio/vhost-user-device.h | 33 ++ include/hw/virtio/vhost-user-gpio.h | 23 +- include/hw/virtio/vhost-user-rng.h | 11 +- include/hw/virtio/virtio.h | 21 ++ include/qom/object.h | 16 +- hw/display/vhost-user-gpu.c | 4 +- hw/net/virtio-net.c | 4 +- hw/virtio/vhost-user-device-pci.c | 71 +++++ hw/virtio/vhost-user-device.c | 359 ++++++++++++++++++++++ hw/virtio/vhost-user-fs.c | 4 +- hw/virtio/vhost-user-gpio.c | 405 +------------------------ hw/virtio/vhost-user-rng.c | 264 +--------------- hw/virtio/vhost-vsock-common.c | 4 +- hw/virtio/virtio-crypto.c | 4 +- qom/object.c | 14 + qom/object_interfaces.c | 9 +- qom/qom-qmp-cmds.c | 1 + softmmu/qdev-monitor.c | 1 + hw/virtio/meson.build | 3 + 23 files changed, 613 insertions(+), 692 deletions(-) create mode 100644 include/hw/virtio/vhost-user-device.h create mode 100644 hw/virtio/vhost-user-device-pci.c create mode 100644 hw/virtio/vhost-user-device.c -- 2.39.2