aboutsummaryrefslogtreecommitdiffstats
path: root/vl.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2011-07-23 12:38:37 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2011-07-23 10:19:49 -0500
commit9052ea6bf4962b1342aa56d4341bb55176ed9e45 (patch)
treedb62acb0a55260c3f6263e34d066b1fe416ebbf1 /vl.c
parent7006b9cff356233c3db0150ec55fd999c49dfae3 (diff)
Generalize -machine command line option
-machine somehow suggests that it selects the machine, but it doesn't. Fix that before this command is set in stone. Actually, -machine should supersede -M and allow to introduce arbitrary per-machine options to the command line. That will change the internal realization again, but we will be able to keep the user interface stable. Tested-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/vl.c b/vl.c
index fcd7395dd..acfff858a 100644
--- a/vl.c
+++ b/vl.c
@@ -1899,6 +1899,27 @@ static int debugcon_parse(const char *devname)
return 0;
}
+static QEMUMachine *machine_parse(const char *name)
+{
+ QEMUMachine *m, *machine = NULL;
+
+ if (name) {
+ machine = find_machine(name);
+ }
+ if (machine) {
+ return machine;
+ }
+ printf("Supported machines are:\n");
+ for (m = first_machine; m != NULL; m = m->next) {
+ if (m->alias) {
+ printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name);
+ }
+ printf("%-10s %s%s\n", m->name, m->desc,
+ m->is_default ? " (default)" : "");
+ }
+ exit(!name || *name != '?');
+}
+
static int tcg_init(void)
{
return 0;
@@ -2155,20 +2176,7 @@ int main(int argc, char **argv, char **envp)
}
switch(popt->index) {
case QEMU_OPTION_M:
- machine = find_machine(optarg);
- if (!machine) {
- QEMUMachine *m;
- printf("Supported machines are:\n");
- for(m = first_machine; m != NULL; m = m->next) {
- if (m->alias)
- printf("%-10s %s (alias of %s)\n",
- m->alias, m->desc, m->name);
- printf("%-10s %s%s\n",
- m->name, m->desc,
- m->is_default ? " (default)" : "");
- }
- exit(*optarg != '?');
- }
+ machine = machine_parse(optarg);
break;
case QEMU_OPTION_cpu:
/* hw initialization will check this */
@@ -2698,11 +2706,12 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_machine:
olist = qemu_find_opts("machine");
qemu_opts_reset(olist);
- opts = qemu_opts_parse(olist, optarg, 0);
+ opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
+ machine = machine_parse(qemu_opt_get(opts, "type"));
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
@@ -2976,8 +2985,8 @@ int main(int argc, char **argv, char **envp)
p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
}
if (p == NULL) {
- opts = qemu_opts_parse(qemu_find_opts("machine"),
- machine->default_machine_opts, 0);
+ qemu_opts_reset(list);
+ opts = qemu_opts_parse(list, machine->default_machine_opts, 0);
if (!opts) {
fprintf(stderr, "parse error for machine %s: %s\n",
machine->name, machine->default_machine_opts);