qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5]: Improve machine type functions
@ 2012-02-24 14:13 Luiz Capitulino
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void Luiz Capitulino
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 14:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

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(-)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void
  2012-02-24 14:13 [Qemu-devel] [PATCH 0/5]: Improve machine type functions Luiz Capitulino
@ 2012-02-24 14:13 ` Luiz Capitulino
  2012-02-24 14:17   ` Andreas Färber
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 2/5] boards: rename machine type functions Luiz Capitulino
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 14:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

It never fails.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/boards.h |    2 +-
 vl.c        |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/boards.h b/hw/boards.h
index 667177d..7a9899f 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -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;
diff --git a/vl.c b/vl.c
index 7a8cc08..45fc3b5 100644
--- a/vl.c
+++ b/vl.c
@@ -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)
-- 
1.7.9.111.gf3fb0.dirty

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 2/5] boards: rename machine type functions
  2012-02-24 14:13 [Qemu-devel] [PATCH 0/5]: Improve machine type functions Luiz Capitulino
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void Luiz Capitulino
@ 2012-02-24 14:13 ` Luiz Capitulino
  2012-02-24 16:12   ` Peter Maydell
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all() Luiz Capitulino
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 14:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

Perform the following renames:

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

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 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(-)

diff --git a/hw/alpha_dp264.c b/hw/alpha_dp264.c
index ea0fd95..21f7729 100644
--- a/hw/alpha_dp264.c
+++ b/hw/alpha_dp264.c
@@ -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);
diff --git a/hw/an5206.c b/hw/an5206.c
index d57306d..5361576 100644
--- a/hw/an5206.c
+++ b/hw/an5206.c
@@ -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);
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index c9301fd..549aaa5 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -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);
diff --git a/hw/boards.h b/hw/boards.h
index 7a9899f..098cbb7 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -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;
 
diff --git a/hw/collie.c b/hw/collie.c
index 42f4310..cdcf722 100644
--- a/hw/collie.c
+++ b/hw/collie.c
@@ -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)
diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c
index e3c5740..30562bb 100644
--- a/hw/dummy_m68k.c
+++ b/hw/dummy_m68k.c
@@ -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);
diff --git a/hw/exynos4_boards.c b/hw/exynos4_boards.c
index 553a02b..5b1e717 100644
--- a/hw/exynos4_boards.c
+++ b/hw/exynos4_boards.c
@@ -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);
diff --git a/hw/gumstix.c b/hw/gumstix.c
index 13a36ea..60a00eb 100644
--- a/hw/gumstix.c
+++ b/hw/gumstix.c
@@ -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);
diff --git a/hw/highbank.c b/hw/highbank.c
index 489c00e..aeb3553 100644
--- a/hw/highbank.c
+++ b/hw/highbank.c
@@ -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);
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index 5b06c81..2ec9e7b 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -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);
diff --git a/hw/leon3.c b/hw/leon3.c
index 71d79a6..13677b1 100644
--- a/hw/leon3.c
+++ b/hw/leon3.c
@@ -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);
diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c
index 3cdf120..3ebb0b1 100644
--- a/hw/lm32_boards.c
+++ b/hw/lm32_boards.c
@@ -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);
diff --git a/hw/mainstone.c b/hw/mainstone.c
index 27f5900..bc49f45 100644
--- a/hw/mainstone.c
+++ b/hw/mainstone.c
@@ -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);
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index aa11a75..c45db6f 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -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);
diff --git a/hw/milkymist.c b/hw/milkymist.c
index eaef0c2..8a62c38 100644
--- a/hw/milkymist.c
+++ b/hw/milkymist.c
@@ -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);
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index e3ba9dd..a7fe43c 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -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);
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 2b4678e..d6fa1d2 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -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);
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 86a5fbb..10d75a9 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -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)
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index 76c95b2..944dcc4 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -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);
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 83401f0..cdc94e4 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -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);
diff --git a/hw/musicpal.c b/hw/musicpal.c
index 187a1ae..cb435fd 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -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);
diff --git a/hw/nseries.c b/hw/nseries.c
index c5b3184..2b69411 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -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);
diff --git a/hw/omap_sx1.c b/hw/omap_sx1.c
index 4e8ec4a..63213ff 100644
--- a/hw/omap_sx1.c
+++ b/hw/omap_sx1.c
@@ -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);
diff --git a/hw/palm.c b/hw/palm.c
index b1252ab..889e240 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -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);
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index fe7a729..2621ee1 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -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
 }
 
diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index abf9004..8163b3d 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -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;
     }
diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c
index 98978f8..ccb71ca 100644
--- a/hw/petalogix_ml605_mmu.c
+++ b/hw/petalogix_ml605_mmu.c
@@ -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);
diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c
index d448a41..7ad082a 100644
--- a/hw/petalogix_s3adsp1800_mmu.c
+++ b/hw/petalogix_s3adsp1800_mmu.c
@@ -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);
diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
index 476775d..716d41f 100644
--- a/hw/ppc405_boards.c
+++ b/hw/ppc405_boards.c
@@ -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);
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index f86b168..8d8dc23 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -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);
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 506187b..e0cd55d 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -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);
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 9295a34..fa653da 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -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);
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index eb43fb5..9c1b1c5 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -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);
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index d69f78c..8f9eafe 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -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);
diff --git a/hw/r2d.c b/hw/r2d.c
index c80f9e3..bbaf55e 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -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);
diff --git a/hw/realview.c b/hw/realview.c
index ae1bbcd..b52dc8b 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -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);
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 51123a7..2589ff6 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -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);
diff --git a/hw/shix.c b/hw/shix.c
index e259c17..341facd 100644
--- a/hw/shix.c
+++ b/hw/shix.c
@@ -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);
diff --git a/hw/spapr.c b/hw/spapr.c
index dffb6a2..ffee5bc 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -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);
diff --git a/hw/spitz.c b/hw/spitz.c
index 1d6d2b0..779aa68 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -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);
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 562fbbf..a21bbdf 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -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);
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 99fb219..ce1b458 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -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)
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 423108f..224918e 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -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)
diff --git a/hw/tosa.c b/hw/tosa.c
index 6baa17d..b2506c8 100644
--- a/hw/tosa.c
+++ b/hw/tosa.c
@@ -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);
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index b9102f4..ab4e61c 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -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);
diff --git a/hw/vexpress.c b/hw/vexpress.c
index b9aafec..91d9ca6 100644
--- a/hw/vexpress.c
+++ b/hw/vexpress.c
@@ -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);
diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c
index f8d2b1b..3427e86 100644
--- a/hw/virtex_ml507.c
+++ b/hw/virtex_ml507.c
@@ -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);
diff --git a/hw/xen_machine_pv.c b/hw/xen_machine_pv.c
index 7985d11..0f46a93 100644
--- a/hw/xen_machine_pv.c
+++ b/hw/xen_machine_pv.c
@@ -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);
diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c
index 26112c3..27c9af5 100644
--- a/hw/xtensa_lx60.c
+++ b/hw/xtensa_lx60.c
@@ -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);
diff --git a/hw/xtensa_sim.c b/hw/xtensa_sim.c
index 104e5dc..ba82ccc 100644
--- a/hw/xtensa_sim.c
+++ b/hw/xtensa_sim.c
@@ -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);
diff --git a/hw/z2.c b/hw/z2.c
index 654ac55..0252553 100644
--- a/hw/z2.c
+++ b/hw/z2.c
@@ -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);
diff --git a/vl.c b/vl.c
index 45fc3b5..81cc5b1 100644
--- a/vl.c
+++ b/vl.c
@@ -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;
-- 
1.7.9.111.gf3fb0.dirty

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all()
  2012-02-24 14:13 [Qemu-devel] [PATCH 0/5]: Improve machine type functions Luiz Capitulino
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void Luiz Capitulino
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 2/5] boards: rename machine type functions Luiz Capitulino
@ 2012-02-24 14:13 ` Luiz Capitulino
  2012-02-24 14:26   ` Andreas Färber
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ Luiz Capitulino
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 14:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

Print all registered machine types.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/boards.h |    1 +
 vl.c        |   25 ++++++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/hw/boards.h b/hw/boards.h
index 098cbb7..342a774 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -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;
 
diff --git a/vl.c b/vl.c
index 81cc5b1..9f9927c 100644
--- a/vl.c
+++ b/vl.c
@@ -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 != '?');
 }
 
