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 16/22] machine: move default machine out of machine definitions
Date: Mon, 7 Jun 2010 18:52:04 -0500 [thread overview]
Message-ID: <1275954730-8196-17-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1275954730-8196-1-git-send-email-aliguori@us.ibm.com>
There can only be one default machine so instead of setting in each machine
whether it's the default, simply declare what the name of the default machine
is. A nice characteristic of this is that we technically don't need to
describe the default machine in QEMU anymore. Instead, it could be described
in a config file but this patch doesn't do that.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/hw/boards.h b/hw/boards.h
index 5176e95..b99dc68 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -14,13 +14,13 @@ struct QEMUMachine {
const char *alias;
const char *desc;
QEMUMachineInitFunc *init;
- int is_default;
QemuOptDesc *opts_desc;
QemuOptValue *opts_default;
struct QEMUMachine *next;
};
int qemu_register_machine(QEMUMachine *m);
+void machine_set_default(const char *name);
extern QEMUMachine *current_machine;
diff --git a/hw/etraxfs.c b/hw/etraxfs.c
index 1cb6052..e41d1ce 100644
--- a/hw/etraxfs.c
+++ b/hw/etraxfs.c
@@ -176,12 +176,12 @@ static QEMUMachine bareetraxfs_machine = {
.name = "bareetraxfs",
.desc = "Bare ETRAX FS board",
.init = bareetraxfs_init,
- .is_default = 1,
};
static void bareetraxfs_machine_init(void)
{
qemu_register_machine(&bareetraxfs_machine);
+ machine_set_default("bareetraxfs");
}
machine_init(bareetraxfs_machine_init);
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index 36ebaf0..b505773 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -515,12 +515,12 @@ static QEMUMachine integratorcp_machine = {
.name = "integratorcp",
.desc = "ARM Integrator/CP (ARM926EJ-S)",
.init = integratorcp_init,
- .is_default = 1,
};
static void integratorcp_machine_init(void)
{
qemu_register_machine(&integratorcp_machine);
+ machine_set_default("integratorcp");
}
machine_init(integratorcp_machine_init);
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index b6eb94d..1ed8871 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -293,12 +293,12 @@ static QEMUMachine mcf5208evb_machine = {
.name = "mcf5208evb",
.desc = "MCF5206EVB",
.init = mcf5208evb_init,
- .is_default = 1,
};
static void mcf5208evb_machine_init(void)
{
qemu_register_machine(&mcf5208evb_machine);
+ machine_set_default("mcf5208evb");
}
machine_init(mcf5208evb_machine_init);
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 0ef0090..f89be6d 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -993,12 +993,12 @@ static QEMUMachine mips_malta_machine = {
.name = "malta",
.desc = "MIPS Malta Core LV",
.init = mips_malta_init,
- .is_default = 1,
};
static void mips_malta_machine_init(void)
{
qemu_register_machine(&mips_malta_machine);
+ machine_set_default("malta");
}
machine_init(mips_malta_machine_init);
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index d02bf20..1bb6bee 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -186,7 +186,6 @@ static QEMUMachine pc_machine = {
.alias = "pc",
.desc = "Standard PC",
.init = pc_init,
- .is_default = 1,
.opts_desc = pc_opts_desc,
.opts_default = (QemuOptValue[]) {
QOPT_VALUE("acpi", "on"),
@@ -277,6 +276,7 @@ static void pc_machine_init(void)
qemu_register_machine(&pc_machine_v0_11);
qemu_register_machine(&pc_machine_v0_10);
qemu_register_machine(&isapc_machine);
+ machine_set_default("pc");
}
machine_init(pc_machine_init);
diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c
index 5cc5787..5528960 100644
--- a/hw/petalogix_s3adsp1800_mmu.c
+++ b/hw/petalogix_s3adsp1800_mmu.c
@@ -201,12 +201,12 @@ static QEMUMachine petalogix_s3adsp1800_machine = {
.name = "petalogix-s3adsp1800",
.desc = "Petalogix linux refdesign for xilinx Spartan 3ADSP1800",
.init = petalogix_s3adsp1800_init,
- .is_default = 1
};
static void petalogix_s3adsp1800_machine_init(void)
{
qemu_register_machine(&petalogix_s3adsp1800_machine);
+ machine_set_default("petalogix-s3adsp1800");
}
machine_init(petalogix_s3adsp1800_machine_init);
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 3be0c2d..acc320a 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -446,14 +446,14 @@ static QEMUMachine core99_machine = {
QOPT_VALUE("max_cpus", stringify(MAX_CPUS)),
{ /* end of list */ }
},
-#ifdef TARGET_PPC64
- .is_default = 1,
-#endif
};
static void core99_machine_init(void)
{
qemu_register_machine(&core99_machine);
+#ifdef TARGET_PPC64
+ machine_set_default("mac99");
+#endif
}
machine_init(core99_machine_init);
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 7fab893..365a2b6 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -418,14 +418,14 @@ static QEMUMachine heathrow_machine = {
QOPT_VALUE("max_cpus", stringify(MAX_CPUS)),
{ /* end of list */ }
},
-#ifndef TARGET_PPC64
- .is_default = 1,
-#endif
};
static void heathrow_machine_init(void)
{
qemu_register_machine(&heathrow_machine);
+#ifndef TARGET_PPC64
+ machine_set_default("g3beige");
+#endif
}
machine_init(heathrow_machine_init);
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index a769ba0..6c0f400 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -281,12 +281,12 @@ static QEMUMachine s390_machine = {
QOPT_VALUE("max_cpus", "255"),
{ /* end of list */ }
},
- .is_default = 1,
};
static void s390_machine_init(void)
{
qemu_register_machine(&s390_machine);
+ machine_set_default("s390-virtio");
}
machine_init(s390_machine_init);
diff --git a/hw/shix.c b/hw/shix.c
index da5716e..8648c41 100644
--- a/hw/shix.c
+++ b/hw/shix.c
@@ -91,12 +91,12 @@ static QEMUMachine shix_machine = {
.name = "shix",
.desc = "shix card",
.init = shix_init,
- .is_default = 1,
};
static void shix_machine_init(void)
{
qemu_register_machine(&shix_machine);
+ machine_set_default("shix");
}
machine_init(shix_machine_init);
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 7d24873..8098cef 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -1324,7 +1324,6 @@ static QEMUMachine ss5_machine = {
QOPT_VALUE("default_drive", "scsi"),
{ /* end of list */ }
},
- .is_default = 1,
};
static QEMUMachine ss10_machine = {
@@ -1838,6 +1837,7 @@ static void ss2_machine_init(void)
qemu_register_machine(&ss1000_machine);
qemu_register_machine(&ss2000_machine);
qemu_register_machine(&ss2_machine);
+ machine_set_default("SS-5");
}
machine_init(ss2_machine_init);
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 8b112be..13e7219 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -923,7 +923,6 @@ static QEMUMachine sun4u_machine = {
.name = "sun4u",
.desc = "Sun4u platform",
.init = sun4u_init,
- .is_default = 1,
};
static QEMUMachine sun4v_machine = {
@@ -943,6 +942,7 @@ static void sun4u_machine_init(void)
qemu_register_machine(&sun4u_machine);
qemu_register_machine(&sun4v_machine);
qemu_register_machine(&niagara_machine);
+ machine_set_default("sun4u");
}
machine_init(sun4u_machine_init);
diff --git a/vl.c b/vl.c
index 34e48f8..3d49ba7 100644
--- a/vl.c
+++ b/vl.c
@@ -1591,6 +1591,7 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
/* machine registration */
static QEMUMachine *first_machine = NULL;
+static const char *default_machine = NULL;
int qemu_register_machine(QEMUMachine *m)
{
@@ -1603,6 +1604,11 @@ int qemu_register_machine(QEMUMachine *m)
return 0;
}
+void machine_set_default(const char *name)
+{
+ default_machine = name;
+}
+
static QEMUMachine *find_machine(const char *name)
{
QEMUMachine *m;
@@ -1618,14 +1624,7 @@ static QEMUMachine *find_machine(const char *name)
static QEMUMachine *find_default_machine(void)
{
- QEMUMachine *m;
-
- for(m = first_machine; m != NULL; m = m->next) {
- if (m->is_default) {
- return m;
- }
- }
- return NULL;
+ return find_machine(default_machine);
}
/***********************************************************/
@@ -2764,7 +2763,9 @@ int main(int argc, char **argv, char **envp)
m->alias, m->desc, m->name);
printf("%-10s %s%s\n",
m->name, m->desc,
- m->is_default ? " (default)" : "");
+ (!strcmp(m->name, default_machine) ||
+ !strcmp(m->alias, default_machine)) ?
+ " (default)" : "");
}
exit(0);
}
--
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 ` [Qemu-devel] [PATCH 10/22] machine: allow boards to specify default values and use it in isapc Anthony Liguori
2010-06-08 8:03 ` 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 ` Anthony Liguori [this message]
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-17-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).