From patchwork Mon Jun 7 23:51:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 54907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4B050B7D43 for ; Tue, 8 Jun 2010 10:13:19 +1000 (EST) Received: from localhost ([127.0.0.1]:39490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLmQk-0007bz-QQ for incoming@patchwork.ozlabs.org; Mon, 07 Jun 2010 20:12:34 -0400 Received: from [140.186.70.92] (port=43946 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLm7F-0004NK-H0 for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OLm7D-0003AT-1l for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:25 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:48536) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLm7C-0003AI-Us for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:23 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e2.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o57Ndqas020597 for ; Mon, 7 Jun 2010 19:39:52 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o57NqL731552498 for ; Mon, 7 Jun 2010 19:52:21 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o57NqKv2010344 for ; Mon, 7 Jun 2010 20:52:21 -0300 Received: from localhost.localdomain (sig-9-65-84-205.mts.ibm.com [9.65.84.205]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o57NqDqx009965; Mon, 7 Jun 2010 20:52:20 -0300 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 7 Jun 2010 18:51:58 -0500 Message-Id: <1275954730-8196-11-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1275954730-8196-1-git-send-email-aliguori@us.ibm.com> References: <1275954730-8196-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Glauber Costa , Anthony Liguori Subject: [Qemu-devel] [PATCH 10/22] machine: allow boards to specify default values and use it in isapc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Let boards describe default options. Structuring this way is an important step in making board definitions readable by a config file. To use the new mechanism, introduce a pci=on|off option to the pc boards and unify all of them into a single function. isapc is now just another pc board that happens to have different default values. Signed-off-by: Anthony Liguori diff --git a/hw/boards.h b/hw/boards.h index 0092557..06b9f73 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -26,6 +26,7 @@ struct QEMUMachine { int is_default; GlobalProperty *compat_props; QemuOptDesc *opts_desc; + QemuOptValue *opts_default; struct QEMUMachine *next; }; diff --git a/hw/pc.c b/hw/pc.c index 48b3730..44f5b62 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -794,15 +794,6 @@ void pc_cpus_init(const char *cpu_model) { int i; - /* init CPUs */ - if (cpu_model == NULL) { -#ifdef TARGET_X86_64 - cpu_model = "qemu64"; -#else - cpu_model = "qemu32"; -#endif - } - for(i = 0; i < smp_cpus; i++) { pc_new_cpu(cpu_model); } diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 1830aca..0ad1145 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -40,7 +40,7 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; /* PC hardware initialisation */ -static void pc_init1(QemuOpts *opts, int pci_enabled) +static void pc_init(QemuOpts *opts) { ram_addr_t ram_size = qemu_opt_get_size(opts, "ram_size", 0); const char *boot_device = qemu_opt_get(opts, "boot_device"); @@ -48,6 +48,7 @@ static void pc_init1(QemuOpts *opts, int pci_enabled) const char *kernel_cmdline = qemu_opt_get(opts, "cmdline"); const char *initrd_filename = qemu_opt_get(opts, "initrd"); const char *cpu_model = qemu_opt_get(opts, "cpu"); + int pci_enabled = qemu_opt_get_bool(opts, "pci", 1); int i; ram_addr_t below_4g_mem_size, above_4g_mem_size; PCIBus *pci_bus; @@ -161,45 +162,71 @@ static void pc_init1(QemuOpts *opts, int pci_enabled) } } -static void pc_init_pci(QemuOpts *opts) -{ - pc_init1(opts, 1); -} - -static void pc_init_isa(QemuOpts *opts) -{ - if (!qemu_opt_get(opts, "cpu")) { - qemu_opt_set(opts, "cpu", "486"); - } - - pc_init1(opts, 0); -} - static QemuOptDesc pc_opts_desc[] = { COMMON_MACHINE_OPTS(), { .name = "acpi", .type = QEMU_OPT_BOOL, }, + { + .name = "pci", + .type = QEMU_OPT_BOOL, + }, { /* end of list */ }, }; +#ifdef TARGET_X86_64 +#define PC_DEFAULT_CPU_MODEL "qemu64" +#else +#define PC_DEFAULT_CPU_MODEL "qemu32" +#endif + static QEMUMachine pc_machine = { .name = "pc-0.13", .alias = "pc", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init, .max_cpus = 255, .is_default = 1, .opts_desc = pc_opts_desc, + .opts_default = (QemuOptValue[]) { + { + .name = "acpi", + .value = "on", + }, + { + .name = "pci", + .value = "on", + }, + { + .name = "cpu", + .value = PC_DEFAULT_CPU_MODEL, + }, + { /* end of list */ } + }, }; static QEMUMachine pc_machine_v0_12 = { .name = "pc-0.12", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init, .max_cpus = 255, .opts_desc = pc_opts_desc, + .opts_default = (QemuOptValue[]) { + { + .name = "acpi", + .value = "on", + }, + { + .name = "pci", + .value = "on", + }, + { + .name = "cpu", + .value = PC_DEFAULT_CPU_MODEL, + }, + { /* end of list */ } + }, .compat_props = (GlobalProperty[]) { { .driver = "virtio-serial-pci", @@ -217,9 +244,24 @@ static QEMUMachine pc_machine_v0_12 = { static QEMUMachine pc_machine_v0_11 = { .name = "pc-0.11", .desc = "Standard PC, qemu 0.11", - .init = pc_init_pci, + .init = pc_init, .max_cpus = 255, .opts_desc = pc_opts_desc, + .opts_default = (QemuOptValue[]) { + { + .name = "acpi", + .value = "on", + }, + { + .name = "pci", + .value = "on", + }, + { + .name = "cpu", + .value = PC_DEFAULT_CPU_MODEL, + }, + { /* end of list */ } + }, .compat_props = (GlobalProperty[]) { { .driver = "virtio-blk-pci", @@ -253,9 +295,24 @@ static QEMUMachine pc_machine_v0_11 = { static QEMUMachine pc_machine_v0_10 = { .name = "pc-0.10", .desc = "Standard PC, qemu 0.10", - .init = pc_init_pci, + .init = pc_init, .max_cpus = 255, .opts_desc = pc_opts_desc, + .opts_default = (QemuOptValue[]) { + { + .name = "acpi", + .value = "on", + }, + { + .name = "pci", + .value = "on", + }, + { + .name = "cpu", + .value = PC_DEFAULT_CPU_MODEL, + }, + { /* end of list */ } + }, .compat_props = (GlobalProperty[]) { { .driver = "virtio-blk-pci", @@ -301,7 +358,23 @@ static QEMUMachine pc_machine_v0_10 = { static QEMUMachine isapc_machine = { .name = "isapc", .desc = "ISA-only PC", - .init = pc_init_isa, + .opts_desc = pc_opts_desc, + .init = pc_init, + .opts_default = (QemuOptValue[]) { + { + .name = "acpi", + .value = "off", + }, + { + .name = "pci", + .value = "off", + }, + { + .name = "cpu", + .value = "486", + }, + { /* end of list */ } + }, .max_cpus = 1, }; diff --git a/vl.c b/vl.c index 398d3b4..a7f0a3d 100644 --- a/vl.c +++ b/vl.c @@ -3438,6 +3438,10 @@ int main(int argc, char **argv, char **envp) machine = find_machine(qemu_opt_get(machine_opts, "driver")); } + if (machine->opts_default) { + qemu_opts_set_defaults(machine_opts, machine->opts_default); + } + if (machine->opts_desc) { if (qemu_opts_validate(machine_opts, machine->opts_desc) < 0) { exit(1);