Skip to contentSkip to conversation

hw/arm: Define machines as generic QOM types

PATCH In review Philippe Mathieu-Daudé 3 participants 22 messages Apr 17, 2025 – Apr 19, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover hw/arm: Define machines as generic QOM types

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

 hw/arm/bananapi_m2u.c      | 13 +++++++++++--
 hw/arm/cubieboard.c        | 13 +++++++++++--
 hw/arm/digic_boards.c      | 14 ++++++++++++--
 hw/arm/imx25_pdk.c         | 14 ++++++++++++--
 hw/arm/imx8mp-evk.c        | 15 +++++++++++++--
 hw/arm/integratorcp.c      | 16 +++++++++++++---
 hw/arm/kzm.c               | 14 ++++++++++++--
 hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++--
 hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++--
 hw/arm/msf2-som.c          | 13 +++++++++++--
 hw/arm/musicpal.c          | 16 +++++++++++++---
 hw/arm/netduino2.c         | 13 +++++++++++--
 hw/arm/netduinoplus2.c     | 13 +++++++++++--
 hw/arm/olimex-stm32-h405.c | 13 +++++++++++--
 hw/arm/orangepi.c          | 13 +++++++++++--
 hw/arm/sabrelite.c         | 14 ++++++++++++--
 hw/arm/stm32vldiscovery.c  | 13 +++++++++++--
 hw/core/null-machine.c     | 14 ++++++++++++--
 18 files changed, 213 insertions(+), 38 deletions(-)
Signature · 1 line
2.47.1
#1 lore raw

PATCH 1/11 hw/core/null-machine: Define machine as generic QOM type

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/core/null-machine.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
hw/core/null-machine.c +12 -2
index a6e477a2d88..1ccaf652eb4 100644
@@ -42,8 +42,10 @@ static void machine_none_init(MachineState *mch)
     }
 }
 
-static void machine_none_machine_init(MachineClass *mc)
+static void null_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "empty machine";
     mc->init = machine_none_init;
     mc->max_cpus = 1;
@@ -55,4 +57,12 @@ static void machine_none_machine_init(MachineClass *mc)
     mc->no_cdrom = 1;
 }
 
-DEFINE_MACHINE("none", machine_none_machine_init)
+static const TypeInfo null_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("none"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = null_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(null_machine_types)
Signature · 1 line
2.47.1
#2 lore raw

PATCH 2/11 hw/arm/bananapi: Define machine as generic QOM type

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/bananapi_m2u.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
hw/arm/bananapi_m2u.c +11 -2
index b750a575f72..724ee4b05e5 100644
@@ -125,12 +125,13 @@ static void bpim2u_init(MachineState *machine)
     arm_load_kernel(&r40->cpus[0], machine, &bpim2u_binfo);
 }
 
-static void bpim2u_machine_init(MachineClass *mc)
+static void bpim2u_machine_class_init(ObjectClass *oc, void *data)
 {
     static const char * const valid_cpu_types[] = {
         ARM_CPU_TYPE_NAME("cortex-a7"),
         NULL
     };
+    MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Bananapi M2U (Cortex-A7)";
     mc->init = bpim2u_init;
@@ -144,4 +145,12 @@ static void bpim2u_machine_init(MachineClass *mc)
     mc->auto_create_sdcard = true;
 }
 
-DEFINE_MACHINE("bpim2u", bpim2u_machine_init)
+static const TypeInfo bananapi_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("bpim2u"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = bpim2u_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(bananapi_machine_types)
Signature · 1 line
2.47.1
#3 lore raw

PATCH 3/11 hw/arm/cubieboard: Define machine as generic QOM type

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/cubieboard.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
hw/arm/cubieboard.c +11 -2
index d665d4edd97..36062ac7037 100644
@@ -106,12 +106,13 @@ static void cubieboard_init(MachineState *machine)
     arm_load_kernel(&a10->cpu, machine, &cubieboard_binfo);
 }
 
-static void cubieboard_machine_init(MachineClass *mc)
+static void cubieboard_machine_class_init(ObjectClass *oc, void *data)
 {
     static const char * const valid_cpu_types[] = {
         ARM_CPU_TYPE_NAME("cortex-a8"),
         NULL
     };
+    MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "cubietech cubieboard (Cortex-A8)";
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8");
@@ -125,4 +126,12 @@ static void cubieboard_machine_init(MachineClass *mc)
     mc->auto_create_sdcard = true;
 }
 
-DEFINE_MACHINE("cubieboard", cubieboard_machine_init)
+static const TypeInfo cubieboard_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("cubieboard"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = cubieboard_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(cubieboard_machine_types)
Signature · 1 line
2.47.1
#4 lore raw

PATCH 4/11 hw/arm/digic: Define machine as generic QOM type

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/digic_boards.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
hw/arm/digic_boards.c +12 -2
index 466b8b84c0e..3c0cc6e4370 100644
@@ -136,8 +136,10 @@ static void canon_a1100_init(MachineState *machine)
     digic4_board_init(machine, &digic4_board_canon_a1100);
 }
 
-static void canon_a1100_machine_init(MachineClass *mc)
+static void digic_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "Canon PowerShot A1100 IS (ARM946)";
     mc->init = &canon_a1100_init;
     mc->ignore_memory_transaction_failures = true;
@@ -145,4 +147,12 @@ static void canon_a1100_machine_init(MachineClass *mc)
     mc->default_ram_id = "ram";
 }
 
