qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vl: Abort if multiple machines are registered as default
@ 2020-02-07 11:02 Philippe Mathieu-Daudé
  2020-02-07 11:08 ` Laurent Vivier
  2020-02-07 11:10 ` Marc-André Lureau
  0 siblings, 2 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-07 11:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Paolo Bonzini, Philippe Mathieu-Daudé

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

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-02-07 11:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-07 11:02 [PATCH] vl: Abort if multiple machines are registered as default Philippe Mathieu-Daudé
2020-02-07 11:08 ` Laurent Vivier
2020-02-07 11:25   ` Philippe Mathieu-Daudé
2020-02-07 11:28     ` Laurent Vivier
2020-02-07 11:29       ` Laurent Vivier
2020-02-07 11:10 ` Marc-André Lureau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).