-- 
1.7.9.111.gf3fb0.dirty

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
  2012-02-24 14:13 [Qemu-devel] [PATCH 0/5]: Improve machine type functions Luiz Capitulino
                   ` (2 preceding siblings ...)
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all() Luiz Capitulino
@ 2012-02-24 14:13 ` Luiz Capitulino
  2012-02-24 14:23   ` Andreas Färber
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c Luiz Capitulino
  2012-02-24 14:58 ` [Qemu-devel] [PATCH 0/5]: Improve machine type functions Anthony Liguori
  5 siblings, 1 reply; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 14:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/boards.h |    3 ++-
 vl.c        |   16 ++++++----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/hw/boards.h b/hw/boards.h
index 342a774..1eb8314 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -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);
diff --git a/vl.c b/vl.c
index 9f9927c..4935106 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
         }
-- 
1.7.9.111.gf3fb0.dirty

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c
  2012-02-24 14:13 [Qemu-devel] [PATCH 0/5]: Improve machine type functions Luiz Capitulino
                   ` (3 preceding siblings ...)
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ Luiz Capitulino
@ 2012-02-24 14:13 ` Luiz Capitulino
  2012-02-24 15:10   ` Andreas Färber
  2012-02-24 14:58 ` [Qemu-devel] [PATCH 0/5]: Improve machine type functions Anthony Liguori
  5 siblings, 1 reply; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 14:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori

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

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 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

diff --git a/Makefile.target b/Makefile.target
index d5eb70d..dc76eba 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -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
diff --git a/hw/boards.c b/hw/boards.c
new file mode 100644
index 0000000..73d6b93
--- /dev/null
+++ b/hw/boards.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "hw/boards.h"
+#include "qemu-queue.h"
+
+static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types = 
+    QTAILQ_HEAD_INITIALIZER(machine_types);
+QEMUMachine *current_machine = NULL;
+
+void machine_register(QEMUMachine *m)
+{
+    QTAILQ_INSERT_TAIL(&machine_types, m, next);
+}
+
+static QEMUMachine *machine_find(const char *name)
+{
+    QEMUMachine *m;
+
+    QTAILQ_FOREACH(m, &machine_types, next) {
+        if (!strcmp(m->name, name))
+            return m;
+        if (m->alias && !strcmp(m->alias, name))
+            return m;
+    }
+    return NULL;
+}
+
+QEMUMachine *machine_find_default(void)
+{
+    QEMUMachine *m;
+
+    QTAILQ_FOREACH(m, &machine_types, next) {
+        if (m->is_default) {
+            return m;
+        }
+    }
+    return NULL;
+}
+
+void machine_print_all(void)
+{
+    QEMUMachine *m;
+
+    printf("Supported machines are:\n");
+    QTAILQ_FOREACH(m, &machine_types, 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)" : "");
+    }
+}
+
+QEMUMachine *machine_parse(const char *name)
+{
+    QEMUMachine *machine = NULL;
+
+    if (name) {
+        machine = machine_find(name);
+    }
+    if (machine) {
+        return machine;
+    }
+    machine_print_all();
+    exit(!name || *name != '?');
+}
diff --git a/hw/boards.h b/hw/boards.h
index 1eb8314..d5e110f 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -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;
 
diff --git a/vl.c b/vl.c
index 4935106..4ae05fd 100644
--- a/vl.c
+++ b/vl.c
@@ -1158,57 +1158,6 @@ void pcmcia_info(Monitor *mon)
 }
 
 /***********************************************************/