-DEFINE_MACHINE("canon-a1100", canon_a1100_machine_init)
+static const TypeInfo digic_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("canon-a1100"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = digic_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(digic_machine_types)
Signature · 1 line
2.47.1
#5 lore raw

PATCH 5/11 hw/arm/imx: Define machines as generic QOM types

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/imx25_pdk.c     | 14 ++++++++++++--
 hw/arm/imx8mp-evk.c    | 15 +++++++++++++--
 hw/arm/mcimx6ul-evk.c  | 15 +++++++++++++--
 hw/arm/mcimx7d-sabre.c | 15 +++++++++++++--
 hw/arm/sabrelite.c     | 14 ++++++++++++--
 5 files changed, 63 insertions(+), 10 deletions(-)
hw/arm/imx25_pdk.c +12 -2
index e95ea5e4e18..a90def7f1a2 100644
@@ -141,8 +141,10 @@ static void imx25_pdk_init(MachineState *machine)
     }
 }
 
-static void imx25_pdk_machine_init(MachineClass *mc)
+static void imx25_pdk_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "ARM i.MX25 PDK board (ARM926)";
     mc->init = imx25_pdk_init;
     mc->ignore_memory_transaction_failures = true;
@@ -150,4 +152,12 @@ static void imx25_pdk_machine_init(MachineClass *mc)
     mc->auto_create_sdcard = true;
 }
 
-DEFINE_MACHINE("imx25-pdk", imx25_pdk_machine_init)
+static const TypeInfo imx25_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("imx25-pdk"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = imx25_pdk_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(imx25_machine_types)
hw/arm/imx8mp-evk.c +13 -2
index 967258e6484..c7d87d99230 100644
@@ -64,11 +64,22 @@ static void imx8mp_evk_init(MachineState *machine)
     }
 }
 
-static void imx8mp_evk_machine_init(MachineClass *mc)
+static void imx8mp_evk_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "NXP i.MX 8M Plus EVK Board";
     mc->init = imx8mp_evk_init;
     mc->max_cpus = FSL_IMX8MP_NUM_CPUS;
     mc->default_ram_id = "imx8mp-evk.ram";
 }
-DEFINE_MACHINE("imx8mp-evk", imx8mp_evk_machine_init)
+
+static const TypeInfo imx8_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("imx8mp-evk"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = imx8mp_evk_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(imx8_machine_types)
hw/arm/mcimx6ul-evk.c +13 -2
index 86982cb0772..d947836d2be 100644
@@ -68,12 +68,23 @@ static void mcimx6ul_evk_init(MachineState *machine)
     }
 }
 
-static void mcimx6ul_evk_machine_init(MachineClass *mc)
+static void mcimx6ul_evk_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "Freescale i.MX6UL Evaluation Kit (Cortex-A7)";
     mc->init = mcimx6ul_evk_init;
     mc->max_cpus = FSL_IMX6UL_NUM_CPUS;
     mc->default_ram_id = "mcimx6ul-evk.ram";
     mc->auto_create_sdcard = true;
 }
-DEFINE_MACHINE("mcimx6ul-evk", mcimx6ul_evk_machine_init)
+
+static const TypeInfo imx6_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("mcimx6ul-evk"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = mcimx6ul_evk_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(imx6_machine_types)
hw/arm/mcimx7d-sabre.c +13 -2
index 33119610113..f5dc9c211dd 100644
@@ -68,12 +68,23 @@ static void mcimx7d_sabre_init(MachineState *machine)
     }
 }
 
-static void mcimx7d_sabre_machine_init(MachineClass *mc)
+static void mcimx7d_sabre_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "Freescale i.MX7 DUAL SABRE (Cortex-A7)";
     mc->init = mcimx7d_sabre_init;
     mc->max_cpus = FSL_IMX7_NUM_CPUS;
     mc->default_ram_id = "mcimx7d-sabre.ram";
     mc->auto_create_sdcard = true;
 }
-DEFINE_MACHINE("mcimx7d-sabre", mcimx7d_sabre_machine_init)
+
+static const TypeInfo imx7_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("mcimx7d-sabre"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = mcimx7d_sabre_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(imx7_machine_types)
hw/arm/sabrelite.c +12 -2
index df60d47c6fd..ea59ba301e7 100644
@@ -103,8 +103,10 @@ static void sabrelite_init(MachineState *machine)
     }
 }
 
-static void sabrelite_machine_init(MachineClass *mc)
+static void sabrelite_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "Freescale i.MX6 Quad SABRE Lite Board (Cortex-A9)";
     mc->init = sabrelite_init;
     mc->max_cpus = FSL_IMX6_NUM_CPUS;
@@ -113,4 +115,12 @@ static void sabrelite_machine_init(MachineClass *mc)
     mc->auto_create_sdcard = true;
 }
 
-DEFINE_MACHINE("sabrelite", sabrelite_machine_init)
+static const TypeInfo sabrelite_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("sabrelite"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = sabrelite_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(sabrelite_machine_types)
Signature · 1 line
2.47.1
#6 lore raw

PATCH 6/11 hw/arm/integratorcp: Define machine as generic QOM type

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/integratorcp.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
hw/arm/integratorcp.c +13 -3
index ac0c6c60961..f95916b517d 100644
@@ -681,8 +681,10 @@ static void integratorcp_init(MachineState *machine)
     arm_load_kernel(cpu, machine, &integrator_binfo);
 }
 
-static void integratorcp_machine_init(MachineClass *mc)
+static void integratorcp_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "ARM Integrator/CP (ARM926EJ-S)";
     mc->init = integratorcp_init;
     mc->ignore_memory_transaction_failures = true;
