diff mbox series

[RFC,v5,04/21] hw/core/null-machine: Define machine as generic QOM type

Message ID 20250424222112.36194-5-philmd@linaro.org
State New
Headers show
Series single-binary: Make hw/arm/ common | expand

Commit Message

Philippe Mathieu-Daudé April 24, 2025, 10:20 p.m. UTC
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.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/core/null-machine.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Pierrick Bouvier April 24, 2025, 10:30 p.m. UTC | #1
On 4/24/25 15:20, Philippe Mathieu-Daudé wrote:
> 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.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/core/null-machine.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>

Maybe you can integrate your other series changing existing arm machines 
also, so it's easy to apply this series without the other dependency.
Philippe Mathieu-Daudé April 24, 2025, 10:47 p.m. UTC | #2
On 25/4/25 00:30, Pierrick Bouvier wrote:
> On 4/24/25 15:20, Philippe Mathieu-Daudé wrote:
>> 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.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   hw/core/null-machine.c | 14 ++++++++++++--
>>   1 file changed, 12 insertions(+), 2 deletions(-)
>>
> 
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> 
> Maybe you can integrate your other series changing existing arm machines 
> also, so it's easy to apply this series without the other dependency.

I discarded the other series due to Zoltan comments, and only
salvaged this single patch (the others aren't needed since this
series introduces and uses DEFINE_MACHINE_WITH_INTERFACES).
Pierrick Bouvier April 24, 2025, 10:49 p.m. UTC | #3
On 4/24/25 15:47, Philippe Mathieu-Daudé wrote:
> On 25/4/25 00:30, Pierrick Bouvier wrote:
>> On 4/24/25 15:20, Philippe Mathieu-Daudé wrote:
>>> 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.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>>    hw/core/null-machine.c | 14 ++++++++++++--
>>>    1 file changed, 12 insertions(+), 2 deletions(-)
>>>
>>
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>
>> Maybe you can integrate your other series changing existing arm machines
>> also, so it's easy to apply this series without the other dependency.
> 
> I discarded the other series due to Zoltan comments, and only
> salvaged this single patch (the others aren't needed since this
> series introduces and uses DEFINE_MACHINE_WITH_INTERFACES).
> 

Thanks, I noticed that later while reading the rest of this series.
diff mbox series

Patch

diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index a6e477a2d88..3e03771d570 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -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, const 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)