diff mbox

[v3,6/7] Use DEFINE_MACHINE to register all machines

Message ID 55FD1C62.7060402@suse.de
State New
Headers show

Commit Message

Andreas Färber Sept. 19, 2015, 8:27 a.m. UTC
Am 19.09.2015 um 10:13 schrieb Andreas Färber:
> Am 04.09.2015 um 20:37 schrieb Eduardo Habkost:
>> Convert all machines to use DEFINE_MACHINE instead of QEMUMachine
>> automatically using a script.
>>
>> Cc: Richard Henderson <rth@twiddle.net>
>> Cc: Peter Maydell <peter.maydell@linaro.org>
>> Cc: Li Guang <lig.fnst@cn.fujitsu.com>
>> Cc: Antony Pavlov <antonynpavlov@gmail.com>
>> Cc: Evgeny Voevodin <e.voevodin@samsung.com>
>> Cc: Maksim Kozlov <m.kozlov@samsung.com>
>> Cc: Igor Mitsyanko <i.mitsyanko@gmail.com>
>> Cc: Dmitry Solodkiy <d.solodkiy@samsung.com>
>> Cc: Rob Herring <robh@kernel.org>
>> Cc: Peter Chubb <peter.chubb@nicta.com.au>
>> Cc: Jan Kiszka <jan.kiszka@web.de>
>> Cc: Andrzej Zaborowski <balrogg@gmail.com>
>> Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
>> Cc: Michael Walle <michael@walle.cc>
>> Cc: Aurelien Jarno <aurelien@aurel32.net>
>> Cc: Leon Alrae <leon.alrae@imgtec.com>
>> Cc: "Hervé Poussineau" <hpoussin@reactos.org>
>> Cc: Jia Liu <proljc@gmail.com>
>> Cc: Alexander Graf <agraf@suse.de>
>> Cc: Scott Wood <scottwood@freescale.com>
>> Cc: "Andreas Färber" <andreas.faerber@web.de>
>> Cc: Magnus Damm <magnus.damm@gmail.com>
>> Cc: Fabien Chouteau <chouteau@adacore.com>
>> Cc: Blue Swirl <blauwirbel@gmail.com>
>> Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
>> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
>> Cc: Max Filippov <jcmvbkbc@gmail.com>
>> Cc: qemu-ppc@nongnu.org
>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>> ---
>> Changes v1 -> v2:
>> * Fix trailing spaces and newlines
>> * Don't touch "//" comments on lines that we are not changing
>> * Break long lines manually
>>
>> Changes v2 -> v3:
>> * Replace "machine_machine" with "machine" in new variable and function
>>   names.
>>   Suggested-by: Michael Walle <michael@walle.cc>
>> * Eliminate empty mips_malta_machine_init() and sun4u_machine_init()
>>   functions
> 
> In most (but not all) cases the last DEFINE_MACHINE(...) added a white
> line, dropped manually.
> 
> Your script also always added a semicolon after DEFINE_MACHINE(), even
> when the original machine_init() did not have it. Cleaned up manually.
> 
> This scripted approach also regresses files with multiple machines to
> now have one module init function per machine rather than one per file.
> 
> I'm also not clear on why you chose to diverge from devices in having a
> machine-specific init function with MachineClass *mc arg rather than
> having ObjectClass *oc, void *data and having a local mc variable.
> 
> But getting this conversion done to drop the old infrastructure seems
> more important, and this can be revisited afterwards.

The following conversion has become necessary on top (squashing):

Regards,
Andreas

Comments

