Patchwork [3/3] boards: move all machine type functions to boards.c

login
register
mail settings
Submitter Luiz Capitulino
Date Feb. 24, 2012, 7:36 p.m.
Message ID <1330112189-29280-4-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/142966/
State New
Headers show

Comments

Luiz Capitulino - Feb. 24, 2012, 7:36 p.m.
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 |    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

Patch

diff --git a/Makefile.target b/Makefile.target
index 68a5641..20ba1e7 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -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
diff --git a/hw/boards.c b/hw/boards.c
new file mode 100644
index 0000000..2692930
--- /dev/null
+++ b/hw/boards.c
@@ -0,0 +1,88 @@ 
+/*
+ * 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"
+
+static QEMUMachine *first_machine = NULL;
+QEMUMachine *current_machine = NULL;
+
+void qemu_register_machine(QEMUMachine *m)
+{
+    QEMUMachine **pm;
+    pm = &first_machine;
+    while (*pm != NULL)
+        pm = &(*pm)->next;
+    m->next = NULL;
+    *pm = m;
+}
+
+static QEMUMachine *find_machine(const char *name)
+{
+    QEMUMachine *m;
+
+    for(m = first_machine; m != NULL; m = m->next) {
+        if (!strcmp(m->name, name))
+            return m;
+        if (m->alias && !strcmp(m->alias, name))
+            return m;
+    }
+    return NULL;
+}
+
+QEMUMachine *find_default_machine(void)
+{
+    QEMUMachine *m;
+
+    for(m = first_machine; m != NULL; m = m->next) {
+        if (m->is_default) {
+            return m;
+        }
+    }
+    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)" : "");
+    }
+}
+
+QEMUMachine *machine_parse(const char *name)
+{
+    QEMUMachine *machine = NULL;
+
+    if (name) {
+        machine = find_machine(name);
+    }
+    if (machine) {
+        return machine;
+    }
+    machine_print_all();
+    exit(!name || *name != '?');
+}
diff --git a/hw/boards.h b/hw/boards.h
index 7a9899f..a9b0c8c 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -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;
 
diff --git a/vl.c b/vl.c
index ced7068..949cfd8 100644
--- a/vl.c
+++ b/vl.c
@@ -1158,61 +1158,6 @@  void pcmcia_info(Monitor *mon)
 }
 
 /***********************************************************/
-/* machine registration */
-
-static QEMUMachine *first_machine = NULL;
-QEMUMachine *current_machine = NULL;
-
-void qemu_register_machine(QEMUMachine *m)
-{
-    QEMUMachine **pm;
-    pm = &first_machine;
-    while (*pm != NULL)
-        pm = &(*pm)->next;
-    m->next = NULL;
-    *pm = m;
-}
-
-static QEMUMachine *find_machine(const char *name)
-{
-    QEMUMachine *m;
-
-    for(m = first_machine; m != NULL; m = m->next) {
-        if (!strcmp(m->name, name))
-            return m;
-        if (m->alias && !strcmp(m->alias, name))
-            return m;
-    }
-    return NULL;
-}
-
-QEMUMachine *find_default_machine(void)
-{
-    QEMUMachine *m;
-
-    for(m = first_machine; m != NULL; m = m->next) {
-        if (m->is_default) {
-            return m;
-        }
-    }
-    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 */
 
 static void gui_update(void *opaque)
@@ -2004,20 +1949,6 @@  static int debugcon_parse(const char *devname)
     return 0;
 }
 
-static QEMUMachine *machine_parse(const char *name)
-{
-    QEMUMachine *machine = NULL;
-
-    if (name) {
-        machine = find_machine(name);
-    }
-    if (machine) {
-        return machine;
-    }
-    machine_print_all();
-    exit(!name || *name != '?');
-}
-
 static int tcg_init(void)
 {
     tcg_exec_init(tcg_tb_size * 1024 * 1024);