@@ -693,8 +695,6 @@ static void integratorcp_machine_init(MachineClass *mc)
     machine_add_audiodev_property(mc);
 }
 
-DEFINE_MACHINE("integratorcp", integratorcp_machine_init)
-
 static const Property core_properties[] = {
     DEFINE_PROP_UINT32("memsz", IntegratorCMState, memsz, 0),
 };
@@ -754,3 +754,13 @@ static void integratorcp_register_types(void)
 }
 
 type_init(integratorcp_register_types)
+
+static const TypeInfo integratorcp_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("integratorcp"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = integratorcp_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(integratorcp_machine_types)
Signature · 1 line
2.47.1
#7 lore raw

PATCH 7/11 hw/arm/kzm: Define machine as generic QOM type

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/kzm.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
hw/arm/kzm.c +12 -2
index 362c1454099..b56cabe9f94 100644
@@ -131,12 +131,22 @@ static void kzm_init(MachineState *machine)
     }
 }
 
-static void kzm_machine_init(MachineClass *mc)
+static void kzm_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "ARM KZM Emulation Baseboard (ARM1136)";
     mc->init = kzm_init;
     mc->ignore_memory_transaction_failures = true;
     mc->default_ram_id = "kzm.ram";
 }
 
-DEFINE_MACHINE("kzm", kzm_machine_init)
+static const TypeInfo kzm_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("kzm"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = kzm_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(kzm_machine_types)
Signature · 1 line
2.47.1
#8 lore raw

PATCH 8/11 hw/arm/msf2: Define machine as generic QOM type

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/msf2-som.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
hw/arm/msf2-som.c +11 -2
index 29c76c68605..6ce47eaa27a 100644
@@ -96,16 +96,25 @@ static void emcraft_sf2_s2s010_init(MachineState *machine)
                        0, soc->envm_size);
 }
 
-static void emcraft_sf2_machine_init(MachineClass *mc)
+static void emcraft_sf2_machine_class_init(ObjectClass *oc, void *data)
 {
     static const char * const valid_cpu_types[] = {
         ARM_CPU_TYPE_NAME("cortex-m3"),
         NULL
     };
+    MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "SmartFusion2 SOM kit from Emcraft (M2S010)";
     mc->init = emcraft_sf2_s2s010_init;
     mc->valid_cpu_types = valid_cpu_types;
 }
 
-DEFINE_MACHINE("emcraft-sf2", emcraft_sf2_machine_init)
+static const TypeInfo msf2_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("emcraft-sf2"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = emcraft_sf2_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(msf2_machine_types)
Signature · 1 line
2.47.1
#9 lore raw

PATCH 9/11 hw/arm/musicpal: Define machine as generic QOM type

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/musicpal.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
hw/arm/musicpal.c +13 -3
index 48a32c24079..f7c488cd1d6 100644
@@ -1334,8 +1334,10 @@ static void musicpal_init(MachineState *machine)
     arm_load_kernel(cpu, machine, &musicpal_binfo);
 }
 
-static void musicpal_machine_init(MachineClass *mc)
+static void musicpal_machine_class_init(ObjectClass *oc, void *data)
 {
+    MachineClass *mc = MACHINE_CLASS(oc);
+
     mc->desc = "Marvell 88w8618 / MusicPal (ARM926EJ-S)";
     mc->init = musicpal_init;
     mc->ignore_memory_transaction_failures = true;
@@ -1346,8 +1348,6 @@ static void musicpal_machine_init(MachineClass *mc)
     machine_add_audiodev_property(mc);
 }
 
-DEFINE_MACHINE("musicpal", musicpal_machine_init)
-
 static void mv88w8618_wlan_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1375,3 +1375,13 @@ static void musicpal_register_types(void)
 }
 
 type_init(musicpal_register_types)
+
+static const TypeInfo musicpal_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("musicpal"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = musicpal_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(musicpal_types)
Signature · 1 line
2.47.1
#10 lore raw

PATCH 10/11 hw/arm/orangepi: Define machine as generic QOM type

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/orangepi.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
hw/arm/orangepi.c +11 -2
index e0956880d11..6821033bfd7 100644
@@ -103,12 +103,13 @@ static void orangepi_init(MachineState *machine)
     arm_load_kernel(&h3->cpus[0], machine, &orangepi_binfo);
 }
 
-static void orangepi_machine_init(MachineClass *mc)
+static void orangepi_machine_class_init(ObjectClass *oc, void *data)
 {
     static const char * const valid_cpu_types[] = {
         ARM_CPU_TYPE_NAME("cortex-a7"),
         NULL
     };
+    MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Orange Pi PC (Cortex-A7)";
     mc->init = orangepi_init;
@@ -124,4 +125,12 @@ static void orangepi_machine_init(MachineClass *mc)
     mc->auto_create_sdcard = true;
 }
 
-DEFINE_MACHINE("orangepi-pc", orangepi_machine_init)
+static const TypeInfo orangepi_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("orangepi-pc"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = orangepi_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(orangepi_machine_types)
Signature · 1 line
2.47.1
#11 lore raw

PATCH 11/11 hw/arm/stm32: Define machines as generic QOM types

In reply to Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

---
 hw/arm/netduino2.c         | 13 +++++++++++--
 hw/arm/netduinoplus2.c     | 13 +++++++++++--
 hw/arm/olimex-stm32-h405.c | 13 +++++++++++--
 hw/arm/stm32vldiscovery.c  | 13 +++++++++++--
 4 files changed, 44 insertions(+), 8 deletions(-)
hw/arm/netduino2.c +11 -2
index df793c77fe1..52c30055d44 100644
@@ -52,12 +52,13 @@ static void netduino2_init(MachineState *machine)
                        0, FLASH_SIZE);
 }
 
