From patchwork Mon Jun 7 23:52:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 54915 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 18761B7D1C for ; Tue, 8 Jun 2010 10:25:11 +1000 (EST) Received: from localhost ([127.0.0.1]:53396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLmct-0004u5-JW for incoming@patchwork.ozlabs.org; Mon, 07 Jun 2010 20:25:07 -0400 Received: from [140.186.70.92] (port=43967 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLm7H-0004Oo-3y for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OLm7D-0003Aw-Vo for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:26 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:58904) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLm7D-0003Ah-Qj for qemu-devel@nongnu.org; Mon, 07 Jun 2010 19:52:23 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o57Ncw8i004714 for ; Mon, 7 Jun 2010 19:38:58 -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 o57NqMgE798900 for ; Mon, 7 Jun 2010 19:52:22 -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 o57NqMnM010396 for ; Mon, 7 Jun 2010 20:52:22 -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 o57NqDr1009965; Mon, 7 Jun 2010 20:52:21 -0300 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 7 Jun 2010 18:52:00 -0500 Message-Id: <1275954730-8196-13-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 12/22] machine: some sugary macros to simplify machine default options 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 c7358ae..e05637b 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -33,6 +33,12 @@ int qemu_register_machine(QEMUMachine *m); extern QEMUMachine *current_machine; +#define QOPT_COMPAT(driver, property, value) \ + QOPT_VALUE(driver "." property, value) + +#define QOPT_COMPAT_INT(driver, property, value) \ + QOPT_VALUE(driver "." property, stringify(value)) + #define COMMON_MACHINE_OPTS() \ { \ .name = "driver", \ diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 28c1408..104206c 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -190,18 +190,9 @@ static QEMUMachine pc_machine = { .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, - }, + QOPT_VALUE("acpi", "on"), + QOPT_VALUE("pci", "on"), + QOPT_VALUE("cpu", PC_DEFAULT_CPU_MODEL), { /* end of list */ } }, }; @@ -213,25 +204,11 @@ static QEMUMachine pc_machine_v0_12 = { .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, - }, - { - .name = "virtio-serial-pci.max_nr_ports", - .value = stringify(1), - },{ - .name = "virtio-serial-pci.vectors", - .value = stringify(0), - }, + QOPT_VALUE("acpi", "on"), + QOPT_VALUE("pci", "on"), + QOPT_VALUE("cpu", PC_DEFAULT_CPU_MODEL), + QOPT_COMPAT_INT("virtio-serial-pci", "max_nr_ports", 1), + QOPT_COMPAT_INT("virtio-serial-pci", "vectors", 0), { /* end of list */ } }, }; @@ -243,37 +220,15 @@ static QEMUMachine pc_machine_v0_11 = { .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, - }, - { - .name = "virtio-blk-pci.vectors", - .value = stringify(0), - },{ - .name = "virtio-serial-pci.max_nr_ports", - .value = stringify(1), - },{ - .name = "virtio-serial-pci.vectors", - .value = stringify(0), - },{ - .name = "ide-drive.ver", - .value = "0.11", - },{ - .name = "scsi-disk.ver", - .value = "0.11", - },{ - .name = "PCI.rombar", - .value = stringify(0), - }, + QOPT_VALUE("acpi", "on"), + QOPT_VALUE("pci", "on"), + QOPT_VALUE("cpu", PC_DEFAULT_CPU_MODEL), + QOPT_COMPAT_INT("virtio-blk-pci", "vectors", 0), + QOPT_COMPAT_INT("virtio-serial-pci", "max_nr_ports", 1), + QOPT_COMPAT_INT("virtio-serial-pci", "vectors", 0), + QOPT_COMPAT("ide-drive", "ver", "0.11"), + QOPT_COMPAT("scsi-disk", "ver", "0.11"), + QOPT_COMPAT_INT("PCI", "rombar", 0), { /* end of list */ } } }; @@ -285,46 +240,18 @@ static QEMUMachine pc_machine_v0_10 = { .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, - }, - { - .name = "virtio-blk-pci.class", - .value = stringify(PCI_CLASS_STORAGE_OTHER), - },{ - .name = "virtio-serial-pci.class", - .value = stringify(PCI_CLASS_DISPLAY_OTHER), - },{ - .name = "virtio-serial-pci.max_nr_ports", - .value = stringify(1), - },{ - .name = "virtio-serial-pci.vectors", - .value = stringify(0), - },{ - .name = "virtio-net-pci.vectors", - .value = stringify(0), - },{ - .name = "virtio-blk-pci.vectors", - .value = stringify(0), - },{ - .name = "ide-drive.ver", - .value = "0.10", - },{ - .name = "scsi-disk.ver", - .value = "0.10", - },{ - .name = "PCI.rombar", - .value = stringify(0), - }, + QOPT_VALUE("acpi", "on"), + QOPT_VALUE("pci", "on"), + QOPT_VALUE("cpu", PC_DEFAULT_CPU_MODEL), + QOPT_COMPAT_INT("virtio-blk-pci", "class", PCI_CLASS_STORAGE_OTHER), + QOPT_COMPAT_INT("virtio-serial-pci", "class", PCI_CLASS_DISPLAY_OTHER), + QOPT_COMPAT_INT("virtio-net-pci", "vectors", 0), + QOPT_COMPAT_INT("virtio-blk-pci", "vectors", 0), + QOPT_COMPAT_INT("virtio-serial-pci", "max_nr_ports", 1), + QOPT_COMPAT_INT("virtio-serial-pci", "vectors", 0), + QOPT_COMPAT("ide-drive", "ver", "0.10"), + QOPT_COMPAT("scsi-disk", "ver", "0.10"), + QOPT_COMPAT_INT("PCI", "rombar", 0), { /* end of list */ } }, }; @@ -335,18 +262,9 @@ static QEMUMachine isapc_machine = { .opts_desc = pc_opts_desc, .init = pc_init, .opts_default = (QemuOptValue[]) { - { - .name = "acpi", - .value = "off", - }, - { - .name = "pci", - .value = "off", - }, - { - .name = "cpu", - .value = "486", - }, + QOPT_VALUE("acpi", "off"), + QOPT_VALUE("pci", "off"), + QOPT_VALUE("cpu", "486"), { /* end of list */ } }, .max_cpus = 1, diff --git a/qemu-option.h b/qemu-option.h index 85ab58e..5fc60ac 100644 --- a/qemu-option.h +++ b/qemu-option.h @@ -109,6 +109,12 @@ typedef struct QemuOptValue { const char *value; } QemuOptValue; +#define QOPT_VALUE(_name, _value) \ + { \ + .name = _name, \ + .value = _value, \ + } + const char *qemu_opt_get(QemuOpts *opts, const char *name); int qemu_opt_get_bool(QemuOpts *opts, const char *name, int defval); uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval);