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