-static void netduino2_machine_init(MachineClass *mc)
+static void netduino2_machine_class_init(ObjectClass *oc, void *data)
 {
     static const char * const valid_cpu_types[] = {
         ARM_CPU_TYPE_NAME("cortex-m3"),
         NULL
     };
+    MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Netduino 2 Machine (Cortex-M3)";
     mc->init = netduino2_init;
@@ -65,4 +66,12 @@ static void netduino2_machine_init(MachineClass *mc)
     mc->ignore_memory_transaction_failures = true;
 }
 
-DEFINE_MACHINE("netduino2", netduino2_machine_init)
+static const TypeInfo netduino_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("netduino2"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = netduino2_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(netduino_machine_types)
hw/arm/netduinoplus2.c +11 -2
index 81b6334cf72..2735d3a0e2b 100644
@@ -53,16 +53,25 @@ static void netduinoplus2_init(MachineState *machine)
                        0, FLASH_SIZE);
 }
 
-static void netduinoplus2_machine_init(MachineClass *mc)
+static void netduinoplus2_machine_class_init(ObjectClass *oc, void *data)
 {
     static const char * const valid_cpu_types[] = {
         ARM_CPU_TYPE_NAME("cortex-m4"),
         NULL
     };
+    MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Netduino Plus 2 Machine (Cortex-M4)";
     mc->init = netduinoplus2_init;
     mc->valid_cpu_types = valid_cpu_types;
 }
 
-DEFINE_MACHINE("netduinoplus2", netduinoplus2_machine_init)
+static const TypeInfo netduino_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("netduinoplus2"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = netduinoplus2_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(netduino_machine_types)
hw/arm/olimex-stm32-h405.c +11 -2
index 1f15620f9fd..795218c93cf 100644
@@ -56,12 +56,13 @@ static void olimex_stm32_h405_init(MachineState *machine)
                        0, FLASH_SIZE);
 }
 
-static void olimex_stm32_h405_machine_init(MachineClass *mc)
+static void olimex_stm32_machine_class_init(ObjectClass *oc, void *data)
 {
     static const char * const valid_cpu_types[] = {
         ARM_CPU_TYPE_NAME("cortex-m4"),
         NULL
     };
+    MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "Olimex STM32-H405 (Cortex-M4)";
     mc->init = olimex_stm32_h405_init;
@@ -71,4 +72,12 @@ static void olimex_stm32_h405_machine_init(MachineClass *mc)
     mc->default_ram_size = 0;
 }
 
-DEFINE_MACHINE("olimex-stm32-h405", olimex_stm32_h405_machine_init)
+static const TypeInfo olimex_stm32_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("olimex-stm32-h405"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = olimex_stm32_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(olimex_stm32_machine_types)
hw/arm/stm32vldiscovery.c +11 -2
index e6c1f5b8d7d..3a9728ca719 100644
@@ -56,16 +56,25 @@ static void stm32vldiscovery_init(MachineState *machine)
                        0, FLASH_SIZE);
 }
 
-static void stm32vldiscovery_machine_init(MachineClass *mc)
+static void stm32vldiscovery_machine_class_init(ObjectClass *oc, void *data)
 {
     static const char * const valid_cpu_types[] = {
         ARM_CPU_TYPE_NAME("cortex-m3"),
         NULL
     };
+    MachineClass *mc = MACHINE_CLASS(oc);
 
     mc->desc = "ST STM32VLDISCOVERY (Cortex-M3)";
     mc->init = stm32vldiscovery_init;
     mc->valid_cpu_types = valid_cpu_types;
 }
 
-DEFINE_MACHINE("stm32vldiscovery", stm32vldiscovery_machine_init)
+static const TypeInfo stm32vldiscovery_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("stm32vldiscovery"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = stm32vldiscovery_machine_class_init,
+    },
+};
+
+DEFINE_TYPES(stm32vldiscovery_machine_types)
Signature · 1 line
2.47.1
Reviewed-by on the v1 series
#12 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 29 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

  hw/arm/bananapi_m2u.c      | 13 +++++++++++--
  hw/arm/cubieboard.c        | 13 +++++++++++--
  hw/arm/digic_boards.c      | 14 ++++++++++++--
  hw/arm/imx25_pdk.c         | 14 ++++++++++++--
  hw/arm/imx8mp-evk.c        | 15 +++++++++++++--
  hw/arm/integratorcp.c      | 16 +++++++++++++---
  hw/arm/kzm.c               | 14 ++++++++++++--
  hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++--
  hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++--
  hw/arm/msf2-som.c          | 13 +++++++++++--
  hw/arm/musicpal.c          | 16 +++++++++++++---
Quoted 9 lines
  hw/arm/netduino2.c         | 13 +++++++++++--
  hw/arm/netduinoplus2.c     | 13 +++++++++++--
  hw/arm/olimex-stm32-h405.c | 13 +++++++++++--
  hw/arm/orangepi.c          | 13 +++++++++++--
  hw/arm/sabrelite.c         | 14 ++++++++++++--
  hw/arm/stm32vldiscovery.c  | 13 +++++++++++--
  hw/core/null-machine.c     | 14 ++++++++++++--
  18 files changed, 213 insertions(+), 38 deletions(-)

Sounds good, for the whole series:

