From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y80NB-0007cq-Fc for qemu-devel@nongnu.org; Mon, 05 Jan 2015 00:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y80N8-00067r-8r for qemu-devel@nongnu.org; Mon, 05 Jan 2015 00:38:37 -0500 Received: from mga09.intel.com ([134.134.136.24]:41280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y80N8-00067b-1Q for qemu-devel@nongnu.org; Mon, 05 Jan 2015 00:38:34 -0500 From: Tiejun Chen Date: Mon, 5 Jan 2015 13:35:29 +0800 Message-Id: <1420436129-8467-1-git-send-email-tiejun.chen@intel.com> Subject: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcel.a@redhat.com, peter.maydell@linaro.org, agraf@suse.de, greg.bellows@linaro.org Cc: qemu-devel@nongnu.org After one commit 49d2e648e808, "machine: remove qemu_machine_opts global list", is introduced, QEMU doesn't keep a global list of options but set desc lately. Then we can see the following, $ x86_64-softmmu/qemu-system-x86_64 -usb qemu-system-x86_64: util/qemu-option.c:387: qemu_opt_get_bool_helper: \ Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Aborted (core dumped) So inside qemu_opt_get_bool_helper, we need to call find_desc_by_name() to work parse_option_bool() out just in case of !opt->desc. Signed-off-by: Tiejun Chen --- util/qemu-option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index a708241..7cb3601 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -377,7 +377,7 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts, const char *name, } opt = qemu_opt_find(opts, name); - if (opt == NULL) { + if ((opt == NULL) || !opt->desc) { const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name); if (desc && desc->def_value_str) { parse_option_bool(name, desc->def_value_str, &ret, &error_abort); -- 1.9.1