From: "Chen, Tiejun" <tiejun.chen@intel.com>
To: Eric Blake <eblake@redhat.com>,
marcel.a@redhat.com, peter.maydell@linaro.org, agraf@suse.de,
greg.bellows@linaro.org
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC][PATCH] qemu_opt_get_bool_helper: back finding desc by name just if !opt->desc
Date: Tue, 06 Jan 2015 10:39:13 +0800 [thread overview]
Message-ID: <54AB4AD1.5060802@intel.com> (raw)
In-Reply-To: <54AB387F.4010208@intel.com>
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
next prev parent reply other threads:[~2015-01-06 2:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2015-01-06 14:56 ` Stefan Hajnoczi
2015-01-06 16:50 ` Marcel Apfelbaum
2015-01-07 1:24 ` Chen, Tiejun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54AB4AD1.5060802@intel.com \
--to=tiejun.chen@intel.com \
--cc=agraf@suse.de \
--cc=eblake@redhat.com \
--cc=greg.bellows@linaro.org \
--cc=marcel.a@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).