qemu-trivial
[Top][All Lists]
Advanced

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

[PATCH] vl: Abort if multiple machines are registered as default


From: Philippe Mathieu-Daudé
Subject: [PATCH] vl: Abort if multiple machines are registered as default
Date: Fri, 7 Feb 2020 12:02:59 +0100

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

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
 vl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/vl.c b/vl.c
index 7dcb0879c4..da828188eb 100644
--- a/vl.c
+++ b/vl.c
@@ -2354,6 +2354,8 @@ static MachineClass *machine_parse(const char *name, 
GSList *machines)
     GSList *el;
 
     if (is_help_option(name)) {
+        int default_count = 0;
+
         printf("Supported machines are:\n");
         machines = g_slist_sort(machines, machine_class_cmp);
         for (el = machines; el; el = el->next) {
@@ -2364,6 +2366,11 @@ static MachineClass *machine_parse(const char *name, 
GSList *machines)
             printf("%-20s %s%s%s\n", mc->name, mc->desc,
                    mc->is_default ? " (default)" : "",
                    mc->deprecation_reason ? " (deprecated)" : "");
+            default_count += !!mc->is_default;
+        }
+        if (default_count > 1) {
+            error_printf("Multiple default machines available\n");
+            abort();
         }
         exit(0);
     }
-- 
2.21.1




reply via email to

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