Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> --- hw/virtio/virtio-pci.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index a33d1b2cbcf..6f0e1772669 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2488,10 +2488,12 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) .abstract = true, .interfaces = t->interfaces, }; - TypeInfo generic_type_info = { + const TypeInfo generic_type_info = { .name = t->generic_name, - .parent = t->base_name, - .class_init = virtio_pci_generic_class_init, + .parent = t->base_name ?: base_name, + .class_init = t->base_name ? virtio_pci_generic_class_init + : virtio_pci_base_class_init, + .class_data = t->base_name ? NULL : t, .interfaces = (const InterfaceInfo[]) { { INTERFACE_PCIE_DEVICE }, { INTERFACE_CONVENTIONAL_PCI_DEVICE }, @@ -2504,13 +2506,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t) type_register_static(&base_type_info); - if (!t->base_name) { - generic_type_info.parent = base_name; - generic_type_info.class_init = virtio_pci_base_class_init; - generic_type_info.class_data = t; - } - - if (generic_type_info.name) { + if (t->generic_name) { type_register_static(&generic_type_info); } -- 2.47.1