From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: [PATCH v2] vl: Abort if multiple machines are registered as default
Date: Fri, 7 Feb 2020 12:27:29 +0100 [thread overview]
Message-ID: <20200207112729.28554-1-philmd@redhat.com> (raw)
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
next reply other threads:[~2020-02-07 11:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 11:27 Philippe Mathieu-Daudé [this message]
2020-02-07 12:28 ` [PATCH v2] vl: Abort if multiple machines are registered as default Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200207112729.28554-1-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=laurent@vivier.eu \
--cc=marcandre.lureau@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).