diff options
author | Philippe Mathieu-Daudé <philmd@redhat.com> | 2020-02-07 17:19:48 +0100 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2020-02-28 14:57:19 -0500 |
commit | 6db1857ec9960c63024f4ce6329d947f727bad39 (patch) | |
tree | 06d62e3a633ee467010a132133c8fbe33305598b | |
parent | ea0ac7f6f8f313f810858dd1ba4e7fae602e01bd (diff) | |
download | qemu-6db1857ec9960c63024f4ce6329d947f727bad39.zip qemu-6db1857ec9960c63024f4ce6329d947f727bad39.tar.gz qemu-6db1857ec9960c63024f4ce6329d947f727bad39.tar.bz2 |
vl: Abort if multiple machines are registered as default
It would be confusing to have multiple default machines.
Abort if this ever occurs.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200207161948.15972-4-philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Tested-by: Laurent Vivier <laurent@vivier.eu>
-rw-r--r-- | softmmu/vl.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/softmmu/vl.c b/softmmu/vl.c index 705ee6f..5549f4b 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1163,16 +1163,18 @@ static MachineClass *find_machine(const char *name, GSList *machines) static MachineClass *find_default_machine(GSList *machines) { GSList *el; + MachineClass *default_machineclass = NULL; for (el = machines; el; el = el->next) { MachineClass *mc = el->data; if (mc->is_default) { - return mc; + assert(default_machineclass == NULL && "Multiple default machines"); + default_machineclass = mc; } } - return NULL; + return default_machineclass; } static int machine_help_func(QemuOpts *opts, MachineState *machine) |