From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: [PULL 4/4] vl: Abort if multiple machines are registered as default
Date: Fri, 28 Feb 2020 16:04:27 -0500 [thread overview]
Message-ID: <20200228210427.474606-5-ehabkost@redhat.com> (raw)
In-Reply-To: <20200228210427.474606-1-ehabkost@redhat.com>
From: Philippe Mathieu-Daudé <philmd@redhat.com>
It would be confusing to have multiple default machines.
Abort if this ever occurs.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200207161948.15972-4-philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Tested-by: Laurent Vivier <laurent@vivier.eu>
---
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
next prev parent reply other threads:[~2020-02-28 21:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 21:04 [PULL 0/4] Machine queue, 2020-02-28 Eduardo Habkost
2020-02-28 21:04 ` [PULL 1/4] hw/nmi: Fix the NMI() macro, based on INTERFACE_CHECK() Eduardo Habkost
2020-02-28 21:04 ` [PULL 2/4] hw: Do not initialize MachineClass::is_default to 0 Eduardo Habkost
2020-02-28 21:04 ` [PULL 3/4] hw: Make MachineClass::is_default a boolean type Eduardo Habkost
2020-02-28 21:04 ` Eduardo Habkost [this message]
2020-03-02 10:45 ` [PULL 0/4] Machine queue, 2020-02-28 Peter Maydell
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=20200228210427.474606-5-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=laurent@vivier.eu \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@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).