#13 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 29 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++--
hw/arm/cubieboard.c        | 13 +++++++++++--
hw/arm/digic_boards.c      | 14 ++++++++++++--
hw/arm/imx25_pdk.c         | 14 ++++++++++++--
hw/arm/imx8mp-evk.c        | 15 +++++++++++++--
hw/arm/integratorcp.c      | 16 +++++++++++++---
hw/arm/kzm.c               | 14 ++++++++++++--
hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++--
hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++--
hw/arm/msf2-som.c          | 13 +++++++++++--
hw/arm/musicpal.c          | 16 +++++++++++++---
Quoted 8 lines
hw/arm/netduino2.c         | 13 +++++++++++--
hw/arm/netduinoplus2.c     | 13 +++++++++++--
hw/arm/olimex-stm32-h405.c | 13 +++++++++++--
hw/arm/orangepi.c          | 13 +++++++++++--
hw/arm/sabrelite.c         | 14 ++++++++++++--
hw/arm/stm32vldiscovery.c  | 13 +++++++++++--
hw/core/null-machine.c     | 14 ++++++++++++--
18 files changed, 213 insertions(+), 38 deletions(-)

This is much longer and exposing boiler plate code. Is it possible instead to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden and not bring it back?

Regards,
BALATON Zoltan

#14 lore raw
Quoted 39 lines · BALATON Zoltan
Quoted 29 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++--
hw/arm/cubieboard.c        | 13 +++++++++++--
hw/arm/digic_boards.c      | 14 ++++++++++++--
hw/arm/imx25_pdk.c         | 14 ++++++++++++--
hw/arm/imx8mp-evk.c        | 15 +++++++++++++--
hw/arm/integratorcp.c      | 16 +++++++++++++---
hw/arm/kzm.c               | 14 ++++++++++++--
hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++--
hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++--
hw/arm/msf2-som.c          | 13 +++++++++++--
hw/arm/musicpal.c          | 16 +++++++++++++---
Quoted 8 lines
hw/arm/netduino2.c         | 13 +++++++++++--
hw/arm/netduinoplus2.c     | 13 +++++++++++--
hw/arm/olimex-stm32-h405.c | 13 +++++++++++--
hw/arm/orangepi.c          | 13 +++++++++++--
hw/arm/sabrelite.c         | 14 ++++++++++++--
hw/arm/stm32vldiscovery.c  | 13 +++++++++++--
hw/core/null-machine.c     | 14 ++++++++++++--
18 files changed, 213 insertions(+), 38 deletions(-)
Quoted 6 lines

This is much longer and exposing boiler plate code. Is it possible instead to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden and not bring it back?

We can eventually modify DEFINE_MACHINES, to take an additional interfaces parameter, and replace all call sites, with an empty list for all boards out of hw/arm.

As long as we avoid something like:
DEFINE_MACHINES_WITH_INTERFACE_1(...)
DEFINE_MACHINES_WITH_INTERFACE_2(...)
DEFINE_MACHINES_WITH_INTERFACE_3(...)
I'm ok with keeping the macro.

Would that work for you folks?

Quoted 2 lines

Regards,
BALATON Zoltan

#15 lore raw
Quoted 49 lines · Pierrick Bouvier
Quoted 39 lines · BALATON Zoltan
Quoted 36 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
  hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++-- hw/arm/cubieboard.c        | 13 +++++++++++-- hw/arm/digic_boards.c      | 14 ++++++++++++-- hw/arm/imx25_pdk.c         | 14 ++++++++++++-- hw/arm/imx8mp-evk.c        | 15 +++++++++++++-- hw/arm/integratorcp.c      | 16 +++++++++++++--- hw/arm/kzm.c               | 14 ++++++++++++-- hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++-- hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++-- hw/arm/msf2-som.c          | 13 +++++++++++-- hw/arm/musicpal.c          | 16 +++++++++++++--- hw/arm/netduino2.c         | 13 +++++++++++-- hw/arm/netduinoplus2.c     | 13 +++++++++++-- hw/arm/olimex-stm32-h405.c | 13 +++++++++++-- hw/arm/orangepi.c          | 13 +++++++++++-- hw/arm/sabrelite.c         | 14 ++++++++++++-- hw/arm/stm32vldiscovery.c  | 13 +++++++++++-- hw/core/null-machine.c     | 14 ++++++++++++--

Quoted 1 line
18 files changed, 213 insertions(+), 38 deletions(-)
Quoted 6 lines

This is much longer and exposing boiler plate code. Is it possible instead to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden and not bring it back?

We can eventually modify DEFINE_MACHINES, to take an additional interfaces parameter, and replace all call sites, with an empty list for all boards out of hw/arm.

Quoted 7 lines

As long as we avoid something like:
DEFINE_MACHINES_WITH_INTERFACE_1(...)
DEFINE_MACHINES_WITH_INTERFACE_2(...)
DEFINE_MACHINES_WITH_INTERFACE_3(...)
I'm ok with keeping the macro.

Would that work for you folks?

But then we'll want DEFINE_PPC32_MACHINE() -> DEFINE_MACHINES_WITH_INTERFACE_1() etc...

We want to eventually use declarative file to structure most of the machine boiler plate code. Maybe being momentarily verbose is acceptable...

