[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 5/5] vl: Clean up machine selection in main().
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 5/5] vl: Clean up machine selection in main(). |
Date: |
Fri, 19 Feb 2016 14:27:49 +0100 |
We set machine_class to the default first, and update it to the real
one later. Any use of machine_class in between is almost certainly
wrong (there are no such uses right now). Set it once and for all
instead.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Laszlo Ersek <address@hidden>
Reviewed-by: Marcel Apfelbaum <address@hidden>
---
vl.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/vl.c b/vl.c
index 8c1a1ff..b87e292 100644
--- a/vl.c
+++ b/vl.c
@@ -2762,8 +2762,9 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
return popt;
}
-static void set_machine_options(MachineClass **machine_class)
+static MachineClass *select_machine(void)
{
+ MachineClass *machine_class = find_default_machine();
const char *optarg;
QemuOpts *opts;
Location loc;
@@ -2775,16 +2776,17 @@ static void set_machine_options(MachineClass
**machine_class)
optarg = qemu_opt_get(opts, "type");
if (optarg) {
- *machine_class = machine_parse(optarg);
+ machine_class = machine_parse(optarg);
}
- if (*machine_class == NULL) {
+ if (!machine_class) {
error_report("No machine specified, and there is no default");
error_printf("Use -machine help to list supported machines\n");
exit(1);
}
loc_pop(&loc);
+ return machine_class;
}
static int machine_set_property(void *opaque,
@@ -3031,7 +3033,6 @@ int main(int argc, char **argv, char **envp)
os_setup_early_signal_handling();
module_call_init(MODULE_INIT_MACHINE);
- machine_class = find_default_machine();
cpu_model = NULL;
snapshot = 0;
cyls = heads = secs = 0;
@@ -4022,7 +4023,7 @@ int main(int argc, char **argv, char **envp)
replay_configure(icount_opts);
- set_machine_options(&machine_class);
+ machine_class = select_machine();
set_memory_options(&ram_slots, &maxram_size, machine_class);
--
2.4.3
- [Qemu-devel] [PULL 0/5] Error reporting patches for 2016-02-19, Markus Armbruster, 2016/02/19
- [Qemu-devel] [PULL 5/5] vl: Clean up machine selection in main().,
Markus Armbruster <=
- [Qemu-devel] [PULL 4/5] vl: Set error location when parsing memory options, Markus Armbruster, 2016/02/19
- [Qemu-devel] [PULL 2/5] vl: Reset location after handling command-line arguments, Markus Armbruster, 2016/02/19
- [Qemu-devel] [PULL 3/5] replay: Set error location properly when parsing options, Markus Armbruster, 2016/02/19
- [Qemu-devel] [PULL 1/5] vl.c: Fix regression in machine error message, Markus Armbruster, 2016/02/19
- Re: [Qemu-devel] [PULL 0/5] Error reporting patches for 2016-02-19, Peter Maydell, 2016/02/19