mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-11 16:00:50 -07:00
qtest: Don't segfault with invalid -qtest option
This prints an error message, instead of core dump, when "-qtest"
option value is invalid, e.g.:
$ ./x86_64-softmmu/qemu-system-x86_64 -qtest unknown
qemu-system-x86_64: Failed to initialize device for qtest:
"unknown"
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
1f9c4cfda4
commit
23802b4fe0
3 changed files with 16 additions and 3 deletions
8
qtest.c
8
qtest.c
|
|
@ -507,12 +507,18 @@ int qtest_init_accel(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void qtest_init(const char *qtest_chrdev, const char *qtest_log)
|
||||
void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)
|
||||
{
|
||||
CharDriverState *chr;
|
||||
|
||||
chr = qemu_chr_new("qtest", qtest_chrdev, NULL);
|
||||
|
||||
if (chr == NULL) {
|
||||
error_setg(errp, "Failed to initialize device for qtest: \"%s\"",
|
||||
qtest_chrdev);
|
||||
return;
|
||||
}
|
||||
|
||||
qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr);
|
||||
qemu_chr_fe_set_echo(chr, true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue