Skip to contentSkip to conversation

: Improve machine type functions

PATCH Superseded Luiz Capitulino 4 participants 22 messages Feb 24, 2012

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover : Improve machine type functions

I was reading some related code yesterday and couldn't resist improving this. Not sure if this is aligned with any possible QOM work in this area, but I'm posting this anyway...

 Makefile.target               |    3 +-
 hw/alpha_dp264.c              |    2 +-
 hw/an5206.c                   |    2 +-
 hw/axis_dev88.c               |    2 +-
 hw/boards.c                   |   86 +++++++++++++++++++++++++++++++++++++++++
 hw/boards.h                   |    9 +++-
 hw/collie.c                   |    2 +-
 hw/dummy_m68k.c               |    2 +-
 hw/exynos4_boards.c           |    4 +-
 hw/gumstix.c                  |    4 +-
 hw/highbank.c                 |    2 +-
 hw/integratorcp.c             |    2 +-
 hw/leon3.c                    |    2 +-
 hw/lm32_boards.c              |    4 +-
 hw/mainstone.c                |    2 +-
 hw/mcf5208.c                  |    2 +-
 hw/milkymist.c                |    2 +-
 hw/mips_fulong2e.c            |    2 +-
 hw/mips_jazz.c                |    4 +-
 hw/mips_malta.c               |    2 +-
 hw/mips_mipssim.c             |    2 +-
 hw/mips_r4k.c                 |    2 +-
 hw/musicpal.c                 |    2 +-
 hw/nseries.c                  |    4 +-
 hw/omap_sx1.c                 |    4 +-
 hw/palm.c                     |    2 +-
 hw/pc_piix.c                  |   20 +++++-----
 hw/pc_sysfw.c                 |    2 +-
 hw/petalogix_ml605_mmu.c      |    2 +-
 hw/petalogix_s3adsp1800_mmu.c |    2 +-
 hw/ppc405_boards.c            |    4 +-
 hw/ppc440_bamboo.c            |    2 +-
 hw/ppc_newworld.c             |    2 +-
 hw/ppc_oldworld.c             |    2 +-
 hw/ppc_prep.c                 |    2 +-
 hw/ppce500_mpc8544ds.c        |    2 +-
 hw/r2d.c                      |    2 +-
 hw/realview.c                 |    8 ++--
 hw/s390-virtio.c              |    2 +-
 hw/shix.c                     |    2 +-
 hw/spapr.c                    |    2 +-
 hw/spitz.c                    |    8 ++--
 hw/stellaris.c                |    4 +-
 hw/sun4m.c                    |   24 ++++++------
 hw/sun4u.c                    |    6 +-
 hw/tosa.c                     |    2 +-
 hw/versatilepb.c              |    4 +-
 hw/vexpress.c                 |    4 +-
 hw/virtex_ml507.c             |    2 +-
 hw/xen_machine_pv.c           |    2 +-
 hw/xtensa_lx60.c              |    4 +-
 hw/xtensa_sim.c               |    2 +-
 hw/z2.c                       |    2 +-
 vl.c                          |   65 +------------------------------
 54 files changed, 184 insertions(+), 157 deletions(-)
#1 lore raw

PATCH 1/5 boards: qemu_register_machine(): return void

It never fails.

---
 hw/boards.h |    2 +-
 vl.c        |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
hw/boards.h +1 -1
index 667177d..7a9899f 100644
@@ -31,7 +31,7 @@ typedef struct QEMUMachine {
     struct QEMUMachine *next;
 } QEMUMachine;
 
-int qemu_register_machine(QEMUMachine *m);
+void qemu_register_machine(QEMUMachine *m);
 QEMUMachine *find_default_machine(void);
 
 extern QEMUMachine *current_machine;
vl.c +1 -2
index 7a8cc08..45fc3b5 100644
@@ -1163,7 +1163,7 @@ void pcmcia_info(Monitor *mon)
 static QEMUMachine *first_machine = NULL;
 QEMUMachine *current_machine = NULL;
 
-int qemu_register_machine(QEMUMachine *m)
+void qemu_register_machine(QEMUMachine *m)
 {
     QEMUMachine **pm;
     pm = &first_machine;
@@ -1171,7 +1171,6 @@ int qemu_register_machine(QEMUMachine *m)
         pm = &(*pm)->next;
     m->next = NULL;
     *pm = m;
-    return 0;
 }
 
 static QEMUMachine *find_machine(const char *name)
Signature · 1 line
1.7.9.111.gf3fb0.dirty
Reviewed-by on v1 1/5
#2 lore raw

Re: [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 1 line

It never fails.

...and is never checked. Low-impact cleanup, thanks.

Quoted 2 lines

Andreas

Quoted 39 lines
---
 hw/boards.h |    2 +-
 vl.c        |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
hw/boards.h +1 -1
index 667177d..7a9899f 100644
@@ -31,7 +31,7 @@ typedef struct QEMUMachine {
     struct QEMUMachine *next;
 } QEMUMachine;
 
-int qemu_register_machine(QEMUMachine *m);
+void qemu_register_machine(QEMUMachine *m);
 QEMUMachine *find_default_machine(void);
 
 extern QEMUMachine *current_machine;
vl.c +1 -2
index 7a8cc08..45fc3b5 100644
@@ -1163,7 +1163,7 @@ void pcmcia_info(Monitor *mon)
 static QEMUMachine *first_machine = NULL;
 QEMUMachine *current_machine = NULL;
 
-int qemu_register_machine(QEMUMachine *m)
+void qemu_register_machine(QEMUMachine *m)
 {
     QEMUMachine **pm;
     pm = &first_machine;
@@ -1171,7 +1171,6 @@ int qemu_register_machine(QEMUMachine *m)
         pm = &(*pm)->next;
     m->next = NULL;
     *pm = m;
-    return 0;
 }
 
 static QEMUMachine *find_machine(const char *name)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw

PATCH 2/5 boards: rename machine type functions

In reply to Luiz Capitulino

Perform the following renames:

o qemu_register_machine() -> machine_register()
o find_machine() -> machine_find()
o find_default_machine() -> machine_find_default()

---
 hw/alpha_dp264.c              |    2 +-
 hw/an5206.c                   |    2 +-
 hw/axis_dev88.c               |    2 +-
 hw/boards.h                   |    4 ++--
 hw/collie.c                   |    2 +-
 hw/dummy_m68k.c               |    2 +-
 hw/exynos4_boards.c           |    4 ++--
 hw/gumstix.c                  |    4 ++--
 hw/highbank.c                 |    2 +-
 hw/integratorcp.c             |    2 +-
 hw/leon3.c                    |    2 +-
 hw/lm32_boards.c              |    4 ++--
 hw/mainstone.c                |    2 +-
 hw/mcf5208.c                  |    2 +-
 hw/milkymist.c                |    2 +-
 hw/mips_fulong2e.c            |    2 +-
 hw/mips_jazz.c                |    4 ++--
 hw/mips_malta.c               |    2 +-
 hw/mips_mipssim.c             |    2 +-
 hw/mips_r4k.c                 |    2 +-
 hw/musicpal.c                 |    2 +-
 hw/nseries.c                  |    4 ++--
 hw/omap_sx1.c                 |    4 ++--
 hw/palm.c                     |    2 +-
 hw/pc_piix.c                  |   20 ++++++++++----------
 hw/pc_sysfw.c                 |    2 +-
 hw/petalogix_ml605_mmu.c      |    2 +-
 hw/petalogix_s3adsp1800_mmu.c |    2 +-
 hw/ppc405_boards.c            |    4 ++--
 hw/ppc440_bamboo.c            |    2 +-
 hw/ppc_newworld.c             |    2 +-
 hw/ppc_oldworld.c             |    2 +-
 hw/ppc_prep.c                 |    2 +-
 hw/ppce500_mpc8544ds.c        |    2 +-
 hw/r2d.c                      |    2 +-
 hw/realview.c                 |    8 ++++----
 hw/s390-virtio.c              |    2 +-
 hw/shix.c                     |    2 +-
 hw/spapr.c                    |    2 +-
 hw/spitz.c                    |    8 ++++----
 hw/stellaris.c                |    4 ++--
 hw/sun4m.c                    |   24 ++++++++++++------------
 hw/sun4u.c                    |    6 +++---
 hw/tosa.c                     |    2 +-
 hw/versatilepb.c              |    4 ++--
 hw/vexpress.c                 |    4 ++--
 hw/virtex_ml507.c             |    2 +-
 hw/xen_machine_pv.c           |    2 +-
 hw/xtensa_lx60.c              |    4 ++--
 hw/xtensa_sim.c               |    2 +-
 hw/z2.c                       |    2 +-
 vl.c                          |   10 +++++-----
 52 files changed, 96 insertions(+), 96 deletions(-)
hw/alpha_dp264.c +1 -1
index ea0fd95..21f7729 100644
@@ -174,7 +174,7 @@ static QEMUMachine clipper_machine = {
 
 static void clipper_machine_init(void)
 {
-    qemu_register_machine(&clipper_machine);
+    machine_register(&clipper_machine);
 }
 
 machine_init(clipper_machine_init);
hw/an5206.c +1 -1
index d57306d..5361576 100644
@@ -90,7 +90,7 @@ static QEMUMachine an5206_machine = {
 
 static void an5206_machine_init(void)
 {
-    qemu_register_machine(&an5206_machine);
+    machine_register(&an5206_machine);
 }
 
 machine_init(an5206_machine_init);
hw/axis_dev88.c +1 -1
index c9301fd..549aaa5 100644
@@ -356,7 +356,7 @@ static QEMUMachine axisdev88_machine = {
 
 static void axisdev88_machine_init(void)
 {
-    qemu_register_machine(&axisdev88_machine);
+    machine_register(&axisdev88_machine);
 }
 
 machine_init(axisdev88_machine_init);
hw/boards.h +2 -2
index 7a9899f..098cbb7 100644
@@ -31,8 +31,8 @@ typedef struct QEMUMachine {
     struct QEMUMachine *next;
 } QEMUMachine;
 
-void qemu_register_machine(QEMUMachine *m);
-QEMUMachine *find_default_machine(void);
+void machine_register(QEMUMachine *m);
+QEMUMachine *machine_find_default(void);
 
 extern QEMUMachine *current_machine;
 
hw/collie.c +1 -1
index 42f4310..cdcf722 100644
@@ -65,7 +65,7 @@ static QEMUMachine collie_machine = {
 
 static void collie_machine_init(void)
 {
-    qemu_register_machine(&collie_machine);
+    machine_register(&collie_machine);
 }
 
 machine_init(collie_machine_init)
hw/dummy_m68k.c +1 -1
index e3c5740..30562bb 100644
@@ -77,7 +77,7 @@ static QEMUMachine dummy_m68k_machine = {
 
 static void dummy_m68k_machine_init(void)
 {
-    qemu_register_machine(&dummy_m68k_machine);
+    machine_register(&dummy_m68k_machine);
 }
 
 machine_init(dummy_m68k_machine_init);
hw/exynos4_boards.c +2 -2
index 553a02b..5b1e717 100644
@@ -170,8 +170,8 @@ static QEMUMachine exynos4_machines[EXYNOS4_NUM_OF_BOARDS] = {
 
 static void exynos4_machine_init(void)
 {
-    qemu_register_machine(&exynos4_machines[EXYNOS4_BOARD_NURI]);
-    qemu_register_machine(&exynos4_machines[EXYNOS4_BOARD_SMDKC210]);
+    machine_register(&exynos4_machines[EXYNOS4_BOARD_NURI]);
+    machine_register(&exynos4_machines[EXYNOS4_BOARD_SMDKC210]);
 }
 
 machine_init(exynos4_machine_init);
hw/gumstix.c +2 -2
index 13a36ea..60a00eb 100644
@@ -137,8 +137,8 @@ static QEMUMachine verdex_machine = {
 
 static void gumstix_machine_init(void)
 {
-    qemu_register_machine(&connex_machine);
-    qemu_register_machine(&verdex_machine);
+    machine_register(&connex_machine);
+    machine_register(&verdex_machine);
 }
 
 machine_init(gumstix_machine_init);
hw/highbank.c +1 -1
index 489c00e..aeb3553 100644
@@ -332,7 +332,7 @@ static QEMUMachine highbank_machine = {
 
 static void highbank_machine_init(void)
 {
-    qemu_register_machine(&highbank_machine);
+    machine_register(&highbank_machine);
 }
 
 machine_init(highbank_machine_init);
hw/integratorcp.c +1 -1
index 5b06c81..2ec9e7b 100644
@@ -512,7 +512,7 @@ static QEMUMachine integratorcp_machine = {
 
 static void integratorcp_machine_init(void)
 {
-    qemu_register_machine(&integratorcp_machine);
+    machine_register(&integratorcp_machine);
 }
 
 machine_init(integratorcp_machine_init);
hw/leon3.c +1 -1
index 71d79a6..13677b1 100644
@@ -217,7 +217,7 @@ QEMUMachine leon3_generic_machine = {
 
 static void leon3_machine_init(void)
 {
-    qemu_register_machine(&leon3_generic_machine);
+    machine_register(&leon3_generic_machine);
 }
 
 machine_init(leon3_machine_init);
hw/lm32_boards.c +2 -2
index 3cdf120..3ebb0b1 100644
@@ -298,8 +298,8 @@ static QEMUMachine lm32_uclinux_machine = {
 
 static void lm32_machine_init(void)
 {
-    qemu_register_machine(&lm32_uclinux_machine);
-    qemu_register_machine(&lm32_evr_machine);
+    machine_register(&lm32_uclinux_machine);
+    machine_register(&lm32_evr_machine);
 }
 
 machine_init(lm32_machine_init);
hw/mainstone.c +1 -1
index 27f5900..bc49f45 100644
@@ -188,7 +188,7 @@ static QEMUMachine mainstone2_machine = {
 
 static void mainstone_machine_init(void)
 {
-    qemu_register_machine(&mainstone2_machine);
+    machine_register(&mainstone2_machine);
 }
 
 machine_init(mainstone_machine_init);
hw/mcf5208.c +1 -1
index aa11a75..c45db6f 100644
@@ -296,7 +296,7 @@ static QEMUMachine mcf5208evb_machine = {
 
 static void mcf5208evb_machine_init(void)
 {
-    qemu_register_machine(&mcf5208evb_machine);
+    machine_register(&mcf5208evb_machine);
 }
 
 machine_init(mcf5208evb_machine_init);
hw/milkymist.c +1 -1
index eaef0c2..8a62c38 100644
@@ -210,7 +210,7 @@ static QEMUMachine milkymist_machine = {
 
 static void milkymist_machine_init(void)
 {
-    qemu_register_machine(&milkymist_machine);
+    machine_register(&milkymist_machine);
 }
 
 machine_init(milkymist_machine_init);
hw/mips_fulong2e.c +1 -1
index e3ba9dd..a7fe43c 100644
@@ -397,7 +397,7 @@ QEMUMachine mips_fulong2e_machine = {
 
 static void mips_fulong2e_machine_init(void)
 {
-    qemu_register_machine(&mips_fulong2e_machine);
+    machine_register(&mips_fulong2e_machine);
 }
 
 machine_init(mips_fulong2e_machine_init);
hw/mips_jazz.c +2 -2
index 2b4678e..d6fa1d2 100644
@@ -334,8 +334,8 @@ static QEMUMachine mips_pica61_machine = {
 
 static void mips_jazz_machine_init(void)
 {
-    qemu_register_machine(&mips_magnum_machine);
-    qemu_register_machine(&mips_pica61_machine);
+    machine_register(&mips_magnum_machine);
+    machine_register(&mips_pica61_machine);
 }
 
 machine_init(mips_jazz_machine_init);
hw/mips_malta.c +1 -1
index 86a5fbb..10d75a9 100644
@@ -1037,7 +1037,7 @@ static void mips_malta_register_types(void)
 
 static void mips_malta_machine_init(void)
 {
-    qemu_register_machine(&mips_malta_machine);
+    machine_register(&mips_malta_machine);
 }
 
 type_init(mips_malta_register_types)
hw/mips_mipssim.c +1 -1
index 76c95b2..944dcc4 100644
@@ -227,7 +227,7 @@ static QEMUMachine mips_mipssim_machine = {
 
 static void mips_mipssim_machine_init(void)
 {
-    qemu_register_machine(&mips_mipssim_machine);
+    machine_register(&mips_mipssim_machine);
 }
 
 machine_init(mips_mipssim_machine_init);
hw/mips_r4k.c +1 -1
index 83401f0..cdc94e4 100644
@@ -300,7 +300,7 @@ static QEMUMachine mips_machine = {
 
 static void mips_machine_init(void)
 {
-    qemu_register_machine(&mips_machine);
+    machine_register(&mips_machine);
 }
 
 machine_init(mips_machine_init);
hw/musicpal.c +1 -1
index 187a1ae..cb435fd 100644
@@ -1662,7 +1662,7 @@ static QEMUMachine musicpal_machine = {
 
 static void musicpal_machine_init(void)
 {
-    qemu_register_machine(&musicpal_machine);
+    machine_register(&musicpal_machine);
 }
 
 machine_init(musicpal_machine_init);
hw/nseries.c +2 -2
index c5b3184..2b69411 100644
@@ -1420,8 +1420,8 @@ static QEMUMachine n810_machine = {
 
 static void nseries_machine_init(void)
 {
-    qemu_register_machine(&n800_machine);
-    qemu_register_machine(&n810_machine);
+    machine_register(&n800_machine);
+    machine_register(&n810_machine);
 }
 
 machine_init(nseries_machine_init);
hw/omap_sx1.c +2 -2
index 4e8ec4a..63213ff 100644
@@ -241,8 +241,8 @@ static QEMUMachine sx1_machine_v1 = {
 
 static void sx1_machine_init(void)
 {
-    qemu_register_machine(&sx1_machine_v2);
-    qemu_register_machine(&sx1_machine_v1);
+    machine_register(&sx1_machine_v2);
+    machine_register(&sx1_machine_v1);
 }
 
 machine_init(sx1_machine_init);
hw/palm.c +1 -1
index b1252ab..889e240 100644
@@ -283,7 +283,7 @@ static QEMUMachine palmte_machine = {
 
 static void palmte_machine_init(void)
 {
-    qemu_register_machine(&palmte_machine);
+    machine_register(&palmte_machine);
 }
 
 machine_init(palmte_machine_init);
hw/pc_piix.c +10 -10
index fe7a729..2621ee1 100644
@@ -725,17 +725,17 @@ static QEMUMachine xenfv_machine = {
 
 static void pc_machine_init(void)
 {
-    qemu_register_machine(&pc_machine_v1_1);
-    qemu_register_machine(&pc_machine_v1_0);
-    qemu_register_machine(&pc_machine_v0_15);
-    qemu_register_machine(&pc_machine_v0_14);
-    qemu_register_machine(&pc_machine_v0_13);
-    qemu_register_machine(&pc_machine_v0_12);
-    qemu_register_machine(&pc_machine_v0_11);
-    qemu_register_machine(&pc_machine_v0_10);
-    qemu_register_machine(&isapc_machine);
+    machine_register(&pc_machine_v1_1);
+    machine_register(&pc_machine_v1_0);
+    machine_register(&pc_machine_v0_15);
+    machine_register(&pc_machine_v0_14);
+    machine_register(&pc_machine_v0_13);
+    machine_register(&pc_machine_v0_12);
+    machine_register(&pc_machine_v0_11);
+    machine_register(&pc_machine_v0_10);
+    machine_register(&isapc_machine);
 #ifdef CONFIG_XEN
-    qemu_register_machine(&xenfv_machine);
+    machine_register(&xenfv_machine);
 #endif
 }
 
hw/pc_sysfw.c +1 -1
index abf9004..8163b3d 100644
@@ -89,7 +89,7 @@ static void pc_fw_add_pflash_drv(void)
       return;
     }
 
-    machine = find_default_machine();
+    machine = machine_find_default();
     if (machine == NULL) {
       return;
     }
hw/petalogix_ml605_mmu.c +1 -1
index 98978f8..ccb71ca 100644
@@ -263,7 +263,7 @@ static QEMUMachine petalogix_ml605_machine = {
 
 static void petalogix_ml605_machine_init(void)
 {
-    qemu_register_machine(&petalogix_ml605_machine);
+    machine_register(&petalogix_ml605_machine);
 }
 
 machine_init(petalogix_ml605_machine_init);
hw/petalogix_s3adsp1800_mmu.c +1 -1
index d448a41..7ad082a 100644
@@ -228,7 +228,7 @@ static QEMUMachine petalogix_s3adsp1800_machine = {
 
 static void petalogix_s3adsp1800_machine_init(void)
 {
-    qemu_register_machine(&petalogix_s3adsp1800_machine);
+    machine_register(&petalogix_s3adsp1800_machine);
 }
 
 machine_init(petalogix_s3adsp1800_machine_init);
hw/ppc405_boards.c +2 -2
index 476775d..716d41f 100644
@@ -656,8 +656,8 @@ static QEMUMachine taihu_machine = {
 
 static void ppc405_machine_init(void)
 {
-    qemu_register_machine(&ref405ep_machine);
-    qemu_register_machine(&taihu_machine);
+    machine_register(&ref405ep_machine);
+    machine_register(&taihu_machine);
 }
 
 machine_init(ppc405_machine_init);
hw/ppc440_bamboo.c +1 -1
index f86b168..8d8dc23 100644
@@ -295,7 +295,7 @@ static QEMUMachine bamboo_machine = {
 
 static void bamboo_machine_init(void)
 {
-    qemu_register_machine(&bamboo_machine);
+    machine_register(&bamboo_machine);
 }
 
 machine_init(bamboo_machine_init);
hw/ppc_newworld.c +1 -1
index 506187b..e0cd55d 100644
@@ -421,7 +421,7 @@ static QEMUMachine core99_machine = {
 
 static void core99_machine_init(void)
 {
-    qemu_register_machine(&core99_machine);
+    machine_register(&core99_machine);
 }
 
 machine_init(core99_machine_init);
hw/ppc_oldworld.c +1 -1
index 9295a34..fa653da 100644
@@ -336,7 +336,7 @@ static QEMUMachine heathrow_machine = {
 
 static void heathrow_machine_init(void)
 {
-    qemu_register_machine(&heathrow_machine);
+    machine_register(&heathrow_machine);
 }
 
 machine_init(heathrow_machine_init);
hw/ppc_prep.c +1 -1
index eb43fb5..9c1b1c5 100644
@@ -721,7 +721,7 @@ static QEMUMachine prep_machine = {
 
 static void prep_machine_init(void)
 {
-    qemu_register_machine(&prep_machine);
+    machine_register(&prep_machine);
 }
 
 machine_init(prep_machine_init);
hw/ppce500_mpc8544ds.c +1 -1
index d69f78c..8f9eafe 100644
@@ -404,7 +404,7 @@ static QEMUMachine mpc8544ds_machine = {
 
 static void mpc8544ds_machine_init(void)
 {
-    qemu_register_machine(&mpc8544ds_machine);
+    machine_register(&mpc8544ds_machine);
 }
 
 machine_init(mpc8544ds_machine_init);
hw/r2d.c +1 -1
index c80f9e3..bbaf55e 100644
@@ -344,7 +344,7 @@ static QEMUMachine r2d_machine = {
 
 static void r2d_machine_init(void)
 {
-    qemu_register_machine(&r2d_machine);
+    machine_register(&r2d_machine);
 }
 
 machine_init(r2d_machine_init);
hw/realview.c +4 -4
index ae1bbcd..b52dc8b 100644
@@ -486,10 +486,10 @@ static QEMUMachine realview_pbx_a9_machine = {
 
 static void realview_machine_init(void)
 {
-    qemu_register_machine(&realview_eb_machine);
-    qemu_register_machine(&realview_eb_mpcore_machine);
-    qemu_register_machine(&realview_pb_a8_machine);
-    qemu_register_machine(&realview_pbx_a9_machine);
+    machine_register(&realview_eb_machine);
+    machine_register(&realview_eb_mpcore_machine);
+    machine_register(&realview_pb_a8_machine);
+    machine_register(&realview_pbx_a9_machine);
 }
 
 machine_init(realview_machine_init);
hw/s390-virtio.c +1 -1
index 51123a7..2589ff6 100644
@@ -323,7 +323,7 @@ static QEMUMachine s390_machine = {
 
 static void s390_machine_init(void)
 {
-    qemu_register_machine(&s390_machine);
+    machine_register(&s390_machine);
 }
 
 machine_init(s390_machine_init);
hw/shix.c +1 -1
index e259c17..341facd 100644
@@ -98,7 +98,7 @@ static QEMUMachine shix_machine = {
 
 static void shix_machine_init(void)
 {
-    qemu_register_machine(&shix_machine);
+    machine_register(&shix_machine);
 }
 
 machine_init(shix_machine_init);
hw/spapr.c +1 -1
index dffb6a2..ffee5bc 100644
@@ -746,7 +746,7 @@ static QEMUMachine spapr_machine = {
 
 static void spapr_machine_init(void)
 {
-    qemu_register_machine(&spapr_machine);
+    machine_register(&spapr_machine);
 }
 
 machine_init(spapr_machine_init);
hw/spitz.c +4 -4
index 1d6d2b0..779aa68 100644
@@ -998,10 +998,10 @@ static QEMUMachine terrierpda_machine = {
 
 static void spitz_machine_init(void)
 {
-    qemu_register_machine(&akitapda_machine);
-    qemu_register_machine(&spitzpda_machine);
-    qemu_register_machine(&borzoipda_machine);
-    qemu_register_machine(&terrierpda_machine);
+    machine_register(&akitapda_machine);
+    machine_register(&spitzpda_machine);
+    machine_register(&borzoipda_machine);
+    machine_register(&terrierpda_machine);
 }
 
 machine_init(spitz_machine_init);
hw/stellaris.c +2 -2
index 562fbbf..a21bbdf 100644
@@ -1388,8 +1388,8 @@ static QEMUMachine lm3s6965evb_machine = {
 
 static void stellaris_machine_init(void)
 {
-    qemu_register_machine(&lm3s811evb_machine);
-    qemu_register_machine(&lm3s6965evb_machine);
+    machine_register(&lm3s811evb_machine);
+    machine_register(&lm3s6965evb_machine);
 }
 
 machine_init(stellaris_machine_init);
hw/sun4m.c +12 -12
index 99fb219..ce1b458 100644
@@ -1847,18 +1847,18 @@ static void sun4m_register_types(void)
 
 static void ss2_machine_init(void)
 {
-    qemu_register_machine(&ss5_machine);
-    qemu_register_machine(&ss10_machine);
-    qemu_register_machine(&ss600mp_machine);
-    qemu_register_machine(&ss20_machine);
-    qemu_register_machine(&voyager_machine);
-    qemu_register_machine(&ss_lx_machine);
-    qemu_register_machine(&ss4_machine);
-    qemu_register_machine(&scls_machine);
-    qemu_register_machine(&sbook_machine);
-    qemu_register_machine(&ss1000_machine);
-    qemu_register_machine(&ss2000_machine);
-    qemu_register_machine(&ss2_machine);
+    machine_register(&ss5_machine);
+    machine_register(&ss10_machine);
+    machine_register(&ss600mp_machine);
+    machine_register(&ss20_machine);
+    machine_register(&voyager_machine);
+    machine_register(&ss_lx_machine);
+    machine_register(&ss4_machine);
+    machine_register(&scls_machine);
+    machine_register(&sbook_machine);
+    machine_register(&ss1000_machine);
+    machine_register(&ss2000_machine);
+    machine_register(&ss2_machine);
 }
 
 type_init(sun4m_register_types)
hw/sun4u.c +3 -3
index 423108f..224918e 100644
@@ -945,9 +945,9 @@ static void sun4u_register_types(void)
 
 static void sun4u_machine_init(void)
 {
-    qemu_register_machine(&sun4u_machine);
-    qemu_register_machine(&sun4v_machine);
-    qemu_register_machine(&niagara_machine);
+    machine_register(&sun4u_machine);
+    machine_register(&sun4v_machine);
+    machine_register(&niagara_machine);
 }
 
 type_init(sun4u_register_types)
hw/tosa.c +1 -1
index 6baa17d..b2506c8 100644
@@ -254,7 +254,7 @@ static QEMUMachine tosapda_machine = {
 
 static void tosapda_machine_init(void)
 {
-    qemu_register_machine(&tosapda_machine);
+    machine_register(&tosapda_machine);
 }
 
 machine_init(tosapda_machine_init);
hw/versatilepb.c +2 -2
index b9102f4..ab4e61c 100644
@@ -358,8 +358,8 @@ static QEMUMachine versatileab_machine = {
 
 static void versatile_machine_init(void)
 {
-    qemu_register_machine(&versatilepb_machine);
-    qemu_register_machine(&versatileab_machine);
+    machine_register(&versatilepb_machine);
+    machine_register(&versatileab_machine);
 }
 
 machine_init(versatile_machine_init);
hw/vexpress.c +2 -2
index b9aafec..91d9ca6 100644
@@ -483,8 +483,8 @@ static QEMUMachine vexpress_a15_machine = {
 
 static void vexpress_machine_init(void)
 {
-    qemu_register_machine(&vexpress_a9_machine);
-    qemu_register_machine(&vexpress_a15_machine);
+    machine_register(&vexpress_a9_machine);
+    machine_register(&vexpress_a15_machine);
 }
 
 machine_init(vexpress_machine_init);
hw/virtex_ml507.c +1 -1
index f8d2b1b..3427e86 100644
@@ -263,7 +263,7 @@ static QEMUMachine virtex_machine = {
 
 static void virtex_machine_init(void)
 {
-    qemu_register_machine(&virtex_machine);
+    machine_register(&virtex_machine);
 }
 
 machine_init(virtex_machine_init);
hw/xen_machine_pv.c +1 -1
index 7985d11..0f46a93 100644
@@ -118,7 +118,7 @@ static QEMUMachine xenpv_machine = {
 
 static void xenpv_machine_init(void)
 {
-    qemu_register_machine(&xenpv_machine);
+    machine_register(&xenpv_machine);
 }
 
 machine_init(xenpv_machine_init);
hw/xtensa_lx60.c +2 -2
index 26112c3..27c9af5 100644
@@ -308,8 +308,8 @@ static QEMUMachine xtensa_lx200_machine = {
 
 static void xtensa_lx_machines_init(void)
 {
-    qemu_register_machine(&xtensa_lx60_machine);
-    qemu_register_machine(&xtensa_lx200_machine);
+    machine_register(&xtensa_lx60_machine);
+    machine_register(&xtensa_lx200_machine);
 }
 
 machine_init(xtensa_lx_machines_init);
hw/xtensa_sim.c +1 -1
index 104e5dc..ba82ccc 100644
@@ -112,7 +112,7 @@ static QEMUMachine xtensa_sim_machine = {
 
 static void xtensa_sim_machine_init(void)
 {
-    qemu_register_machine(&xtensa_sim_machine);
+    machine_register(&xtensa_sim_machine);
 }
 
 machine_init(xtensa_sim_machine_init);
hw/z2.c +1 -1
index 654ac55..0252553 100644
@@ -375,7 +375,7 @@ static QEMUMachine z2_machine = {
 
 static void z2_machine_init(void)
 {
-    qemu_register_machine(&z2_machine);
+    machine_register(&z2_machine);
 }
 
 machine_init(z2_machine_init);
vl.c +5 -5
index 45fc3b5..81cc5b1 100644
@@ -1163,7 +1163,7 @@ void pcmcia_info(Monitor *mon)
 static QEMUMachine *first_machine = NULL;
 QEMUMachine *current_machine = NULL;
 
-void qemu_register_machine(QEMUMachine *m)
+void machine_register(QEMUMachine *m)
 {
     QEMUMachine **pm;
     pm = &first_machine;
@@ -1173,7 +1173,7 @@ void qemu_register_machine(QEMUMachine *m)
     *pm = m;
 }
 
-static QEMUMachine *find_machine(const char *name)
+static QEMUMachine *machine_find(const char *name)
 {
     QEMUMachine *m;
 
@@ -1186,7 +1186,7 @@ static QEMUMachine *find_machine(const char *name)
     return NULL;
 }
 
-QEMUMachine *find_default_machine(void)
+QEMUMachine *machine_find_default(void)
 {
     QEMUMachine *m;
 
@@ -1990,7 +1990,7 @@ static QEMUMachine *machine_parse(const char *name)
     QEMUMachine *m, *machine = NULL;
 
     if (name) {
-        machine = find_machine(name);
+        machine = machine_find(name);
     }
     if (machine) {
         return machine;
@@ -2235,7 +2235,7 @@ int main(int argc, char **argv, char **envp)
     os_setup_early_signal_handling();
 
     module_call_init(MODULE_INIT_MACHINE);
-    machine = find_default_machine();
+    machine = machine_find_default();
     cpu_model = NULL;
     ram_size = 0;
     snapshot = 0;
Signature · 1 line
1.7.9.111.gf3fb0.dirty
#4 lore raw

Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions

Quoted 8 lines · Luiz Capitulino

Perform the following renames:

 o qemu_register_machine() -> machine_register()
 o find_machine() -> machine_find()
 o find_default_machine()  -> machine_find_default()

 52 files changed, 96 insertions(+), 96 deletions(-)

I said I was going to nack the next change-whole-tree change, so here it is: nack.

At some point we're going to have to actually start converting boards to be QOM objects themselves, but
(a) I hope we can make that incremental so we can do things in batches the way we did with MemoryRegion conversions and (b) until then the qemu_register_machine rename just looks like unnecessary churn to me.

-- PMM

#5 lore raw

Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions

Quoted 13 lines · Peter Maydell
Quoted 8 lines · Luiz Capitulino

Perform the following renames:

o qemu_register_machine() -> machine_register()
o find_machine() -> machine_find()
o find_default_machine() -> machine_find_default()

  52 files changed, 96 insertions(+), 96 deletions(-)

I said I was going to nack the next change-whole-tree change, so here it is: nack.

Quoted 6 lines

At some point we're going to have to actually start converting boards to be QOM objects themselves, but
(a) I hope we can make that incremental so we can do things in batches the way we did with MemoryRegion conversions and (b) until then the qemu_register_machine rename just looks like unnecessary churn to me.

I think I agree with you here. I don't see the value compared to the churn here given that we're going to have to touch all of this again anyway soon.

Regards,

Anthony Liguori

Quoted 4 lines

-- PMM

#6 lore raw

Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions

Quoted 21 lines · On Fri, 24 Feb 2012 10:15:52 -0600 Anthony Liguori <[email protected]> wrote:
Quoted 13 lines · Peter Maydell
Quoted 8 lines · Luiz Capitulino

Perform the following renames:

o qemu_register_machine() -> machine_register()
o find_machine() -> machine_find()
o find_default_machine() -> machine_find_default()

  52 files changed, 96 insertions(+), 96 deletions(-)

I said I was going to nack the next change-whole-tree change, so here it is: nack.

Quoted 6 lines

At some point we're going to have to actually start converting boards to be QOM objects themselves, but
(a) I hope we can make that incremental so we can do things in batches the way we did with MemoryRegion conversions and (b) until then the qemu_register_machine rename just looks like unnecessary churn to me.

Quoted 2 lines

I think I agree with you here. I don't see the value compared to the churn here given that we're going to have to touch all of this again anyway soon.

Do you guys see value in patch 5/5, which moves the machine function to the boards file?

If you don't I'll keep only patch 1/5 (which can be submitted to qemu-trivial).

#7 lore raw

Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions

Quoted 24 lines · Luiz Capitulino
Quoted 21 lines · On Fri, 24 Feb 2012 10:15:52 -0600 Anthony Liguori<[email protected]> wrote:
Quoted 19 lines · Peter Maydell
Quoted 8 lines · Luiz Capitulino

Perform the following renames:

o qemu_register_machine() -> machine_register()
o find_machine() -> machine_find()
o find_default_machine() -> machine_find_default()

   52 files changed, 96 insertions(+), 96 deletions(-)

I said I was going to nack the next change-whole-tree change, so here it is: nack.

At some point we're going to have to actually start converting boards to be QOM objects themselves, but
(a) I hope we can make that incremental so we can do things in batches the way we did with MemoryRegion conversions and (b) until then the qemu_register_machine rename just looks like unnecessary churn to me.

Quoted 5 lines
Quoted 2 lines

I think I agree with you here. I don't see the value compared to the churn here given that we're going to have to touch all of this again anyway soon.

Do you guys see value in patch 5/5, which moves the machine function to the boards file?

Yes. And it's not that the other practicals aren't useful, it's just that I agree with Peter's valid point that the churn outweighs the benefit right now.

Regards,

Anthony Liguori

Quoted 3 lines

If you don't I'll keep only patch 1/5 (which can be submitted to qemu-trivial).

#8 lore raw

PATCH 3/5 boards: introduce machine_print_all()

In reply to Luiz Capitulino

Print all registered machine types.

---
 hw/boards.h |    1 +
 vl.c        |   25 ++++++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)
hw/boards.h +1 -0
index 098cbb7..342a774 100644
@@ -33,6 +33,7 @@ typedef struct QEMUMachine {
 
 void machine_register(QEMUMachine *m);
 QEMUMachine *machine_find_default(void);
+void machine_print_all(void);
 
 extern QEMUMachine *current_machine;
 
vl.c +16 -9
index 81cc5b1..9f9927c 100644
@@ -1198,6 +1198,20 @@ QEMUMachine *machine_find_default(void)
     return NULL;
 }
 
+void machine_print_all(void)
+{
+    QEMUMachine *m;
+
+    printf("Supported machines are:\n");
+    for (m = first_machine; m != NULL; m = m->next) {
+        if (m->alias) {
+            printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
+        }
+        printf("%-10s %s%s\n", m->name, m->desc,
+               m->is_default ? " (default)" : "");
+    }
+}
+
 /***********************************************************/
 /* main execution loop */
 
@@ -1987,7 +2001,7 @@ static int debugcon_parse(const char *devname)
 
 static QEMUMachine *machine_parse(const char *name)
 {
-    QEMUMachine *m, *machine = NULL;
+    QEMUMachine *machine = NULL;
 
     if (name) {
         machine = machine_find(name);
@@ -1995,14 +2009,7 @@ static QEMUMachine *machine_parse(const char *name)
     if (machine) {
         return machine;
     }
-    printf("Supported machines are:\n");
-    for (m = first_machine; m != NULL; m = m->next) {
-        if (m->alias) {
-            printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
-        }
-        printf("%-10s %s%s\n", m->name, m->desc,
-               m->is_default ? " (default)" : "");
-    }
+    machine_print_all();
     exit(!name || *name != '?');
 }
 
Signature · 1 line
1.7.9.111.gf3fb0.dirty
#9 lore raw

Re: [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all()

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 3 lines

Print all registered machine types.

I'm okay with the code movement, but is there a reason not to make it static?

Needs a rebase due to 10 -> 20 bump by Peter.

Andreas

Quoted 67 lines
---
 hw/boards.h |    1 +
 vl.c        |   25 ++++++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)
hw/boards.h +1 -0
index 098cbb7..342a774 100644
@@ -33,6 +33,7 @@ typedef struct QEMUMachine {
 
 void machine_register(QEMUMachine *m);
 QEMUMachine *machine_find_default(void);
+void machine_print_all(void);
 
 extern QEMUMachine *current_machine;
 
vl.c +16 -9
index 81cc5b1..9f9927c 100644
@@ -1198,6 +1198,20 @@ QEMUMachine *machine_find_default(void)
     return NULL;
 }
 
+void machine_print_all(void)
+{
+    QEMUMachine *m;
+
+    printf("Supported machines are:\n");
+    for (m = first_machine; m != NULL; m = m->next) {
+        if (m->alias) {
+            printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
+        }
+        printf("%-10s %s%s\n", m->name, m->desc,
+               m->is_default ? " (default)" : "");
+    }
+}
+
 /***********************************************************/
 /* main execution loop */
 
@@ -1987,7 +2001,7 @@ static int debugcon_parse(const char *devname)
 
 static QEMUMachine *machine_parse(const char *name)
 {
-    QEMUMachine *m, *machine = NULL;
+    QEMUMachine *machine = NULL;
 
     if (name) {
         machine = machine_find(name);
@@ -1995,14 +2009,7 @@ static QEMUMachine *machine_parse(const char *name)
     if (machine) {
         return machine;
     }
-    printf("Supported machines are:\n");
-    for (m = first_machine; m != NULL; m = m->next) {
-        if (m->alias) {
-            printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
-        }
-        printf("%-10s %s%s\n", m->name, m->desc,
-               m->is_default ? " (default)" : "");
-    }
+    machine_print_all();
     exit(!name || *name != '?');
 }
 
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#10 lore raw

Re: [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all()

Quoted 7 lines · On Fri, 24 Feb 2012 15:26:36 +0100 Andreas Färber <[email protected]> wrote:

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 3 lines

Print all registered machine types.

I'm okay with the code movement, but is there a reason not to make it static?

I can make it static.

Quoted 1 line

Needs a rebase due to 10 -> 20 bump by Peter.

Will rebase as soon as his patch is merged on master.

#11 lore raw

PATCH 4/5 boards: switch machine type list to QTAILQ

In reply to Luiz Capitulino
---
 hw/boards.h |    3 ++-
 vl.c        |   16 ++++++----------
 2 files changed, 8 insertions(+), 11 deletions(-)
hw/boards.h +2 -1
index 342a774..1eb8314 100644
@@ -4,6 +4,7 @@
 #define HW_BOARDS_H
 
 #include "qdev.h"
+#include "qemu-queue.h"
 
 typedef void QEMUMachineInitFunc(ram_addr_t ram_size,
                                  const char *boot_device,
@@ -28,7 +29,7 @@ typedef struct QEMUMachine {
     int is_default;
     const char *default_machine_opts;
     GlobalProperty *compat_props;
-    struct QEMUMachine *next;
+    QTAILQ_ENTRY(QEMUMachine) next;
 } QEMUMachine;
 
 void machine_register(QEMUMachine *m);
vl.c +6 -10
index 9f9927c..4935106 100644
@@ -1160,24 +1160,20 @@ void pcmcia_info(Monitor *mon)
 /***********************************************************/
 /* machine registration */
 
-static QEMUMachine *first_machine = NULL;
+static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types = 
+    QTAILQ_HEAD_INITIALIZER(machine_types);
 QEMUMachine *current_machine = NULL;
 
 void machine_register(QEMUMachine *m)
 {
-    QEMUMachine **pm;
-    pm = &first_machine;
-    while (*pm != NULL)
-        pm = &(*pm)->next;
-    m->next = NULL;
-    *pm = m;
+    QTAILQ_INSERT_TAIL(&machine_types, m, next);
 }
 
 static QEMUMachine *machine_find(const char *name)
 {
     QEMUMachine *m;
 
-    for(m = first_machine; m != NULL; m = m->next) {
+    QTAILQ_FOREACH(m, &machine_types, next) {
         if (!strcmp(m->name, name))
             return m;
         if (m->alias && !strcmp(m->alias, name))
@@ -1190,7 +1186,7 @@ QEMUMachine *machine_find_default(void)
 {
     QEMUMachine *m;
 
-    for(m = first_machine; m != NULL; m = m->next) {
+    QTAILQ_FOREACH(m, &machine_types, next) {
         if (m->is_default) {
             return m;
         }
@@ -1203,7 +1199,7 @@ void machine_print_all(void)
     QEMUMachine *m;
 
     printf("Supported machines are:\n");
-    for (m = first_machine; m != NULL; m = m->next) {
+    QTAILQ_FOREACH(m, &machine_types, next) {
         if (m->alias) {
             printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
         }
Signature · 1 line
1.7.9.111.gf3fb0.dirty
#12 lore raw

Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 1 line

Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch.

Andreas

Quoted 77 lines
---
 hw/boards.h |    3 ++-
 vl.c        |   16 ++++++----------
 2 files changed, 8 insertions(+), 11 deletions(-)
hw/boards.h +2 -1
index 342a774..1eb8314 100644
@@ -4,6 +4,7 @@
 #define HW_BOARDS_H
 
 #include "qdev.h"
+#include "qemu-queue.h"
 
 typedef void QEMUMachineInitFunc(ram_addr_t ram_size,
                                  const char *boot_device,
@@ -28,7 +29,7 @@ typedef struct QEMUMachine {
     int is_default;
     const char *default_machine_opts;
     GlobalProperty *compat_props;
-    struct QEMUMachine *next;
+    QTAILQ_ENTRY(QEMUMachine) next;
 } QEMUMachine;
 
 void machine_register(QEMUMachine *m);
vl.c +6 -10
index 9f9927c..4935106 100644
@@ -1160,24 +1160,20 @@ void pcmcia_info(Monitor *mon)
 /***********************************************************/
 /* machine registration */
 
-static QEMUMachine *first_machine = NULL;
+static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types = 
+    QTAILQ_HEAD_INITIALIZER(machine_types);
 QEMUMachine *current_machine = NULL;
 
 void machine_register(QEMUMachine *m)
 {
-    QEMUMachine **pm;
-    pm = &first_machine;
-    while (*pm != NULL)
-        pm = &(*pm)->next;
-    m->next = NULL;
-    *pm = m;
+    QTAILQ_INSERT_TAIL(&machine_types, m, next);
 }
 
 static QEMUMachine *machine_find(const char *name)
 {
     QEMUMachine *m;
 
-    for(m = first_machine; m != NULL; m = m->next) {
+    QTAILQ_FOREACH(m, &machine_types, next) {
         if (!strcmp(m->name, name))
             return m;
         if (m->alias && !strcmp(m->alias, name))
@@ -1190,7 +1186,7 @@ QEMUMachine *machine_find_default(void)
 {
     QEMUMachine *m;
 
-    for(m = first_machine; m != NULL; m = m->next) {
+    QTAILQ_FOREACH(m, &machine_types, next) {
         if (m->is_default) {
             return m;
         }
@@ -1203,7 +1199,7 @@ void machine_print_all(void)
     QEMUMachine *m;
 
     printf("Supported machines are:\n");
-    for (m = first_machine; m != NULL; m = m->next) {
+    QTAILQ_FOREACH(m, &machine_types, next) {
         if (m->alias) {
             printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
         }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#13 lore raw

Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ

Quoted 6 lines · On Fri, 24 Feb 2012 15:23:43 +0100 Andreas Färber <[email protected]> wrote:

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 1 line

Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch.

Is there a plan to convert this to qom anytime soon?

If there isn't, then I'd do the refactoring because the resulting code is simpler & cleaner.

#14 lore raw

Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ

Am 24.02.2012 15:56, schrieb Luiz Capitulino:

Quoted 11 lines
Quoted 6 lines · On Fri, 24 Feb 2012 15:23:43 +0100 Andreas Färber <[email protected]> wrote:

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 1 line

Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch.

Is there a plan to convert this to qom anytime soon?

I was planning to look into it after CPU is done, if no one beats me. Since CPU will touch on the machine init functions, doing both in parallel did not seem like a good idea to me.

I consider both CPU and machine 1.1 material - if we can agree on the way there, then the code you are changing here will not see a release. It certainly doesn't hurt to commit it though. :)

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#15 lore raw

Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ

Quoted 13 lines · On Fri, 24 Feb 2012 16:21:56 +0100 Andreas Färber <[email protected]> wrote:

Am 24.02.2012 15:56, schrieb Luiz Capitulino:

Quoted 11 lines
Quoted 6 lines · On Fri, 24 Feb 2012 15:23:43 +0100 Andreas Färber <[email protected]> wrote:

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 1 line

Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch.

Is there a plan to convert this to qom anytime soon?

Quoted 7 lines

I was planning to look into it after CPU is done, if no one beats me. Since CPU will touch on the machine init functions, doing both in parallel did not seem like a good idea to me.

I consider both CPU and machine 1.1 material - if we can agree on the way there, then the code you are changing here will not see a release. It certainly doesn't hurt to commit it though. :)

Well, if you're already planning to do it I can drop the patch then.

#16 lore raw

PATCH 5/5 boards: move all machine type functions to boards.c

In reply to Luiz Capitulino

The license text is the same as used in vl.c. Also note that it's necessary to make machine_parse() public.

---
 Makefile.target |    3 +-
 hw/boards.c     |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/boards.h     |    1 +
 vl.c            |   65 -----------------------------------------
 4 files changed, 89 insertions(+), 66 deletions(-)
 create mode 100644 hw/boards.c
Makefile.target +2 -1
index d5eb70d..dc76eba 100644
@@ -195,7 +195,8 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 
-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o
+obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o \
+		boards.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
 obj-$(CONFIG_NO_PCI) += pci-stub.o
hw/boards.c new file +86 -0

86 lines not on this page · raw message

hw/boards.h +1 -0
index 1eb8314..d5e110f 100644
@@ -35,6 +35,7 @@ typedef struct QEMUMachine {
 void machine_register(QEMUMachine *m);
 QEMUMachine *machine_find_default(void);
 void machine_print_all(void);
+QEMUMachine *machine_parse(const char *name);
 
 extern QEMUMachine *current_machine;
 
vl.c +0 -65

77 lines not on this page · raw message

Signature · 1 line
1.7.9.111.gf3fb0.dirty
#17 lore raw

Re: [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 11 lines

The license text is the same as used in vl.c. Also note that it's necessary to make machine_parse() public.

---
 Makefile.target |    3 +-
 hw/boards.c     |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/boards.h     |    1 +
 vl.c            |   65 -----------------------------------------
 4 files changed, 89 insertions(+), 66 deletions(-)
 create mode 100644 hw/boards.c

In anticipation of a "board" class derived from "container" I would rather have the file name match the class name, i.e. board.c. Unfortunately boards.h is used in quite a lot of places already, but when we QOM'ify it we might want to move it to include/qemu so all users would need to be touched anyway.

Makefile.target endif #CONFIG_BSD_USER · line 199

Quoted 11 lines
Makefile.target +2 -1
index d5eb70d..dc76eba 100644
@@ -195,7 +195,8 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 
-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o
+obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o \
+		boards.o

Please use obj-y += ... instead of the line break.

Otherwise looks okay.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#18 lore raw

Re: [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c

Quoted 13 lines · On Fri, 24 Feb 2012 16:10:17 +0100 Andreas Färber <[email protected]> wrote:

Am 24.02.2012 15:13, schrieb Luiz Capitulino:

Quoted 11 lines

The license text is the same as used in vl.c. Also note that it's necessary to make machine_parse() public.

---
 Makefile.target |    3 +-
 hw/boards.c     |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/boards.h     |    1 +
 vl.c            |   65 -----------------------------------------
 4 files changed, 89 insertions(+), 66 deletions(-)
 create mode 100644 hw/boards.c
Quoted 5 lines

In anticipation of a "board" class derived from "container" I would rather have the file name match the class name, i.e. board.c. Unfortunately boards.h is used in quite a lot of places already, but when we QOM'ify it we might want to move it to include/qemu so all users would need to be touched anyway.

I don't min doing the rename work, but Anthony is talking about having a Machine type. So, maybe it's a better idea to do rename along with the QOM conversion, as that's when we'll be sure about the class name.

Quoted 8 lines
Quoted 8 lines
Makefile.target +0 -0
index d5eb70d..dc76eba 100644
@@ -195,7 +195,8 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 
Quoted 5 lines

Makefile.target endif #CONFIG_BSD_USER · line 199

Quoted 3 lines
Makefile.target +2 -1
-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o
+obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o \
+		boards.o

Please use obj-y += ... instead of the line break.

Ok.

Quoted 5 lines

Otherwise looks okay.

Andreas

#19 lore raw
In reply to Luiz Capitulino
Quoted 3 lines · Luiz Capitulino

I was reading some related code yesterday and couldn't resist improving this. Not sure if this is aligned with any possible QOM work in this area, but I'm posting this anyway...

I'm not sure how easy this is, but the way to do this with QOM would be:

1) Introduce a Machine abstract type. It would have the normal properties for the various machine parameters we have today (that are standard for all machines).

2) Convert all the registered users of QEMUMachine to subtypes of Machine. Note that this would tremendously simplify PC since each version could subclass the previous and we wouldn't need to duplicate globals. Use a realize() method to trigger what we think of as the machine->init() function today (but it would take no parameters).

3) Change machine listing to a object_type_foreach() call that passed TYPE_MACHINE for 'implements'.

4) Change machine initialization to creating an object of type (3), setting the properties appropriately, and then calling the realize() method of the object.

That's not to say this series isn't a good cleanup. I haven't actually reviewed it yet. I just wanted to illustrate the next QOM steps.

Regards,

Anthony Liguori

Quoted 57 lines
  Makefile.target               |    3 +-
  hw/alpha_dp264.c              |    2 +-
  hw/an5206.c                   |    2 +-
  hw/axis_dev88.c               |    2 +-
  hw/boards.c                   |   86 +++++++++++++++++++++++++++++++++++++++++
  hw/boards.h                   |    9 +++-
  hw/collie.c                   |    2 +-
  hw/dummy_m68k.c               |    2 +-
  hw/exynos4_boards.c           |    4 +-
  hw/gumstix.c                  |    4 +-
  hw/highbank.c                 |    2 +-
  hw/integratorcp.c             |    2 +-
  hw/leon3.c                    |    2 +-
  hw/lm32_boards.c              |    4 +-
  hw/mainstone.c                |    2 +-
  hw/mcf5208.c                  |    2 +-
  hw/milkymist.c                |    2 +-
  hw/mips_fulong2e.c            |    2 +-
  hw/mips_jazz.c                |    4 +-
  hw/mips_malta.c               |    2 +-
  hw/mips_mipssim.c             |    2 +-
  hw/mips_r4k.c                 |    2 +-
  hw/musicpal.c                 |    2 +-
  hw/nseries.c                  |    4 +-
  hw/omap_sx1.c                 |    4 +-
  hw/palm.c                     |    2 +-
  hw/pc_piix.c                  |   20 +++++-----
  hw/pc_sysfw.c                 |    2 +-
  hw/petalogix_ml605_mmu.c      |    2 +-
  hw/petalogix_s3adsp1800_mmu.c |    2 +-
  hw/ppc405_boards.c            |    4 +-
  hw/ppc440_bamboo.c            |    2 +-
  hw/ppc_newworld.c             |    2 +-
  hw/ppc_oldworld.c             |    2 +-
  hw/ppc_prep.c                 |    2 +-
  hw/ppce500_mpc8544ds.c        |    2 +-
  hw/r2d.c                      |    2 +-
  hw/realview.c                 |    8 ++--
  hw/s390-virtio.c              |    2 +-
  hw/shix.c                     |    2 +-
  hw/spapr.c                    |    2 +-
  hw/spitz.c                    |    8 ++--
  hw/stellaris.c                |    4 +-
  hw/sun4m.c                    |   24 ++++++------
  hw/sun4u.c                    |    6 +-
  hw/tosa.c                     |    2 +-
  hw/versatilepb.c              |    4 +-
  hw/vexpress.c                 |    4 +-
  hw/virtex_ml507.c             |    2 +-
  hw/xen_machine_pv.c           |    2 +-
  hw/xtensa_lx60.c              |    4 +-
  hw/xtensa_sim.c               |    2 +-
  hw/z2.c                       |    2 +-
  vl.c                          |   65 +------------------------------
  54 files changed, 184 insertions(+), 157 deletions(-)
#20 lore raw
Quoted 6 lines · On Fri, 24 Feb 2012 08:58:55 -0600 Anthony Liguori <[email protected]> wrote:
Quoted 3 lines · Luiz Capitulino

I was reading some related code yesterday and couldn't resist improving this. Not sure if this is aligned with any possible QOM work in this area, but I'm posting this anyway...

I'm not sure how easy this is, but the way to do this with QOM would be:

This seems like a cool thing to work on. The two major problems (for me at least) is testing and the possible huge amount of manual work, or do you think that most of the work can be automated?

The problem with testing is that, we have a whole lot of machines I have no idea what's the best way of testing the conversion work.

[...]

Quoted 2 lines

That's not to say this series isn't a good cleanup. I haven't actually reviewed it yet. I just wanted to illustrate the next QOM steps.

Ok. I honestly think that this series is a small first step. Even the QTAILQ conversion is worth it IMHO, because it clearly shows what the function is doing in a single line.

#21 lore raw
Quoted 4 lines · Luiz Capitulino
Quoted 1 line · On Fri, 24 Feb 2012 08:58:55 -0600 Anthony Liguori<[email protected]> wrote:

On 02/24/2012 08:13 AM, Luiz Capitulino wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I was reading some related code yesterday and couldn't resist improving this. Not sure if this is aligned with any possible QOM work in this area, but I'm posting this anyway...

I'm not sure how easy this is, but the way to do this with QOM would be:

This seems like a cool thing to work on. The two major problems (for me at least) is testing and the possible huge amount of manual work,

Heh, I wouldn't quite call it huge :-)

I think you can pretty easily sed the machine init function definitions to accept a Machine parameter as the first argument.

I think to introduce the types, you would need to write a quick python script that parsed the QEMUMachine declarations and then converted that into a TypeInfo + class_init function.

I wouldn't bother trying to make the code conversion script perfect. I've found it's easiest to convert the easy 90% automatically and then do the remaining 10% by hand.

or do you think that

Quoted 4 lines

most of the work can be automated?

The problem with testing is that, we have a whole lot of machines I have no idea what's the best way of testing the conversion work.

Since the conversion shouldn't change any logic, there shouldn't be a huge test burden. What I've done in the past is just write a little script that parses the output of -M ? and then walks through and executes qemu with no arguments other than -M $name. It's a bit tedious since you have to manually close the window but it's a relatively quick way to check each machine is behaving the same as it was before.

Regards,

Anthony Liguori

Quoted 10 lines

[...]

Quoted 2 lines

That's not to say this series isn't a good cleanup. I haven't actually reviewed it yet. I just wanted to illustrate the next QOM steps.

Ok. I honestly think that this series is a small first step. Even the QTAILQ conversion is worth it IMHO, because it clearly shows what the function is doing in a single line.