qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
@ 2015-01-05  5:35 Tiejun Chen
  2015-01-05 17:13 ` Eric Blake
  0 siblings, 1 reply; 7+ messages in thread
From: Tiejun Chen @ 2015-01-05  5:35 UTC (permalink / raw)
  To: marcel.a, peter.maydell, agraf, greg.bellows; +Cc: qemu-devel

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 <tiejun.chen@intel.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-07  1:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-05  5:35 [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc Tiejun Chen
2015-01-05 17:13 ` Eric Blake
2015-01-06  1:21   ` Chen, Tiejun
2015-01-06  2:39     ` Chen, Tiejun
2015-01-06 14:56       ` Stefan Hajnoczi
2015-01-06 16:50         ` Marcel Apfelbaum
2015-01-07  1:24         ` Chen, Tiejun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).