#16 lore raw
Quoted 60 lines · Philippe Mathieu-Daudé
Quoted 59 lines · Pierrick Bouvier
Quoted 39 lines · BALATON Zoltan
Quoted 36 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
  hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++-- hw/arm/cubieboard.c        | 13 +++++++++++-- hw/arm/digic_boards.c      | 14 ++++++++++++-- hw/arm/imx25_pdk.c         | 14 ++++++++++++-- hw/arm/imx8mp-evk.c        | 15 +++++++++++++-- hw/arm/integratorcp.c      | 16 +++++++++++++--- hw/arm/kzm.c               | 14 ++++++++++++-- hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++-- hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++-- hw/arm/msf2-som.c          | 13 +++++++++++-- hw/arm/musicpal.c          | 16 +++++++++++++--- hw/arm/netduino2.c         | 13 +++++++++++-- hw/arm/netduinoplus2.c     | 13 +++++++++++-- hw/arm/olimex-stm32-h405.c | 13 +++++++++++-- hw/arm/orangepi.c          | 13 +++++++++++-- hw/arm/sabrelite.c         | 14 ++++++++++++-- hw/arm/stm32vldiscovery.c  | 13 +++++++++++-- hw/core/null-machine.c     | 14 ++++++++++++--

Quoted 1 line
18 files changed, 213 insertions(+), 38 deletions(-)
Quoted 8 lines

This is much longer and exposing boiler plate code. Is it possible instead
to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden
and not bring it back?

We can eventually modify DEFINE_MACHINES, to take an additional interfaces parameter, and replace all call sites, with an empty list for all boards out of hw/arm.

As long as we avoid something like:
DEFINE_MACHINES_WITH_INTERFACE_1(...)
DEFINE_MACHINES_WITH_INTERFACE_2(...)
DEFINE_MACHINES_WITH_INTERFACE_3(...)
I'm ok with keeping the macro.

Quoted 5 lines
Quoted 1 line

Would that work for you folks?

But then we'll want DEFINE_PPC32_MACHINE() ->
DEFINE_MACHINES_WITH_INTERFACE_1() etc...

We can see that later when touching other targets. For now, DEFINE_MACHINE is not used in a lot of places, so replacing call sites should be easy, and it will cover hw/arm, which is our point of interest now.

Quoted 3 lines

We want to eventually use declarative file to structure most of the machine boiler plate code. Maybe being momentarily verbose is acceptable...

#17 lore raw
Quoted 61 lines · Pierrick Bouvier
Quoted 60 lines · Philippe Mathieu-Daudé
Quoted 59 lines · Pierrick Bouvier
Quoted 39 lines · BALATON Zoltan
Quoted 36 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
   hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++-- hw/arm/cubieboard.c        | 13 +++++++++++-- hw/arm/digic_boards.c      | 14 ++++++++++++-- hw/arm/imx25_pdk.c         | 14 ++++++++++++-- hw/arm/imx8mp-evk.c        | 15 +++++++++++++-- hw/arm/integratorcp.c      | 16 +++++++++++++--- hw/arm/kzm.c               | 14 ++++++++++++-- hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++-- hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++-- hw/arm/msf2-som.c          | 13 +++++++++++-- hw/arm/musicpal.c          | 16 +++++++++++++--- hw/arm/netduino2.c         | 13 +++++++++++-- hw/arm/netduinoplus2.c     | 13 +++++++++++-- hw/arm/olimex-stm32-h405.c | 13 +++++++++++-- hw/arm/orangepi.c          | 13 +++++++++++-- hw/arm/sabrelite.c         | 14 ++++++++++++-- hw/arm/stm32vldiscovery.c  | 13 +++++++++++-- hw/core/null-machine.c     | 14 ++++++++++++--

Quoted 1 line
18 files changed, 213 insertions(+), 38 deletions(-)
Quoted 8 lines

This is much longer and exposing boiler plate code. Is it possible instead
to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden
and not bring it back?

We can eventually modify DEFINE_MACHINES, to take an additional interfaces parameter, and replace all call sites, with an empty list for all boards out of hw/arm.

As long as we avoid something like:
DEFINE_MACHINES_WITH_INTERFACE_1(...)
DEFINE_MACHINES_WITH_INTERFACE_2(...)
DEFINE_MACHINES_WITH_INTERFACE_3(...)
I'm ok with keeping the macro.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Would that work for you folks?

But then we'll want DEFINE_PPC32_MACHINE() ->
DEFINE_MACHINES_WITH_INTERFACE_1() etc...

We can see that later when touching other targets. For now, DEFINE_MACHINE is not used in a lot of places, so replacing call sites should be easy, and it will cover hw/arm, which is our point of interest now.

I concur and share the same goal, but here Zoltan is concerned about converting DEFINE_MACHINE to DEFINE_TYPES adds 12 lines of boilerplate code.

#18 lore raw
Quoted 68 lines · Philippe Mathieu-Daudé
Quoted 67 lines · Pierrick Bouvier
Quoted 65 lines · Philippe Mathieu-Daudé
Quoted 53 lines · Pierrick Bouvier
Quoted 39 lines · BALATON Zoltan
Quoted 36 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
   hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++-- hw/arm/cubieboard.c        | 13 +++++++++++-- hw/arm/digic_boards.c      | 14 ++++++++++++-- hw/arm/imx25_pdk.c         | 14 ++++++++++++-- hw/arm/imx8mp-evk.c        | 15 +++++++++++++-- hw/arm/integratorcp.c      | 16 +++++++++++++--- hw/arm/kzm.c               | 14 ++++++++++++-- hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++-- hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++-- hw/arm/msf2-som.c          | 13 +++++++++++-- hw/arm/musicpal.c          | 16 +++++++++++++--- hw/arm/netduino2.c         | 13 +++++++++++-- hw/arm/netduinoplus2.c     | 13 +++++++++++-- hw/arm/olimex-stm32-h405.c | 13 +++++++++++-- hw/arm/orangepi.c          | 13 +++++++++++-- hw/arm/sabrelite.c         | 14 ++++++++++++-- hw/arm/stm32vldiscovery.c  | 13 +++++++++++-- hw/core/null-machine.c     | 14 ++++++++++++--