Andreas Färber Sept. 19, 2015, 8:28 a.m. UTC | #1
Am 19.09.2015 um 10:27 schrieb Andreas Färber:
> Am 19.09.2015 um 10:13 schrieb Andreas Färber:
>> Am 04.09.2015 um 20:37 schrieb Eduardo Habkost:
>>> Convert all machines to use DEFINE_MACHINE instead of QEMUMachine
>>> automatically using a script.
>>>
>>> Cc: Richard Henderson <rth@twiddle.net>
>>> Cc: Peter Maydell <peter.maydell@linaro.org>
>>> Cc: Li Guang <lig.fnst@cn.fujitsu.com>
>>> Cc: Antony Pavlov <antonynpavlov@gmail.com>
>>> Cc: Evgeny Voevodin <e.voevodin@samsung.com>
>>> Cc: Maksim Kozlov <m.kozlov@samsung.com>
>>> Cc: Igor Mitsyanko <i.mitsyanko@gmail.com>
>>> Cc: Dmitry Solodkiy <d.solodkiy@samsung.com>
>>> Cc: Rob Herring <robh@kernel.org>
>>> Cc: Peter Chubb <peter.chubb@nicta.com.au>
>>> Cc: Jan Kiszka <jan.kiszka@web.de>
>>> Cc: Andrzej Zaborowski <balrogg@gmail.com>
>>> Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
>>> Cc: Michael Walle <michael@walle.cc>
>>> Cc: Aurelien Jarno <aurelien@aurel32.net>
>>> Cc: Leon Alrae <leon.alrae@imgtec.com>
>>> Cc: "Hervé Poussineau" <hpoussin@reactos.org>
>>> Cc: Jia Liu <proljc@gmail.com>
>>> Cc: Alexander Graf <agraf@suse.de>
>>> Cc: Scott Wood <scottwood@freescale.com>
>>> Cc: "Andreas Färber" <andreas.faerber@web.de>
>>> Cc: Magnus Damm <magnus.damm@gmail.com>
>>> Cc: Fabien Chouteau <chouteau@adacore.com>
>>> Cc: Blue Swirl <blauwirbel@gmail.com>
>>> Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
>>> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
>>> Cc: Max Filippov <jcmvbkbc@gmail.com>
>>> Cc: qemu-ppc@nongnu.org
>>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>>> ---
>>> Changes v1 -> v2:
>>> * Fix trailing spaces and newlines
>>> * Don't touch "//" comments on lines that we are not changing
>>> * Break long lines manually
>>>
>>> Changes v2 -> v3:
>>> * Replace "machine_machine" with "machine" in new variable and function
>>>   names.
>>>   Suggested-by: Michael Walle <michael@walle.cc>
>>> * Eliminate empty mips_malta_machine_init() and sun4u_machine_init()
>>>   functions
>>
>> In most (but not all) cases the last DEFINE_MACHINE(...) added a white
>> line, dropped manually.
>>
>> Your script also always added a semicolon after DEFINE_MACHINE(), even
>> when the original machine_init() did not have it. Cleaned up manually.
>>
>> This scripted approach also regresses files with multiple machines to
>> now have one module init function per machine rather than one per file.
>>
>> I'm also not clear on why you chose to diverge from devices in having a
>> machine-specific init function with MachineClass *mc arg rather than
>> having ObjectClass *oc, void *data and having a local mc variable.
>>
>> But getting this conversion done to drop the old infrastructure seems
>> more important, and this can be revisited afterwards.
> 
> The following conversion has become necessary on top (squashing):
> 
> diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c
> index c34667f..4250114 100644
> --- a/hw/arm/imx25_pdk.c
> +++ b/hw/arm/imx25_pdk.c
> @@ -145,15 +145,10 @@ static void imx25_pdk_init(MachineState *machine)
>      }
>  }
> 
> -static QEMUMachine imx25_pdk_machine = {
> -    .name = "imx25_pdk",
> -    .desc = "ARM i.MX25 PDK board (ARM926)",
> -    .init = imx25_pdk_init,
> -};
> -
> -static void imx25_pdk_machine_init(void)
> +static void imx25_pdk_machine_init(MachineClass *mc)
>  {
> -    qemu_register_machine(&imx25_pdk_machine);
> +    mc->desc = "ARM i.MX25 PDK board (ARM926)";
> +    mc->init = imx25_pdk_init;
>  }
> 
> -machine_init(imx25_pdk_machine_init)

+DEFINE_MACHINE("imx25_pdk", imx25_pdk_machine_init)

> 
> Regards,
> Andreas
>
diff mbox

Patch

diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c
index c34667f..4250114 100644
--- a/hw/arm/imx25_pdk.c
+++ b/hw/arm/imx25_pdk.c
@@ -145,15 +145,10 @@  static void imx25_pdk_init(MachineState *machine)
     }
 }

-static QEMUMachine imx25_pdk_machine = {
-    .name = "imx25_pdk",
-    .desc = "ARM i.MX25 PDK board (ARM926)",
-    .init = imx25_pdk_init,
-};
-
-static void imx25_pdk_machine_init(void)
+static void imx25_pdk_machine_init(MachineClass *mc)
 {
-    qemu_register_machine(&imx25_pdk_machine);
+    mc->desc = "ARM i.MX25 PDK board (ARM926)";
+    mc->init = imx25_pdk_init;
 }

-machine_init(imx25_pdk_machine_init)