From patchwork Mon Jun 7 23:51:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 54903 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 1DB30B7D43 for ; Tue, 8 Jun 2010 10:05:32 +1000 (EST) Received: from localhost ([127.0.0.1]:58303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLmJD-0002Dt-A2 for incoming@patchwork.ozlabs.org; Mon, 07 Jun 2010 20:04:47 -0400 Received: from [140.186.70.92] (port=43988 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLm7I-0004Pk-3Z for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OLm7E-0003BM-Ba for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:27 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:37357) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLm7E-0003BB-8A for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:24 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by e4.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o57NdHHH009788 for ; Mon, 7 Jun 2010 19:39:17 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o57NqI1W1015836 for ; Mon, 7 Jun 2010 19:52:19 -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 o57NqIhd010216 for ; Mon, 7 Jun 2010 20:52:18 -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 o57NqDqt009965; Mon, 7 Jun 2010 20:52:17 -0300 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 7 Jun 2010 18:51:54 -0500 Message-Id: <1275954730-8196-7-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 06/22] Make -acpi-enable a machine specific option 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 Signed-off-by: Anthony Liguori diff --git a/hw/boards.h b/hw/boards.h index c3f4f68..728908b 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -25,6 +25,7 @@ struct QEMUMachine { no_sdcard:1; int is_default; GlobalProperty *compat_props; + QemuOptDesc *opts_desc; struct QEMUMachine *next; }; @@ -32,4 +33,29 @@ int qemu_register_machine(QEMUMachine *m); extern QEMUMachine *current_machine; +#define COMMON_MACHINE_OPTS() \ + { \ + .name = "ram_size", \ + .type = QEMU_OPT_SIZE, \ + },{ \ + .name = "kernel", \ + .type = QEMU_OPT_STRING, \ + }, \ + { \ + .name = "cmdline", \ + .type = QEMU_OPT_STRING, \ + }, \ + { \ + .name = "initrd", \ + .type = QEMU_OPT_STRING, \ + }, \ + { \ + .name = "boot_device", \ + .type = QEMU_OPT_STRING, \ + }, \ + { \ + .name = "cpu", \ + .type = QEMU_OPT_STRING, \ + } + #endif diff --git a/hw/pc.h b/hw/pc.h index 0e52933..1ae61e0 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -110,7 +110,6 @@ typedef void (*cpu_set_smm_t)(int smm, void *arg); void cpu_smm_register(cpu_set_smm_t callback, void *arg); /* acpi.c */ -extern int acpi_enabled; extern char *acpi_tables; extern size_t acpi_tables_len; diff --git a/hw/pc_piix.c b/hw/pc_piix.c index c58cd42..1830aca 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -40,14 +40,14 @@ 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(ram_addr_t ram_size, - const char *boot_device, - const char *kernel_filename, - const char *kernel_cmdline, - const char *initrd_filename, - const char *cpu_model, - int pci_enabled) +static void pc_init1(QemuOpts *opts, int pci_enabled) { + ram_addr_t ram_size = qemu_opt_get_size(opts, "ram_size", 0); + const char *boot_device = qemu_opt_get(opts, "boot_device"); + const char *kernel_filename = qemu_opt_get(opts, "kernel"); + 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 i; ram_addr_t below_4g_mem_size, above_4g_mem_size; PCIBus *pci_bus; @@ -133,7 +133,7 @@ static void pc_init1(ram_addr_t ram_size, usb_uhci_piix3_init(pci_bus, piix3_devfn + 2); } - if (pci_enabled && acpi_enabled) { + if (pci_enabled && qemu_opt_get_bool(opts, "acpi", 1)) { uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */ i2c_bus *smbus; @@ -163,32 +163,27 @@ static void pc_init1(ram_addr_t ram_size, static void pc_init_pci(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"); - const char *kernel_filename = qemu_opt_get(opts, "kernel"); - 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"); - pc_init1(ram_size, boot_device, - kernel_filename, kernel_cmdline, - initrd_filename, cpu_model, 1); + pc_init1(opts, 1); } static void pc_init_isa(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"); - const char *kernel_filename = qemu_opt_get(opts, "kernel"); - 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"); - if (cpu_model == NULL) - cpu_model = "486"; - pc_init1(ram_size, boot_device, - kernel_filename, kernel_cmdline, - initrd_filename, cpu_model, 0); + 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, + }, + { /* end of list */ }, +}; + static QEMUMachine pc_machine = { .name = "pc-0.13", .alias = "pc", @@ -196,6 +191,7 @@ static QEMUMachine pc_machine = { .init = pc_init_pci, .max_cpus = 255, .is_default = 1, + .opts_desc = pc_opts_desc, }; static QEMUMachine pc_machine_v0_12 = { @@ -203,6 +199,7 @@ static QEMUMachine pc_machine_v0_12 = { .desc = "Standard PC", .init = pc_init_pci, .max_cpus = 255, + .opts_desc = pc_opts_desc, .compat_props = (GlobalProperty[]) { { .driver = "virtio-serial-pci", @@ -222,6 +219,7 @@ static QEMUMachine pc_machine_v0_11 = { .desc = "Standard PC, qemu 0.11", .init = pc_init_pci, .max_cpus = 255, + .opts_desc = pc_opts_desc, .compat_props = (GlobalProperty[]) { { .driver = "virtio-blk-pci", @@ -257,6 +255,7 @@ static QEMUMachine pc_machine_v0_10 = { .desc = "Standard PC, qemu 0.10", .init = pc_init_pci, .max_cpus = 255, + .opts_desc = pc_opts_desc, .compat_props = (GlobalProperty[]) { { .driver = "virtio-blk-pci", diff --git a/vl.c b/vl.c index 87009eb..4fc4c20 100644 --- a/vl.c +++ b/vl.c @@ -209,7 +209,7 @@ int max_cpus = 0; int smp_cores = 1; int smp_threads = 1; const char *vnc_display; -int acpi_enabled = 1; +static int acpi_enabled = 1; int no_hpet = 0; int fd_bootchk = 1; int no_reboot = 0; @@ -2550,32 +2550,8 @@ static const QEMUOption *lookup_opt(int argc, char **argv, return popt; } -/* TEMP: until we have proper -machine support */ static QemuOptDesc common_machine_opts[] = { - { - .name = "ram_size", - .type = QEMU_OPT_SIZE, - }, - { - .name = "kernel", - .type = QEMU_OPT_STRING, - }, - { - .name = "cmdline", - .type = QEMU_OPT_STRING, - }, - { - .name = "initrd", - .type = QEMU_OPT_STRING, - }, - { - .name = "boot_device", - .type = QEMU_OPT_STRING, - }, - { - .name = "cpu", - .type = QEMU_OPT_STRING, - }, + COMMON_MACHINE_OPTS(), { /* end of list */ }, }; @@ -3771,8 +3747,18 @@ int main(int argc, char **argv, char **envp) qemu_opt_set(opts, "ram_size", buffer); } - if (qemu_opts_validate(opts, common_machine_opts) < 0) { - exit(1); + if (acpi_enabled == 0) { + qemu_opt_set(opts, "acpi", "off"); + } + + if (machine->opts_desc) { + if (qemu_opts_validate(opts, machine->opts_desc) < 0) { + exit(1); + } + } else { + if (qemu_opts_validate(opts, common_machine_opts) < 0) { + exit(1); + } } machine->init(opts);