From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>
Subject: [PULL v2 04/11] vl: catch [accel] entry without accelerator
Date: Thu, 9 Feb 2023 10:35:13 +0100 [thread overview]
Message-ID: <20230209093514.177999-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20230209093514.177999-1-pbonzini@redhat.com>
Avoid a SIGSEGV and return an error instead.
Reported-by: Thomas Huth <thuth@redhat.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1439
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
softmmu/vl.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index b2ee3fee3f06..459588aa7d14 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2204,14 +2204,18 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
int ret;
bool qtest_with_kvm;
+ if (!acc) {
+ error_setg(errp, QERR_MISSING_PARAMETER, "accel");
+ goto bad;
+ }
+
qtest_with_kvm = g_str_equal(acc, "kvm") && qtest_chrdev != NULL;
if (!ac) {
- *p_init_failed = true;
if (!qtest_with_kvm) {
error_report("invalid accelerator %s", acc);
}
- return 0;
+ goto bad;
}
accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
object_apply_compat_props(OBJECT(accel));
@@ -2221,14 +2225,17 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
ret = accel_init_machine(accel, current_machine);
if (ret < 0) {
- *p_init_failed = true;
if (!qtest_with_kvm || ret != -ENOENT) {
error_report("failed to initialize %s: %s", acc, strerror(-ret));
}
- return 0;
+ goto bad;
}
return 1;
+
+bad:
+ *p_init_failed = true;
+ return 0;
}
static void configure_accelerators(const char *progname)
--
2.39.1
next prev parent reply other threads:[~2023-02-09 9:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 9:35 [PULL v2 00/11] Misc patches for 2023-02-08 Paolo Bonzini
2023-02-09 9:35 ` Paolo Bonzini [this message]
2023-02-09 9:35 ` [PULL v2 07/11] readconfig-test: add test for accelerator configuration Paolo Bonzini
2023-02-09 15:17 ` [PULL v2 00/11] Misc patches for 2023-02-08 Peter Maydell
2023-02-20 13:56 ` Thomas Huth
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=20230209093514.177999-2-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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).