From 23802b4fe0cf5821b72aa5bc682e38c8c91bb168 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Mon, 10 Feb 2014 09:28:02 +0800 Subject: qtest: Don't segfault with invalid -qtest option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Andreas Färber --- vl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index a7b00cdd37..0f7d31f047 100644 --- a/vl.c +++ b/vl.c @@ -4078,7 +4078,13 @@ int main(int argc, char **argv, char **envp) configure_accelerator(); if (qtest_chrdev) { - qtest_init(qtest_chrdev, qtest_log); + Error *local_err = NULL; + qtest_init(qtest_chrdev, qtest_log, &local_err); + if (local_err) { + error_report("%s", error_get_pretty(local_err)); + error_free(local_err); + exit(1); + } } machine_opts = qemu_get_machine_opts(); -- cgit v1.2.3