mirror of https://github.com/xemu-project/xemu.git
vl: catch [accel] entry without accelerator
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>
This commit is contained in:
parent
5080152e2e
commit
78901b5047
15
softmmu/vl.c
15
softmmu/vl.c
|
@ -2204,14 +2204,18 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
|
||||||
int ret;
|
int ret;
|
||||||
bool qtest_with_kvm;
|
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;
|
qtest_with_kvm = g_str_equal(acc, "kvm") && qtest_chrdev != NULL;
|
||||||
|
|
||||||
if (!ac) {
|
if (!ac) {
|
||||||
*p_init_failed = true;
|
|
||||||
if (!qtest_with_kvm) {
|
if (!qtest_with_kvm) {
|
||||||
error_report("invalid accelerator %s", acc);
|
error_report("invalid accelerator %s", acc);
|
||||||
}
|
}
|
||||||
return 0;
|
goto bad;
|
||||||
}
|
}
|
||||||
accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
|
accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
|
||||||
object_apply_compat_props(OBJECT(accel));
|
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);
|
ret = accel_init_machine(accel, current_machine);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
*p_init_failed = true;
|
|
||||||
if (!qtest_with_kvm || ret != -ENOENT) {
|
if (!qtest_with_kvm || ret != -ENOENT) {
|
||||||
error_report("failed to initialize %s: %s", acc, strerror(-ret));
|
error_report("failed to initialize %s: %s", acc, strerror(-ret));
|
||||||
}
|
}
|
||||||
return 0;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
bad:
|
||||||
|
*p_init_failed = true;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void configure_accelerators(const char *progname)
|
static void configure_accelerators(const char *progname)
|
||||||
|
|
Loading…
Reference in New Issue