Quoted 1 line
18 files changed, 213 insertions(+), 38 deletions(-)
Quoted 8 lines

This is much longer and exposing boiler plate code. Is it possible instead
to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden
and not bring it back?

We can eventually modify DEFINE_MACHINES, to take an additional interfaces parameter, and replace all call sites, with an empty list for all boards out of hw/arm.

Quoted 7 lines

As long as we avoid something like:
DEFINE_MACHINES_WITH_INTERFACE_1(...)
DEFINE_MACHINES_WITH_INTERFACE_2(...)
DEFINE_MACHINES_WITH_INTERFACE_3(...)
I'm ok with keeping the macro.

Would that work for you folks?

But then we'll want DEFINE_PPC32_MACHINE() ->
DEFINE_MACHINES_WITH_INTERFACE_1() etc...

Quoted 8 lines
Quoted 4 lines

We can see that later when touching other targets. For now, DEFINE_MACHINE is not used in a lot of places, so replacing call sites should be easy, and it will cover hw/arm, which is our point of interest now.

I concur and share the same goal, but here Zoltan is concerned about converting DEFINE_MACHINE to DEFINE_TYPES adds 12 lines of boilerplate code.

If I understand correctly, Zoltan issue is that we remove usage of DEFINE_MACHINE, and put boilerplate for type definition instead. So hiding boilerplate behind the macro would be ok, thus my proposal.

Zoltan, could you please confirm in which way you were qualifying this as boilerplate?

Thanks,
Pierrick

#19 lore raw
Quoted 74 lines · Pierrick Bouvier
Quoted 73 lines · Philippe Mathieu-Daudé
Quoted 71 lines · Pierrick Bouvier
Quoted 60 lines · Philippe Mathieu-Daudé
Quoted 59 lines · Pierrick Bouvier
Quoted 39 lines · BALATON Zoltan
Quoted 36 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
   hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++-- hw/arm/cubieboard.c        | 13 +++++++++++-- hw/arm/digic_boards.c      | 14 ++++++++++++-- hw/arm/imx25_pdk.c         | 14 ++++++++++++-- hw/arm/imx8mp-evk.c        | 15 +++++++++++++-- hw/arm/integratorcp.c      | 16 +++++++++++++--- hw/arm/kzm.c               | 14 ++++++++++++-- hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++-- hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++-- hw/arm/msf2-som.c          | 13 +++++++++++-- hw/arm/musicpal.c          | 16 +++++++++++++--- hw/arm/netduino2.c         | 13 +++++++++++-- hw/arm/netduinoplus2.c     | 13 +++++++++++-- hw/arm/olimex-stm32-h405.c | 13 +++++++++++-- hw/arm/orangepi.c          | 13 +++++++++++-- hw/arm/sabrelite.c         | 14 ++++++++++++-- hw/arm/stm32vldiscovery.c  | 13 +++++++++++-- hw/core/null-machine.c     | 14 ++++++++++++--

Quoted 1 line
18 files changed, 213 insertions(+), 38 deletions(-)
Quoted 8 lines

This is much longer and exposing boiler plate code. Is it possible instead
to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden
and not bring it back?

We can eventually modify DEFINE_MACHINES, to take an additional interfaces parameter, and replace all call sites, with an empty list for all boards out of hw/arm.

As long as we avoid something like:
DEFINE_MACHINES_WITH_INTERFACE_1(...)
DEFINE_MACHINES_WITH_INTERFACE_2(...)
DEFINE_MACHINES_WITH_INTERFACE_3(...)
I'm ok with keeping the macro.

Quoted 5 lines
Quoted 1 line

Would that work for you folks?

But then we'll want DEFINE_PPC32_MACHINE() ->
DEFINE_MACHINES_WITH_INTERFACE_1() etc...

We can see that later when touching other targets. For now, DEFINE_MACHINE is not used in a lot of places, so replacing call sites should be easy, and it will cover hw/arm, which is our point of interest now.

Quoted 8 lines
Quoted 3 lines

I concur and share the same goal, but here Zoltan is concerned about converting DEFINE_MACHINE to DEFINE_TYPES adds 12 lines of boilerplate code.

If I understand correctly, Zoltan issue is that we remove usage of DEFINE_MACHINE, and put boilerplate for type definition instead. So hiding boilerplate behind the macro would be ok, thus my proposal.

Zoltan, could you please confirm in which way you were qualifying this as boilerplate?

See commit f84203a8c22 and if I remember correctly there was some discussion around that on the list where this came from which was partly started by me being annoyed to have half of a device model consiting of just boiler plate. I would not like that to come back if can be avoided as having these macros make the models much more comprehensive for new people not having to go through all the QOM boiler plate to see the actual functionality.

Regards,
BALATON Zoltan

#20 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 56 lines · Philippe Mathieu-Daudé
Quoted 55 lines · Pierrick Bouvier
Quoted 39 lines · BALATON Zoltan
Quoted 36 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
  hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++-- hw/arm/cubieboard.c        | 13 +++++++++++-- hw/arm/digic_boards.c      | 14 ++++++++++++-- hw/arm/imx25_pdk.c         | 14 ++++++++++++-- hw/arm/imx8mp-evk.c        | 15 +++++++++++++-- hw/arm/integratorcp.c      | 16 +++++++++++++--- hw/arm/kzm.c               | 14 ++++++++++++-- hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++-- hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++-- hw/arm/msf2-som.c          | 13 +++++++++++-- hw/arm/musicpal.c          | 16 +++++++++++++--- hw/arm/netduino2.c         | 13 +++++++++++-- hw/arm/netduinoplus2.c     | 13 +++++++++++-- hw/arm/olimex-stm32-h405.c | 13 +++++++++++-- hw/arm/orangepi.c          | 13 +++++++++++-- hw/arm/sabrelite.c         | 14 ++++++++++++-- hw/arm/stm32vldiscovery.c  | 13 +++++++++++-- hw/core/null-machine.c     | 14 ++++++++++++--

