* [PATCH v2] vl: Abort if multiple machines are registered as default
@ 2020-02-07 11:27 Philippe Mathieu-Daudé
2020-02-07 12:28 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-07 11:27 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-trivial, Paolo Bonzini, Philippe Mathieu-Daudé,
Marc-André Lureau, Laurent Vivier
It would be confusing to have multiple default machines.
Abort if this ever occurs.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v2: Use assert() instead of human friendly message (Marc-André)
Cc: Marc-André Lureau <marcandre.lureau@gmail.com>
Cc: Laurent Vivier <laurent@vivier.eu>
---
vl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/vl.c b/vl.c
index 7dcb0879c4..b3e0f7af25 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,7 +2366,9 @@ 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;
}
+ assert(default_count <= 1);
exit(0);
}
--
2.21.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] vl: Abort if multiple machines are registered as default
2020-02-07 11:27 [PATCH v2] vl: Abort if multiple machines are registered as default Philippe Mathieu-Daudé
@ 2020-02-07 12:28 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2020-02-07 12:28 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-trivial, Paolo Bonzini, Marc-André Lureau, Laurent Vivier
On 2/7/20 11:27 AM, Philippe Mathieu-Daudé wrote:
> + default_count += !!mc->is_default;
I'd prefer we simply change mc->is_default to bool.
There's no good reason for it to be type int, afaics.
In the meantime, there are no settings of is_default outside {0,1}, so you
could just drop the !! for now.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-07 12:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 11:27 [PATCH v2] vl: Abort if multiple machines are registered as default Philippe Mathieu-Daudé
2020-02-07 12:28 ` Richard Henderson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.