From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y85kL-0007Tc-FJ for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:22:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y85kK-0007NJ-Gk for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:22:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y85kK-0007Kr-AI for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:22:52 -0500 From: Stefan Hajnoczi Date: Mon, 5 Jan 2015 11:22:41 +0000 Message-Id: <1420456961-19631-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH] vl.c: fix -usb option assertion failure in qemu_opt_get_bool_helper() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Tiejun Chen , Peter Maydell , Marcel Apfelbaum , Stefan Hajnoczi , plucinski.mariusz@gmail.com Commit 49d2e648e8087d154d8bf8b91f27c8e05e79d5a6 ("machine: remove qemu_machine_opts global list") removed option descriptions from the -machine QemuOptsList to avoid repeating MachineState's QOM properties. This change broke vl.c:usb_enabled() because qemu_opt_get_bool() cannot be used on QemuOptsList without option descriptions since QemuOpts doesn't know the type and therefore left an unparsed string value. This patch avoids calling qemu_opt_get_bool() to fix the assertion failure: $ qemu-system-x86_64 -usb qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Test the presence of -usb using qemu_opt_find() but use the MachineState->usb field instead of qemu_opt_get_bool(). Cc: Marcel Apfelbaum Cc: Tiejun Chen Signed-off-by: Stefan Hajnoczi --- vl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index bea9656..6e8889c 100644 --- a/vl.c +++ b/vl.c @@ -999,8 +999,11 @@ static int parse_name(QemuOpts *opts, void *opaque) bool usb_enabled(bool default_usb) { - return qemu_opt_get_bool(qemu_get_machine_opts(), "usb", - has_defaults && default_usb); + if (qemu_opt_find(qemu_get_machine_opts(), "usb")) { + return current_machine->usb; + } else { + return has_defaults && default_usb; + } } #ifndef _WIN32 -- 2.1.0