[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 3/3] vl: Abort if multiple machines are registered as default
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v4 3/3] vl: Abort if multiple machines are registered as default |
Date: |
Fri, 7 Feb 2020 17:19:48 +0100 |
It would be confusing to have multiple default machines.
Abort if this ever occurs.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
v2: Use assert() instead of human friendly message (Marc-André)
v3: Move the check to find_machine() (Michael)
Cc: Marc-André Lureau <address@hidden>
Cc: Laurent Vivier <address@hidden>
Cc: Michael S. Tsirkin <address@hidden>
---
vl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index 7dcb0879c4..ebc203af0d 100644
--- a/vl.c
+++ b/vl.c
@@ -1184,16 +1184,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)
--
2.21.1
- Re: Tricore default machine, (continued)
[PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type, Philippe Mathieu-Daudé, 2020/02/07
- Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type, Marc-André Lureau, 2020/02/07
- Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type, Laurent Vivier, 2020/02/07
- Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type, David Gibson, 2020/02/08
- Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type, Cornelia Huck, 2020/02/10
- Re: [PATCH v4 2/3] hw: Make MachineClass::is_default a boolean type, Thomas Huth, 2020/02/10
[PATCH v4 3/3] vl: Abort if multiple machines are registered as default,
Philippe Mathieu-Daudé <=
Re: [PATCH v4 0/3] Make MachineClass::is_default boolean, refuse multiple default machines, Eduardo Habkost, 2020/02/07