-/* machine registration */
-
-static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types = 
-    QTAILQ_HEAD_INITIALIZER(machine_types);
-QEMUMachine *current_machine = NULL;
-
-void machine_register(QEMUMachine *m)
-{
-    QTAILQ_INSERT_TAIL(&machine_types, m, next);
-}
-
-static QEMUMachine *machine_find(const char *name)
-{
-    QEMUMachine *m;
-
-    QTAILQ_FOREACH(m, &machine_types, next) {
-        if (!strcmp(m->name, name))
-            return m;
-        if (m->alias && !strcmp(m->alias, name))
-            return m;
-    }
-    return NULL;
-}
-
-QEMUMachine *machine_find_default(void)
-{
-    QEMUMachine *m;
-
-    QTAILQ_FOREACH(m, &machine_types, next) {
-        if (m->is_default) {
-            return m;
-        }
-    }
-    return NULL;
-}
-
-void machine_print_all(void)
-{
-    QEMUMachine *m;
-
-    printf("Supported machines are:\n");
-    QTAILQ_FOREACH(m, &machine_types, 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 */
 
 static void gui_update(void *opaque)
@@ -1995,20 +1944,6 @@ static int debugcon_parse(const char *devname)
     return 0;
 }
 
-static QEMUMachine *machine_parse(const char *name)
-{
-    QEMUMachine *machine = NULL;
-
-    if (name) {
-        machine = machine_find(name);
-    }
-    if (machine) {
-        return machine;
-    }
-    machine_print_all();
-    exit(!name || *name != '?');
-}
-
 static int tcg_init(void)
 {
     tcg_exec_init(tcg_tb_size * 1024 * 1024);
-- 
1.7.9.111.gf3fb0.dirty

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void Luiz Capitulino
@ 2012-02-24 14:17   ` Andreas Färber
  0 siblings, 0 replies; 22+ messages in thread
From: Andreas Färber @ 2012-02-24 14:17 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, qemu-devel

Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> It never fails.

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

> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas

> ---
>  hw/boards.h |    2 +-
>  vl.c        |    3 +--
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/boards.h b/hw/boards.h
> index 667177d..7a9899f 100644
> --- a/hw/boards.h
> +++ b/hw/boards.h
> @@ -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;
> diff --git a/vl.c b/vl.c
> index 7a8cc08..45fc3b5 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -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)

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ Luiz Capitulino
@ 2012-02-24 14:23   ` Andreas Färber
  2012-02-24 14:56     ` Luiz Capitulino
  0 siblings, 1 reply; 22+ messages in thread
From: Andreas Färber @ 2012-02-24 14:23 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, qemu-devel

Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>

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

> ---
>  hw/boards.h |    3 ++-
>  vl.c        |   16 ++++++----------
>  2 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/hw/boards.h b/hw/boards.h
> index 342a774..1eb8314 100644
> --- a/hw/boards.h
> +++ b/hw/boards.h
> @@ -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);
> diff --git a/vl.c b/vl.c
> index 9f9927c..4935106 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -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);
>          }

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all()
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all() Luiz Capitulino
@ 2012-02-24 14:26   ` Andreas Färber
  2012-02-24 14:57     ` Luiz Capitulino
  0 siblings, 1 reply; 22+ messages in thread
From: Andreas Färber @ 2012-02-24 14:26 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Peter Maydell, aliguori, qemu-devel

Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> Print all registered machine types.
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>

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

> ---
>  hw/boards.h |    1 +
>  vl.c        |   25 ++++++++++++++++---------
>  2 files changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/boards.h b/hw/boards.h
> index 098cbb7..342a774 100644
> --- a/hw/boards.h
> +++ b/hw/boards.h
> @@ -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;
>  
> diff --git a/vl.c b/vl.c
> index 81cc5b1..9f9927c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -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 != '?');
>  }
>  

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
  2012-02-24 14:23   ` Andreas Färber
@ 2012-02-24 14:56     ` Luiz Capitulino
  2012-02-24 15:21       ` Andreas Färber
  0 siblings, 1 reply; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 14:56 UTC (permalink / raw)
  To: Andreas Färber; +Cc: aliguori, qemu-devel

On Fri, 24 Feb 2012 15:23:43 +0100
Andreas Färber <afaerber@suse.de> wrote:

> Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> 
> 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.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all()
  2012-02-24 14:26   ` Andreas Färber
@ 2012-02-24 14:57     ` Luiz Capitulino
  0 siblings, 0 replies; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 14:57 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Peter Maydell, aliguori, qemu-devel

On Fri, 24 Feb 2012 15:26:36 +0100
Andreas Färber <afaerber@suse.de> wrote:

> Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> > Print all registered machine types.
> > 
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> 
> I'm okay with the code movement, but is there a reason not to make it
> static?

I can make it static.

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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5]: Improve machine type functions
  2012-02-24 14:13 [Qemu-devel] [PATCH 0/5]: Improve machine type functions Luiz Capitulino
                   ` (4 preceding siblings ...)
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c Luiz Capitulino
@ 2012-02-24 14:58 ` Anthony Liguori
  2012-02-24 15:20   ` Luiz Capitulino
  5 siblings, 1 reply; 22+ messages in thread
From: Anthony Liguori @ 2012-02-24 14:58 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Peter Maydell, qemu-devel, Andreas Färber

On 02/24/2012 08:13 AM, Luiz Capitulino wrote:
> 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

>
>   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(-)
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c Luiz Capitulino
@ 2012-02-24 15:10   ` Andreas Färber
  2012-02-24 15:22     ` Luiz Capitulino
  0 siblings, 1 reply; 22+ messages in thread
From: Andreas Färber @ 2012-02-24 15:10 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, qemu-devel

Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> The license text is the same as used in vl.c. Also note that it's
> necessary to make machine_parse() public.
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  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.

> diff --git a/Makefile.target b/Makefile.target
> index d5eb70d..dc76eba 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -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

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5]: Improve machine type functions
  2012-02-24 14:58 ` [Qemu-devel] [PATCH 0/5]: Improve machine type functions Anthony Liguori
@ 2012-02-24 15:20   ` Luiz Capitulino
  2012-02-24 15:44     ` Anthony Liguori
  0 siblings, 1 reply; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 15:20 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Peter Maydell, qemu-devel, Andreas Färber

On Fri, 24 Feb 2012 08:58:55 -0600
Anthony Liguori <aliguori@us.ibm.com> wrote:

> On 02/24/2012 08:13 AM, Luiz Capitulino wrote:
> > 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.

[...]

> 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.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
  2012-02-24 14:56     ` Luiz Capitulino
@ 2012-02-24 15:21       ` Andreas Färber
  2012-02-24 15:23         ` Luiz Capitulino
  0 siblings, 1 reply; 22+ messages in thread
From: Andreas Färber @ 2012-02-24 15:21 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Paolo Bonzini, aliguori, qemu-devel

Am 24.02.2012 15:56, schrieb Luiz Capitulino:
> On Fri, 24 Feb 2012 15:23:43 +0100
> Andreas Färber <afaerber@suse.de> wrote:
> 
>> Am 24.02.2012 15:13, schrieb Luiz Capitulino:
>>> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
>>
>> 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

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c
  2012-02-24 15:10   ` Andreas Färber
@ 2012-02-24 15:22     ` Luiz Capitulino
  0 siblings, 0 replies; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 15:22 UTC (permalink / raw)
  To: Andreas Färber; +Cc: aliguori, qemu-devel

On Fri, 24 Feb 2012 16:10:17 +0100
Andreas Färber <afaerber@suse.de> wrote:

> Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> > The license text is the same as used in vl.c. Also note that it's
> > necessary to make machine_parse() public.
> > 
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > ---
> >  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.

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.

> > diff --git a/Makefile.target b/Makefile.target
> > index d5eb70d..dc76eba 100644
> > --- a/Makefile.target
> > +++ b/Makefile.target
> > @@ -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.

Ok.

> 
> Otherwise looks okay.
> 
> Andreas
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ
  2012-02-24 15:21       ` Andreas Färber
@ 2012-02-24 15:23         ` Luiz Capitulino
  0 siblings, 0 replies; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 15:23 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Paolo Bonzini, aliguori, qemu-devel

On Fri, 24 Feb 2012 16:21:56 +0100
Andreas Färber <afaerber@suse.de> wrote:

> Am 24.02.2012 15:56, schrieb Luiz Capitulino:
> > On Fri, 24 Feb 2012 15:23:43 +0100
> > Andreas Färber <afaerber@suse.de> wrote:
> > 
> >> Am 24.02.2012 15:13, schrieb Luiz Capitulino:
> >>> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> >>
> >> 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. :)

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5]: Improve machine type functions
  2012-02-24 15:20   ` Luiz Capitulino
@ 2012-02-24 15:44     ` Anthony Liguori
  0 siblings, 0 replies; 22+ messages in thread
From: Anthony Liguori @ 2012-02-24 15:44 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Peter Maydell, qemu-devel, Andreas Färber

On 02/24/2012 09:20 AM, Luiz Capitulino wrote:
> On Fri, 24 Feb 2012 08:58:55 -0600
> Anthony Liguori<aliguori@us.ibm.com>  wrote:
>
>> On 02/24/2012 08:13 AM, Luiz Capitulino wrote:
>>> 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
> 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

>
> [...]
>
>> 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.
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions
  2012-02-24 14:13 ` [Qemu-devel] [PATCH 2/5] boards: rename machine type functions Luiz Capitulino
@ 2012-02-24 16:12   ` Peter Maydell
  2012-02-24 16:15     ` Anthony Liguori
  0 siblings, 1 reply; 22+ messages in thread
From: Peter Maydell @ 2012-02-24 16:12 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, qemu-devel

On 24 February 2012 14:13, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> Perform the following renames:
>
>  o qemu_register_machine() -> machine_register()
>  o find_machine() -> machine_find()
>  o find_default_machine()  -> machine_find_default()
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
>  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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions
  2012-02-24 16:12   ` Peter Maydell
@ 2012-02-24 16:15     ` Anthony Liguori
  2012-02-24 16:51       ` Luiz Capitulino
  0 siblings, 1 reply; 22+ messages in thread
From: Anthony Liguori @ 2012-02-24 16:15 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, Luiz Capitulino

On 02/24/2012 10:12 AM, Peter Maydell wrote:
> On 24 February 2012 14:13, Luiz Capitulino<lcapitulino@redhat.com>  wrote:
>> Perform the following renames:
>>
>>   o qemu_register_machine() ->  machine_register()
>>   o find_machine() ->  machine_find()
>>   o find_default_machine()  ->  machine_find_default()
>>
>> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
>>   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.

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

>
> -- PMM
>
>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions
  2012-02-24 16:15     ` Anthony Liguori
@ 2012-02-24 16:51       ` Luiz Capitulino
  2012-02-24 16:57         ` Anthony Liguori
  0 siblings, 1 reply; 22+ messages in thread
From: Luiz Capitulino @ 2012-02-24 16:51 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Peter Maydell, qemu-devel

On Fri, 24 Feb 2012 10:15:52 -0600
Anthony Liguori <aliguori@us.ibm.com> wrote:

> On 02/24/2012 10:12 AM, Peter Maydell wrote:
> > On 24 February 2012 14:13, Luiz Capitulino<lcapitulino@redhat.com>  wrote:
> >> Perform the following renames:
> >>
> >>   o qemu_register_machine() ->  machine_register()
> >>   o find_machine() ->  machine_find()
> >>   o find_default_machine()  ->  machine_find_default()
> >>
> >> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
> >>   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.
> 
> 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).

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] boards: rename machine type functions
  2012-02-24 16:51       ` Luiz Capitulino
@ 2012-02-24 16:57         ` Anthony Liguori
  0 siblings, 0 replies; 22+ messages in thread
