* [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
* Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
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
0 siblings, 1 reply; 7+ messages in thread
From: Eric Blake @ 2015-01-05 17:13 UTC (permalink / raw)
To: Tiejun Chen, marcel.a, peter.maydell, agraf, greg.bellows; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1485 bytes --]
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 <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) {
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
2015-01-05 17:13 ` Eric Blake
@ 2015-01-06 1:21 ` Chen, Tiejun
2015-01-06 2:39 ` Chen, Tiejun
0 siblings, 1 reply; 7+ messages in thread
From: Chen, Tiejun @ 2015-01-06 1:21 UTC (permalink / raw)
To: Eric Blake, marcel.a, peter.maydell, agraf, greg.bellows; +Cc: qemu-devel
On 2015/1/6 1:13, Eric Blake wrote:
> 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 <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) {
>
> Over-parenthesized, and looks like you also introduced a spurious space.
> Simpler to just have:
>
> if (!opt || !opt->desc) {
Looks good.
>
> Also, there are other threads about the same topic.
> https://lists.gnu.org/archive/html/qemu-devel/2015-01/msg00130.html
Yeah, I already notice that.
Thanks
Tiejun
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
2015-01-06 1:21 ` Chen, Tiejun
@ 2015-01-06 2:39 ` Chen, Tiejun
2015-01-06 14:56 ` Stefan Hajnoczi
0 siblings, 1 reply; 7+ messages in thread
From: Chen, Tiejun @ 2015-01-06 2:39 UTC (permalink / raw)
To: Eric Blake, marcel.a, peter.maydell, agraf, greg.bellows; +Cc: qemu-devel
On 2015/1/6 9:21, Chen, Tiejun wrote:
> On 2015/1/6 1:13, Eric Blake wrote:
>> 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 <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) {
>>
>> Over-parenthesized, and looks like you also introduced a spurious space.
>> Simpler to just have:
>>
>> if (!opt || !opt->desc) {
>
> Looks good.
>
>>
>> Also, there are other threads about the same topic.
>> https://lists.gnu.org/archive/html/qemu-devel/2015-01/msg00130.html
>
> Yeah, I already notice that.
>
Then I realize I need to extend this to all qemu_opt_get_*.
Tiejun
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
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
0 siblings, 2 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2015-01-06 14:56 UTC (permalink / raw)
To: Chen, Tiejun; +Cc: peter.maydell, marcel.a, qemu-devel, agraf, greg.bellows
[-- Attachment #1: Type: text/plain, Size: 2104 bytes --]
On Tue, Jan 06, 2015 at 10:39:13AM +0800, Chen, Tiejun wrote:
> On 2015/1/6 9:21, Chen, Tiejun wrote:
> >On 2015/1/6 1:13, Eric Blake wrote:
> >>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 <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) {
> >>
> >>Over-parenthesized, and looks like you also introduced a spurious space.
> >> Simpler to just have:
> >>
> >>if (!opt || !opt->desc) {
> >
> >Looks good.
> >
> >>
> >>Also, there are other threads about the same topic.
> >>https://lists.gnu.org/archive/html/qemu-devel/2015-01/msg00130.html
> >
> >Yeah, I already notice that.
> >
>
> Then I realize I need to extend this to all qemu_opt_get_*.
Marcel is working on a fix.
I think hacking qemu_opt_get_* is not a clean solution. The intention
was to move away from QemuOpts to QOM properties. The patch that
removed -machine QemuOptsList descriptions was buggy, but the proper fix
is to make that approach work instead of hacking qemu_opt_get_*.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
2015-01-06 14:56 ` Stefan Hajnoczi
@ 2015-01-06 16:50 ` Marcel Apfelbaum
2015-01-07 1:24 ` Chen, Tiejun
1 sibling, 0 replies; 7+ messages in thread
From: Marcel Apfelbaum @ 2015-01-06 16:50 UTC (permalink / raw)
To: Stefan Hajnoczi, Chen, Tiejun
Cc: peter.maydell, marcel.a, qemu-devel, agraf, greg.bellows
On 01/06/2015 04:56 PM, Stefan Hajnoczi wrote:
> On Tue, Jan 06, 2015 at 10:39:13AM +0800, Chen, Tiejun wrote:
>> On 2015/1/6 9:21, Chen, Tiejun wrote:
>>> On 2015/1/6 1:13, Eric Blake wrote:
>>>> 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 <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) {
>>>>
>>>> Over-parenthesized, and looks like you also introduced a spurious space.
>>>> Simpler to just have:
>>>>
>>>> if (!opt || !opt->desc) {
>>>
>>> Looks good.
>>>
>>>>
>>>> Also, there are other threads about the same topic.
>>>> https://lists.gnu.org/archive/html/qemu-devel/2015-01/msg00130.html
>>>
>>> Yeah, I already notice that.
>>>
>>
>> Then I realize I need to extend this to all qemu_opt_get_*.
>
> Marcel is working on a fix.
I just posted a fix on the mailing list.
https://www.mail-archive.com/qemu-devel@nongnu.org/msg272607.html
Thanks,
Marcel
>
> I think hacking qemu_opt_get_* is not a clean solution. The intention
> was to move away from QemuOpts to QOM properties. The patch that
> removed -machine QemuOptsList descriptions was buggy, but the proper fix
> is to make that approach work instead of hacking qemu_opt_get_*.
>
> Stefan
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
2015-01-06 14:56 ` Stefan Hajnoczi
2015-01-06 16:50 ` Marcel Apfelbaum
@ 2015-01-07 1:24 ` Chen, Tiejun
1 sibling, 0 replies; 7+ messages in thread
From: Chen, Tiejun @ 2015-01-07 1:24 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: peter.maydell, marcel.a, qemu-devel, agraf, greg.bellows
On 2015/1/6 22:56, Stefan Hajnoczi wrote:
> On Tue, Jan 06, 2015 at 10:39:13AM +0800, Chen, Tiejun wrote:
>> On 2015/1/6 9:21, Chen, Tiejun wrote:
>>> On 2015/1/6 1:13, Eric Blake wrote:
>>>> 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 <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) {
>>>>
>>>> Over-parenthesized, and looks like you also introduced a spurious space.
>>>> Simpler to just have:
>>>>
>>>> if (!opt || !opt->desc) {
>>>
>>> Looks good.
>>>
>>>>
>>>> Also, there are other threads about the same topic.
>>>> https://lists.gnu.org/archive/html/qemu-devel/2015-01/msg00130.html
>>>
>>> Yeah, I already notice that.
>>>
>>
>> Then I realize I need to extend this to all qemu_opt_get_*.
>
> Marcel is working on a fix.
>
> I think hacking qemu_opt_get_* is not a clean solution. The intention
> was to move away from QemuOpts to QOM properties. The patch that
> removed -machine QemuOptsList descriptions was buggy, but the proper fix
> is to make that approach work instead of hacking qemu_opt_get_*.
>
Understand.
Thanks
Tiejun
^ permalink raw reply [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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.