qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PULL 4/4] vl: Abort if multiple machines are registered as default


From: Eduardo Habkost
Subject: [PULL 4/4] vl: Abort if multiple machines are registered as default
Date: Fri, 28 Feb 2020 16:04:27 -0500

From: Philippe Mathieu-Daudé <address@hidden>

It would be confusing to have multiple default machines.
Abort if this ever occurs.

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Tested-by: Laurent Vivier <address@hidden>
---
 softmmu/vl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 705ee6f841..5549f4b619 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)
-- 
2.24.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]