From patchwork Fri Feb 24 14:13:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 142895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EB17CB7986 for ; Sat, 25 Feb 2012 01:37:04 +1100 (EST) Received: from localhost ([::1]:46306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0vuY-0004iL-Ch for incoming@patchwork.ozlabs.org; Fri, 24 Feb 2012 09:14:14 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0vtt-0002Wl-Oa for qemu-devel@nongnu.org; Fri, 24 Feb 2012 09:13:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0vtn-0001Bz-MZ for qemu-devel@nongnu.org; Fri, 24 Feb 2012 09:13:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0vtn-0001Bq-Ff for qemu-devel@nongnu.org; Fri, 24 Feb 2012 09:13:27 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1OEDQUh016239 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 24 Feb 2012 09:13:26 -0500 Received: from localhost (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1OEDPNM008565; Fri, 24 Feb 2012 09:13:26 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Fri, 24 Feb 2012 12:13:12 -0200 Message-Id: <1330092792-22455-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1330092792-22455-1-git-send-email-lcapitulino@redhat.com> References: <1330092792-22455-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 5/5] boards: move all machine type functions to boards.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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);