Skip to contentSkip to conversation

: Improve machine type functions

PATCH New Luiz Capitulino 1 participant 4 messages Feb 24, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover : Improve machine type functions

Actually, the major change is to move the machine type functions to boards.c. But I wanted to keep the same subject as v1.

v2:

o Drop function renames
o Drop machine type list conversion to QTAILQ
o Rebase against latest master
o Other minor changes

 Makefile.target |    1 +
 hw/boards.c     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/boards.h     |    3 +-
 vl.c            |   63 ---------------------------------------
 4 files changed, 91 insertions(+), 64 deletions(-)
#1 lore raw

PATCH v2 1/3 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 cd77852..728eb36 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
#2 lore raw

PATCH v2 2/3 boards: introduce machine_print_all()

In reply to Luiz Capitulino

It prints all registered machine types.

---
 vl.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)
vl.c +16 -9
index 728eb36..ced7068 100644
@@ -1198,6 +1198,20 @@ QEMUMachine *find_default_machine(void)
     return NULL;
 }
 
+static 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("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
+        }
+        printf("%-20s %s%s\n", m->name, m->desc,
+               m->is_default ? " (default)" : "");
+    }
+}
+
 /***********************************************************/
 /* main execution loop */
 
@@ -1992,7 +2006,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 = find_machine(name);
@@ -2000,14 +2014,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("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
-        }
-        printf("%-20s %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
#3 lore raw

PATCH v2 3/3 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 |    1 +
 hw/boards.c     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/boards.h     |    1 +
 vl.c            |   69 -------------------------------------------
 4 files changed, 90 insertions(+), 69 deletions(-)
 create mode 100644 hw/boards.c
Makefile.target +1 -0
index 68a5641..20ba1e7 100644
@@ -196,6 +196,7 @@ endif #CONFIG_BSD_USER
 ifdef CONFIG_SOFTMMU
 
 obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o
+obj-y += 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 +88 -0

88 lines not on this page · raw message

hw/boards.h +1 -0
index 7a9899f..a9b0c8c 100644
@@ -33,6 +33,7 @@ typedef struct QEMUMachine {
 
 void qemu_register_machine(QEMUMachine *m);
 QEMUMachine *find_default_machine(void);
+QEMUMachine *machine_parse(const char *name);
 
 extern QEMUMachine *current_machine;
 
vl.c +0 -69

81 lines not on this page · raw message

Signature · 1 line
1.7.9.111.gf3fb0.dirty