[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/11] vl: catch [accel] entry without accelerator
From: |
Paolo Bonzini |
Subject: |
[PULL 04/11] vl: catch [accel] entry without accelerator |
Date: |
Wed, 8 Feb 2023 18:19:15 +0100 |
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..06c9c931565e 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(&error_fatal, 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
- [PULL 00/11] Misc patches for 2022-02-08, Paolo Bonzini, 2023/02/08
- [PULL 01/11] build: make meson-buildoptions.sh stable, Paolo Bonzini, 2023/02/08
- [PULL 03/11] block/iscsi: fix double-free on BUSY or similar statuses, Paolo Bonzini, 2023/02/08
- [PULL 06/11] libqtest: ensure waitpid() is only called once, Paolo Bonzini, 2023/02/08
- [PULL 11/11] target/i386: fix ADOX followed by ADCX, Paolo Bonzini, 2023/02/08
- [PULL 05/11] libqtest: split qtest_spawn_qemu function, Paolo Bonzini, 2023/02/08
- [PULL 08/11] tests/tcg/i386: Introduce and use reg_t consistently, Paolo Bonzini, 2023/02/08
- [PULL 10/11] target/i386: Fix C flag for BLSI, BLSMSK, BLSR, Paolo Bonzini, 2023/02/08
- [PULL 04/11] vl: catch [accel] entry without accelerator,
Paolo Bonzini <=
- [PULL 07/11] readconfig-test: add test for accelerator configuration, Paolo Bonzini, 2023/02/08
- [PULL 09/11] target/i386: Fix BEXTR instruction, Paolo Bonzini, 2023/02/08
- [PULL 02/11] remove unnecessary extern "C" blocks, Paolo Bonzini, 2023/02/08
- Re: [PULL 00/11] Misc patches for 2022-02-08, Thomas Huth, 2023/02/09