Quoted 1 line
18 files changed, 213 insertions(+), 38 deletions(-)
Quoted 6 lines

This is much longer and exposing boiler plate code. Is it possible instead to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden and not bring it back?

We can eventually modify DEFINE_MACHINES, to take an additional interfaces parameter, and replace all call sites, with an empty list for all boards out of hw/arm.

As long as we avoid something like:
DEFINE_MACHINES_WITH_INTERFACE_1(...)
DEFINE_MACHINES_WITH_INTERFACE_2(...)
DEFINE_MACHINES_WITH_INTERFACE_3(...)
I'm ok with keeping the macro.

Quoted 7 lines
Quoted 1 line

Would that work for you folks?

But then we'll want DEFINE_PPC32_MACHINE() -> DEFINE_MACHINES_WITH_INTERFACE_1() etc...

We want to eventually use declarative file to structure most of the machine boiler plate code. Maybe being momentarily verbose is acceptable...

Moments in QEMU can last years... I was thinking about similar to OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES. Would something like that be possible for DEFINE_MACHINE too?

Regards,
BALATON Zoltan

#21 lore raw
Quoted 64 lines · BALATON Zoltan
Quoted 63 lines · Philippe Mathieu-Daudé
Quoted 51 lines · Pierrick Bouvier
Quoted 39 lines · BALATON Zoltan
Quoted 36 lines · Philippe Mathieu-Daudé

While DEFINE_MACHINE() is a succinct macro, it doesn't allow registering QOM interfaces to the defined machine. Convert to the generic DEFINE_TYPES() in preparation to register interfaces.

Philippe Mathieu-Daudé (11):
  hw/core/null-machine: Define machine as generic QOM type hw/arm/bananapi: Define machine as generic QOM type hw/arm/cubieboard: Define machine as generic QOM type hw/arm/digic: Define machine as generic QOM type hw/arm/imx: Define machines as generic QOM types hw/arm/integratorcp: Define machine as generic QOM type hw/arm/kzm: Define machine as generic QOM type hw/arm/msf2: Define machine as generic QOM type hw/arm/musicpal: Define machine as generic QOM type hw/arm/orangepi: Define machine as generic QOM type hw/arm/stm32: Define machines as generic QOM types

hw/arm/bananapi_m2u.c      | 13 +++++++++++-- hw/arm/cubieboard.c        | 13 +++++++++++-- hw/arm/digic_boards.c      | 14 ++++++++++++-- hw/arm/imx25_pdk.c         | 14 ++++++++++++-- hw/arm/imx8mp-evk.c        | 15 +++++++++++++-- hw/arm/integratorcp.c      | 16 +++++++++++++--- hw/arm/kzm.c               | 14 ++++++++++++-- hw/arm/mcimx6ul-evk.c      | 15 +++++++++++++-- hw/arm/mcimx7d-sabre.c     | 15 +++++++++++++-- hw/arm/msf2-som.c          | 13 +++++++++++-- hw/arm/musicpal.c          | 16 +++++++++++++--- hw/arm/netduino2.c         | 13 +++++++++++-- hw/arm/netduinoplus2.c     | 13 +++++++++++-- hw/arm/olimex-stm32-h405.c | 13 +++++++++++-- hw/arm/orangepi.c          | 13 +++++++++++-- hw/arm/sabrelite.c         | 14 ++++++++++++-- hw/arm/stm32vldiscovery.c  | 13 +++++++++++-- hw/core/null-machine.c     | 14 ++++++++++++--

Quoted 1 line
18 files changed, 213 insertions(+), 38 deletions(-)
Quoted 6 lines

This is much longer and exposing boiler plate code. Is it possible instead to change DEFINE_MACHINE or add another similar macro that allows specifying more details such as class state type and interfaces like we already have for OBJECT_DEFINE macros to keep the boiler plate code hidden and not bring it back?

We can eventually modify DEFINE_MACHINES, to take an additional interfaces parameter, and replace all call sites, with an empty list for all boards out of hw/arm.

Quoted 7 lines

As long as we avoid something like:
DEFINE_MACHINES_WITH_INTERFACE_1(...)
DEFINE_MACHINES_WITH_INTERFACE_2(...)
DEFINE_MACHINES_WITH_INTERFACE_3(...)
I'm ok with keeping the macro.

Would that work for you folks?

But then we'll want DEFINE_PPC32_MACHINE() ->
DEFINE_MACHINES_WITH_INTERFACE_1() etc...

Quoted 8 lines
Quoted 3 lines

We want to eventually use declarative file to structure most of the machine boiler plate code. Maybe being momentarily verbose is acceptable...

Moments in QEMU can last years... I was thinking about similar to OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES. Would something like that be possible for DEFINE_MACHINE too?

We can just add the list of interfaces the machine is implementing as an additional parameter to DEFINE_MACHINE, and this solves the problem without adding any boilerplate.

Ultimately, we'll need to tag all machines to mention targets supported, so this information has to be written somewhere.

Quoted 2 lines

Regards,
BALATON Zoltan