diff mbox

'-usb' regressed by 49d2e648 ("machine: remove qemu_machine_opts global list")

Message ID 549A87B0.7010002@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Dec. 24, 2014, 9:30 a.m. UTC
On 23/12/2014 23:12, Laszlo Ersek wrote:
> Apologies if this problem is known. After building qemu at ab0302ee:
> 
> $ 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.

Does this work?

         qemu_opt_del_all(opts, name);
@@ -420,7 +420,7 @@ static uint64_t qemu_opt_get_number_helper(QemuOpts
*opts, const char *name,
         }
         return ret;
     }
-    assert(opt->desc && opt->desc->type == QEMU_OPT_NUMBER);
+    assert(!opt->desc || opt->desc->type == QEMU_OPT_NUMBER);
     ret = opt->value.uint;
     if (del) {
         qemu_opt_del_all(opts, name);
@@ -457,7 +457,7 @@ static uint64_t qemu_opt_get_size_helper(QemuOpts
*opts, const char *name,
         }
         return ret;
     }
-    assert(opt->desc && opt->desc->type == QEMU_OPT_SIZE);
+    assert(!opt->desc || opt->desc->type == QEMU_OPT_SIZE);
     ret = opt->value.uint;
     if (del) {
         qemu_opt_del_all(opts, name);

Paolo

Comments

Gonglei (Arei) Dec. 24, 2014, 9:51 a.m. UTC | #1
On 2014/12/24 17:30, Paolo Bonzini wrote:

> 
> 
> On 23/12/2014 23:12, Laszlo Ersek wrote:
>> Apologies if this problem is known. After building qemu at ab0302ee:
>>
>> $ 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.
> 
> Does this work?
> 
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index a708241..4f1f86a 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -384,7 +384,7 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts,
> const char *name,
>          }
>          return ret;
>      }
> -    assert(opt->desc && opt->desc->type == QEMU_OPT_BOOL);
> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_BOOL);
>      ret = opt->value.boolean;
>      if (del) {
>          qemu_opt_del_all(opts, name);
> @@ -420,7 +420,7 @@ static uint64_t qemu_opt_get_number_helper(QemuOpts
> *opts, const char *name,
>          }
>          return ret;
>      }
> -    assert(opt->desc && opt->desc->type == QEMU_OPT_NUMBER);
> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_NUMBER);
>      ret = opt->value.uint;
>      if (del) {
>          qemu_opt_del_all(opts, name);
> @@ -457,7 +457,7 @@ static uint64_t qemu_opt_get_size_helper(QemuOpts
> *opts, const char *name,
>          }
>          return ret;
>      }
> -    assert(opt->desc && opt->desc->type == QEMU_OPT_SIZE);
> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_SIZE);
>      ret = opt->value.uint;
>      if (del) {
>          qemu_opt_del_all(opts, name);
> 
> Paolo
> 

Nice~

Regards,
-Gonglei
Laszlo Ersek Dec. 24, 2014, 11:03 a.m. UTC | #2
On 12/24/14 10:30, Paolo Bonzini wrote:
> 
> 
> On 23/12/2014 23:12, Laszlo Ersek wrote:
>> Apologies if this problem is known. After building qemu at ab0302ee:
>>
>> $ 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.
> 
> Does this work?
> 
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index a708241..4f1f86a 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -384,7 +384,7 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts,
> const char *name,
>          }
>          return ret;
>      }
> -    assert(opt->desc && opt->desc->type == QEMU_OPT_BOOL);
> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_BOOL);
>      ret = opt->value.boolean;
>      if (del) {
>          qemu_opt_del_all(opts, name);
> @@ -420,7 +420,7 @@ static uint64_t qemu_opt_get_number_helper(QemuOpts
> *opts, const char *name,
>          }
>          return ret;
>      }
> -    assert(opt->desc && opt->desc->type == QEMU_OPT_NUMBER);
> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_NUMBER);
>      ret = opt->value.uint;
>      if (del) {
>          qemu_opt_del_all(opts, name);
> @@ -457,7 +457,7 @@ static uint64_t qemu_opt_get_size_helper(QemuOpts
> *opts, const char *name,
>          }
>          return ret;
>      }
> -    assert(opt->desc && opt->desc->type == QEMU_OPT_SIZE);
> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_SIZE);
>      ret = opt->value.uint;
>      if (del) {
>          qemu_opt_del_all(opts, name);

Tested-by: Laszlo Ersek <lersek@redhat.com>

Thanks!
Laszlo
Paolo Bonzini Dec. 24, 2014, 11:55 a.m. UTC | #3
On 24/12/2014 12:03, Laszlo Ersek wrote:
> On 12/24/14 10:30, Paolo Bonzini wrote:
>>
>>
>> On 23/12/2014 23:12, Laszlo Ersek wrote:
>>> Apologies if this problem is known. After building qemu at ab0302ee:
>>>
>>> $ 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.
>>
>> Does this work?
>>
>> diff --git a/util/qemu-option.c b/util/qemu-option.c
>> index a708241..4f1f86a 100644
>> --- a/util/qemu-option.c
>> +++ b/util/qemu-option.c
>> @@ -384,7 +384,7 @@ static bool qemu_opt_get_bool_helper(QemuOpts *opts,
>> const char *name,
>>          }
>>          return ret;
>>      }
>> -    assert(opt->desc && opt->desc->type == QEMU_OPT_BOOL);
>> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_BOOL);
>>      ret = opt->value.boolean;
>>      if (del) {
>>          qemu_opt_del_all(opts, name);
>> @@ -420,7 +420,7 @@ static uint64_t qemu_opt_get_number_helper(QemuOpts
>> *opts, const char *name,
>>          }
>>          return ret;
>>      }
>> -    assert(opt->desc && opt->desc->type == QEMU_OPT_NUMBER);
>> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_NUMBER);
>>      ret = opt->value.uint;
>>      if (del) {
>>          qemu_opt_del_all(opts, name);
>> @@ -457,7 +457,7 @@ static uint64_t qemu_opt_get_size_helper(QemuOpts
>> *opts, const char *name,
>>          }
>>          return ret;
>>      }
>> -    assert(opt->desc && opt->desc->type == QEMU_OPT_SIZE);
>> +    assert(!opt->desc || opt->desc->type == QEMU_OPT_SIZE);
>>      ret = opt->value.uint;
>>      if (del) {
>>          qemu_opt_del_all(opts, name);
> 
> Tested-by: Laszlo Ersek <lersek@redhat.com>

Hmm, it doesn't work though.  parse_option_bool is not called.
Something for new year I guess.

Paolo
diff mbox

Patch

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