From: Anthony Liguori @ 2012-02-24 16:57 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Peter Maydell, qemu-devel

On 02/24/2012 10:51 AM, Luiz Capitulino wrote:
> On Fri, 24 Feb 2012 10:15:52 -0600
> Anthony Liguori<aliguori@us.ibm.com>  wrote:
>
>> On 02/24/2012 10:12 AM, Peter Maydell wrote:
>>> On 24 February 2012 14:13, Luiz Capitulino<lcapitulino@redhat.com>   wrote:
>>>> Perform the following renames:
>>>>
>>>>    o qemu_register_machine() ->   machine_register()
>>>>    o find_machine() ->   machine_find()
>>>>    o find_default_machine()  ->   machine_find_default()
>>>>
>>>> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
>>>>    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.
>>
>> 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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2012-02-24 16:59 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-24 14:13 [Qemu-devel] [PATCH 0/5]: Improve machine type functions Luiz Capitulino
2012-02-24 14:13 ` [Qemu-devel] [PATCH 1/5] boards: qemu_register_machine(): return void Luiz Capitulino
2012-02-24 14:17   ` Andreas Färber
2012-02-24 14:13 ` [Qemu-devel] [PATCH 2/5] boards: rename machine type functions Luiz Capitulino
2012-02-24 16:12   ` Peter Maydell
2012-02-24 16:15     ` Anthony Liguori
2012-02-24 16:51       ` Luiz Capitulino
2012-02-24 16:57         ` Anthony Liguori
2012-02-24 14:13 ` [Qemu-devel] [PATCH 3/5] boards: introduce machine_print_all() Luiz Capitulino
2012-02-24 14:26   ` Andreas Färber
2012-02-24 14:57     ` Luiz Capitulino
2012-02-24 14:13 ` [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ Luiz Capitulino
2012-02-24 14:23   ` Andreas Färber
2012-02-24 14:56     ` Luiz Capitulino
2012-02-24 15:21       ` Andreas Färber
2012-02-24 15:23         ` Luiz Capitulino
2012-02-24 14:13 ` [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c Luiz Capitulino
2012-02-24 15:10   ` Andreas Färber
2012-02-24 15:22     ` Luiz Capitulino
2012-02-24 14:58 ` [Qemu-devel] [PATCH 0/5]: Improve machine type functions Anthony Liguori
2012-02-24 15:20   ` Luiz Capitulino
2012-02-24 15:44     ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).