@samitouri / QOSamiQemu / commits / c66f9c8094

hw/loongarch/virt: Define virt machine type with type_init()

Define virt machine with function type_init(), so that qemu versioned virt machine can be added in later with similar method. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>

Bibo Mao committed Apr 1, 2026 at 09:57 UTC c66f9c8094331e6e9badc0f39ab9ad048681c021
1 file changed +16 -13
hw/loongarch/virt.c
+16 -13
@@ -1535,18 +1535,21 @@ static void virt_class_init(ObjectClass *oc, const void *data)
1535 "for PCI MMIO");
1536 }
1537
1538 -static const TypeInfo virt_machine_types[] = {
1539 - {
1540 - .name = TYPE_LOONGARCH_VIRT_MACHINE,
1541 - .parent = TYPE_MACHINE,
1542 - .instance_size = sizeof(LoongArchVirtMachineState),
1543 - .class_init = virt_class_init,
1544 - .instance_init = virt_initfn,
1545 - .interfaces = (const InterfaceInfo[]) {
1546 - { TYPE_HOTPLUG_HANDLER },
1547 - { }
1548 - },
1549 - }
1538 +static const TypeInfo virt_machine_info = {
1539 + .name = TYPE_LOONGARCH_VIRT_MACHINE,
1540 + .parent = TYPE_MACHINE,
1541 + .instance_size = sizeof(LoongArchVirtMachineState),
1542 + .class_init = virt_class_init,
1543 + .instance_init = virt_initfn,
1544 + .interfaces = (InterfaceInfo[]) {
1545 + { TYPE_HOTPLUG_HANDLER },
1546 + { }
1547 + },
1548 };
1549
1552 -DEFINE_TYPES(virt_machine_types)
1550 +static void machvirt_machine_init(void)
1551 +{
1552 + type_register_static(&virt_machine_info);
1553 +}
1554 +
1555 +type_init(machvirt_machine_init);