@@ -2274,7 +2274,7 @@ int main(int argc, char **argv, char **envp)
int optind;
const char *optarg;
const char *loadvm = NULL;
- QEMUMachine *machine;
+ QEMUMachine *machine = NULL;
const char *cpu_model;
const char *vga_model = "none";
const char *pid_file = NULL;
@@ -2317,7 +2317,6 @@ int main(int argc, char **argv, char **envp)
os_setup_early_signal_handling();
module_call_init(MODULE_INIT_MACHINE);
- machine = find_default_machine();
cpu_model = NULL;
ram_size = 0;
snapshot = 0;
@@ -2384,7 +2383,7 @@ int main(int argc, char **argv, char **envp)
}
switch(popt->index) {
case QEMU_OPTION_M:
- machine = machine_parse(optarg);
+ qemu_opts_set(qemu_find_opts("machine"), 0, "type", optarg);
break;
case QEMU_OPTION_cpu:
/* hw initialization will check this */
@@ -2954,10 +2953,6 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
- optarg = qemu_opt_get(opts, "type");
- if (optarg) {
- machine = machine_parse(optarg);
- }
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
@@ -3218,11 +3213,19 @@ int main(int argc, char **argv, char **envp)
data_dir = CONFIG_QEMU_DATADIR;
}
- if (machine == NULL) {
- fprintf(stderr, "No machine found.\n");
- exit(1);
+ machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
+ if (machine_opts) {
+ optarg = qemu_opt_get(machine_opts, "type");
+ if (optarg) {
+ machine = machine_parse(optarg);
+ }
+ }
+ if (!machine) {
+ machine = find_default_machine();
}
+ current_machine = machine;
+
/*
* Default to max_cpus = smp_cpus, in case the user doesn't
* specify a max_cpus value.
@@ -3312,7 +3315,7 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
- machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
+ /* Initialize machine options */
bios_name = NULL;
kernel_filename = initrd_filename = kernel_cmdline = NULL;
ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
@@ -3493,8 +3496,6 @@ int main(int argc, char **argv, char **envp)
set_numa_modes();
- current_machine = machine;
-
/* init USB devices */
if (usb_enabled) {
if (foreach_device_config(DEV_USB, usb_parse) < 0)
machine_parse is still being called from the -M handler. Remove this, and just call machine_parse based on the "-machine type" value. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- vl.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-)