On 4/1/24 22:09, Alex Bennée wrote:
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.
Signed-off-by: Alex Bennée <alex.ben...@linaro.org>
---
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
@@ -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?
+
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),
};