Set TYPE_HEXAGON_VIRT_MACHINE to MACHINE_TYPE_NAME("hexagon-virt") so
Hexagon virt no longer collides with other virt-machine types in one
process. Keep the -M / help / migration name as virt via
machine_class_set_name().

Signed-off-by: Yonggang Luo <[email protected]>
Reviewed-by: Brian Cain <[email protected]>
Reviewed-by: Marc-AndrĂ© Lureau <[email protected]>
Reviewed-by: Zhao Liu <[email protected]>
---
 hw/hexagon/virt.c         | 23 +++++++++++++++--------
 include/hw/hexagon/virt.h |  5 ++++-
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c
index 64d8366d27d..ed086afe204 100644
--- a/hw/hexagon/virt.c
+++ b/hw/hexagon/virt.c
@@ -359,6 +359,7 @@ static void virt_class_init(ObjectClass *oc, const void 
*data)
     MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Hexagon Virtual Machine";
+    machine_class_set_name(mc, "virt");
     mc->init = virt_init;
     mc->default_cpu_type = HEXAGON_CPU_TYPE_NAME("v68");
     mc->default_ram_size = 4 * GiB;
@@ -373,12 +374,18 @@ static void virt_class_init(ObjectClass *oc, const void 
*data)
     mc->default_nic = "virtio-mmio-bus";
 }
 
+static void virt_machine_register_types(void)
+{
+    const TypeInfo virt_machine_types[] = {
+        {
+            .name = TYPE_HEXAGON_VIRT_MACHINE,
+            .parent = TYPE_HEXAGON_COMMON_MACHINE,
+            .instance_size = sizeof(HexagonVirtMachineState),
+            .class_init = virt_class_init,
+        }
+    };
+    type_register_static_array(virt_machine_types,
+                               ARRAY_SIZE(virt_machine_types));
+}
 
-static const TypeInfo virt_machine_types[] = { {
-    .name = TYPE_HEXAGON_VIRT_MACHINE,
-    .parent = TYPE_HEXAGON_COMMON_MACHINE,
-    .instance_size = sizeof(HexagonVirtMachineState),
-    .class_init = virt_class_init,
-} };
-
-DEFINE_TYPES(virt_machine_types)
+type_init(virt_machine_register_types)
diff --git a/include/hw/hexagon/virt.h b/include/hw/hexagon/virt.h
index 4ca2f1ef859..e5dfcd351a5 100644
--- a/include/hw/hexagon/virt.h
+++ b/include/hw/hexagon/virt.h
@@ -9,6 +9,7 @@
 #define HW_HEXAGONVIRT_H
 
 #include "hw/hexagon/hexagon.h"
+#include "qemu/target-info.h"
 #include "target/hexagon/cpu.h"
 
 #define VIRTIO_DEV_COUNT 8
@@ -26,7 +27,9 @@ struct HexagonVirtMachineState {
 
 void hexagon_load_fdt(const struct HexagonVirtMachineState *vms);
 
-#define TYPE_HEXAGON_VIRT_MACHINE MACHINE_TYPE_NAME("virt")
+#define TYPE_HEXAGON_VIRT_MACHINE \
+    (target_combined_binary() ? MACHINE_TYPE_NAME("hexagon-virt") : \
+                                MACHINE_TYPE_NAME("virt"))
 OBJECT_DECLARE_SIMPLE_TYPE(HexagonVirtMachineState, HEXAGON_VIRT_MACHINE)
 
 #endif /* HW_HEXAGONVIRT_H */
-- 
2.55.0.windows.3


Reply via email to