qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu_opt_get_bool_helper: Fix option handling
@ 2015-01-08 16:09 Michal Privoznik
  2015-01-08 16:39 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michal Privoznik @ 2015-01-08 16:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, marcel.a

Well, after 49d2e648e8087 the options to -machine parameter no longer
has .desc nor .desc->type. That's mainly because the options are
dynamically added while .desc is allocated statically. Anyway, if user
tries to run:

   qemu-system-x86_64 -machine pc-i440fx-2.2,accel=kvm,usb=off

the arguments evaluation fails with:

   qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type ==
   QEMU_OPT_BOOL' failed.

Fix this by dropping the assert() which is useless after the mentioned
commit anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 util/qemu-option.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/util/qemu-option.c b/util/qemu-option.c
index a708241..478420f 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -384,7 +384,6 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts, const char *name,
         }
         return ret;
     }
-    assert(opt->desc && opt->desc->type == QEMU_OPT_BOOL);
     ret = opt->value.boolean;
     if (del) {
         qemu_opt_del_all(opts, name);
-- 
2.0.5

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

* Re: [Qemu-devel] [PATCH] qemu_opt_get_bool_helper: Fix option handling
  2015-01-08 16:09 [Qemu-devel] [PATCH] qemu_opt_get_bool_helper: Fix option handling Michal Privoznik
@ 2015-01-08 16:39 ` Eric Blake
  2015-01-08 16:44 ` Marcel Apfelbaum
  2015-01-08 17:14 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2015-01-08 16:39 UTC (permalink / raw)
  To: Michal Privoznik, qemu-devel; +Cc: stefanha, marcel.a

[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]

On 01/08/2015 09:09 AM, Michal Privoznik wrote:
> Well, after 49d2e648e8087 the options to -machine parameter no longer
> has .desc nor .desc->type. That's mainly because the options are
> dynamically added while .desc is allocated statically. Anyway, if user
> tries to run:
> 
>    qemu-system-x86_64 -machine pc-i440fx-2.2,accel=kvm,usb=off
> 
> the arguments evaluation fails with:
> 
>    qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type ==
>    QEMU_OPT_BOOL' failed.
> 
> Fix this by dropping the assert() which is useless after the mentioned
> commit anyway.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  util/qemu-option.c | 1 -
>  1 file changed, 1 deletion(-)

There are several other open threads about this same issue.  The
consensus so far appears to be that the assert is catching a real bug,
and should remain, and that we are instead working on the patches to fix
the real bug.

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH] qemu_opt_get_bool_helper: Fix option handling
  2015-01-08 16:09 [Qemu-devel] [PATCH] qemu_opt_get_bool_helper: Fix option handling Michal Privoznik
  2015-01-08 16:39 ` Eric Blake
@ 2015-01-08 16:44 ` Marcel Apfelbaum
  2015-01-08 17:14 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Marcel Apfelbaum @ 2015-01-08 16:44 UTC (permalink / raw)
  To: Michal Privoznik, qemu-devel; +Cc: stefanha, marcel.a

On 01/08/2015 06:09 PM, Michal Privoznik wrote:
> Well, after 49d2e648e8087 the options to -machine parameter no longer
> has .desc nor .desc->type. That's mainly because the options are
> dynamically added while .desc is allocated statically. Anyway, if user
> tries to run:
>
>     qemu-system-x86_64 -machine pc-i440fx-2.2,accel=kvm,usb=off
>
> the arguments evaluation fails with:
>
>     qemu_opt_get_bool_helper: Assertion `opt->desc && opt->desc->type ==
>     QEMU_OPT_BOOL' failed.
>
> Fix this by dropping the assert() which is useless after the mentioned
> commit anyway.
>
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>   util/qemu-option.c | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index a708241..478420f 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -384,7 +384,6 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts, const char *name,
>           }
>           return ret;
>       }
> -    assert(opt->desc && opt->desc->type == QEMU_OPT_BOOL);
>       ret = opt->value.boolean;
>       if (del) {
>           qemu_opt_del_all(opts, name);
>

Hi Michal,
Thank you for the patch, but there is already a PULL request for a fix.

You can follow the details in this mail thread
https://www.mail-archive.com/qemu-devel@nongnu.org/msg272607.html

Thank you,
Marcel

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

* Re: [Qemu-devel] [PATCH] qemu_opt_get_bool_helper: Fix option handling
  2015-01-08 16:09 [Qemu-devel] [PATCH] qemu_opt_get_bool_helper: Fix option handling Michal Privoznik
  2015-01-08 16:39 ` Eric Blake
  2015-01-08 16:44 ` Marcel Apfelbaum
@ 2015-01-08 17:14 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2015-01-08 17:14 UTC (permalink / raw)
  To: Michal Privoznik, qemu-devel; +Cc: stefanha, marcel.a



On 08/01/2015 17:09, Michal Privoznik wrote:
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index a708241..478420f 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -384,7 +384,6 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts, const char *name,
>          }
>          return ret;
>      }
> -    assert(opt->desc && opt->desc->type == QEMU_OPT_BOOL);
>      ret = opt->value.boolean;
>      if (del) {
>          qemu_opt_del_all(opts, name);
> 

opt->value.boolean is not initialized correctly if opt->desc is NULL.
See how it is assigned in qemu_opt_parse.

Paolo

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

end of thread, other threads:[~2015-01-08 17:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 16:09 [Qemu-devel] [PATCH] qemu_opt_get_bool_helper: Fix option handling Michal Privoznik
2015-01-08 16:39 ` Eric Blake
2015-01-08 16:44 ` Marcel Apfelbaum
2015-01-08 17:14 ` Paolo Bonzini

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).