From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Glauber Costa <glommer@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 10/22] machine: allow boards to specify default values and use it in isapc
Date: Mon, 7 Jun 2010 18:51:58 -0500 [thread overview]
Message-ID: <1275954730-8196-11-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1275954730-8196-1-git-send-email-aliguori@us.ibm.com>
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 <aliguori@us.ibm.com>
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);
--
1.7.0.4
next prev parent reply other threads:[~2010-06-07 23:52 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-07 23:51 [Qemu-devel] [PATCH 0/22] Refactor machine support Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 01/22] QemuOpts: fix a bug in QemuOpts when setting an option twice Anthony Liguori
2010-06-08 7:51 ` Gerd Hoffmann
2010-06-08 10:32 ` [Qemu-devel] " Paolo Bonzini
2010-06-08 13:07 ` Anthony Liguori
2010-06-08 13:44 ` Gerd Hoffmann
2010-06-08 15:17 ` Anthony Liguori
2010-06-08 15:37 ` Gerd Hoffmann
2010-06-08 16:04 ` Anthony Liguori
2010-06-09 7:01 ` Gerd Hoffmann
2010-06-08 14:38 ` Paul Brook
2010-06-08 15:14 ` Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 02/22] QemuOpts: make qemu_opts_validate() store the description list for later use Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 03/22] QemuOpts: add function to set QemuOpts from defaults Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 04/22] machine: package all init arguments into a QemuOpts (v2) Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 05/22] machine: pass all init options as a single QemuOpts Anthony Liguori
2010-06-08 7:58 ` Gerd Hoffmann
2010-06-07 23:51 ` [Qemu-devel] [PATCH 06/22] Make -acpi-enable a machine specific option Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 07/22] machine: introduce -machine option Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 08/22] machine: implement -kernel/-append/-initrd options in term of -machine Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 09/22] machine: implement -m in terms " Anthony Liguori
2010-06-07 23:51 ` Anthony Liguori [this message]
2010-06-08 8:03 ` [Qemu-devel] [PATCH 10/22] machine: allow boards to specify default values and use it in isapc Gerd Hoffmann
2010-06-08 13:09 ` Anthony Liguori
2010-06-08 13:29 ` Gerd Hoffmann
2010-06-07 23:51 ` [Qemu-devel] [PATCH 11/22] machine: replace compat_props with opts_default Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 12/22] machine: some sugary macros to simplify machine default options Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 13/22] machine: get rid of global default QEMUMachine members Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 14/22] machine: replace QEMUMachine.use_scsi with -machine default_drive Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 15/22] machine: make max_cpus a -machine option Anthony Liguori
2010-06-08 1:01 ` Paul Brook
2010-06-08 1:56 ` Anthony Liguori
2010-06-08 2:56 ` Paul Brook
2010-06-09 7:44 ` Jes Sorensen
2010-06-09 7:47 ` Jes Sorensen
2010-06-07 23:52 ` [Qemu-devel] [PATCH 16/22] machine: move default machine out of machine definitions Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 17/22] machine: kill machine->alias Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 18/22] machine: final conversion to pure QemuOpts Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 19/22] machine: introduce accel option to allow selection of kvm or tcg Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 20/22] machine: introduce machine core and split qemu_register_machine Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 21/22] machine: convert pc machines to split core vs machine API Anthony Liguori
2010-06-09 7:51 ` Jes Sorensen
2010-06-07 23:52 ` [Qemu-devel] [PATCH 22/22] machine: introduce -machine-def option to define a machine via config Anthony Liguori
2010-06-08 0:50 ` Anthony Liguori
2010-06-10 17:48 ` Daniel P. Berrange
2010-06-11 13:03 ` Daniel P. Berrange
2010-06-08 3:12 ` [Qemu-devel] [PATCH 0/22] Refactor machine support Paul Brook
2010-06-08 10:24 ` [Qemu-devel] " Paolo Bonzini
2010-06-08 14:30 ` Paul Brook
2010-06-08 15:28 ` Anthony Liguori
2010-06-08 15:36 ` Paul Brook
2010-06-08 15:58 ` Paolo Bonzini
2010-06-08 16:15 ` Anthony Liguori
2010-06-08 21:05 ` Alexander Graf
2010-06-08 21:16 ` Anthony Liguori
2010-06-08 17:23 ` Anthony Liguori
2010-06-09 2:11 ` Paul Brook
2010-06-09 13:55 ` Anthony Liguori
2010-06-09 14:30 ` Paul Brook
2010-06-09 20:47 ` Blue Swirl
2010-06-09 20:52 ` Anthony Liguori
2010-06-09 21:09 ` Blue Swirl
2010-06-09 22:26 ` Paul Brook
2010-06-08 14:04 ` [Qemu-devel] " Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1275954730-8196-11-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=glommer@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).