qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding des


From: Eric Blake
Subject: Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
Date: Mon, 05 Jan 2015 10:13:14 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 01/04/2015 10:35 PM, Tiejun Chen wrote:
> 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 <address@hidden>
> ---
>  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)  {

Over-parenthesized, and looks like you also introduced a spurious space.
 Simpler to just have:

if (!opt || !opt->desc) {

Also, there are other threads about the same topic.
https://lists.gnu.org/archive/html/qemu-devel/2015-01/msg00130.html

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]