From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-stable@nongnu.org, Fam Zheng <famz@redhat.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] qemu-img: Use only string options in img_open_opts
Date: Thu, 3 May 2018 00:02:44 +0200 [thread overview]
Message-ID: <ca5f1a91-84fe-d11b-f805-c7a8aca84cc3@redhat.com> (raw)
In-Reply-To: <eeef06be-6c71-df6a-6aeb-8a7c23316dee@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1440 bytes --]
On 2018-05-03 00:00, Eric Blake wrote:
> On 05/02/2018 03:20 PM, Max Reitz wrote:
>> img_open_opts() takes a QemuOpts and converts them to a QDict, so all
>> values therein are strings. Then it may try to call qdict_get_bool(),
>> however, which will fail with a segmentation fault every time:
>
> I have no idea if it's worth fixing qdict_get_bool() to at least not
> segfault when called on a non-bool Dict member (but what should it
> return, true or false? or should it abort() for at least a cleaner
> failure than a segfault?)
There's qdict_get_try_bool() which returns a default. For testing
whether the member is a bool I suppose you can use
qdict_to(QBool, qdict_get(qdict, member)).
Max
> But in the meantime, your fix is correct.
>
>>
>> $ ./qemu-img info -U --image-opts \
>> driver=file,filename=/dev/null,force-share=off
>> [1] 27869 segmentation fault (core dumped) ./qemu-img info -U
>> --image-opts driver=file,filename=/dev/null,force-share=off
>>
>> Fix this by using qdict_get_str() and comparing the value as a string.
>> Also, when adding a force-share value to the QDict, add it as a string
>> so it fits the rest of the dict.
>>
>> Cc: qemu-stable@nongnu.org
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> qemu-img.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2018-05-02 22:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-02 20:20 [Qemu-devel] [PATCH 0/3] qemu-io/img: Fix -U/force-share conflict testing Max Reitz
2018-05-02 20:20 ` [Qemu-devel] [PATCH 1/3] qemu-io: Use purely string blockdev options Max Reitz
2018-05-02 21:57 ` Eric Blake
2018-05-02 20:20 ` [Qemu-devel] [PATCH 2/3] qemu-img: Use only string options in img_open_opts Max Reitz
2018-05-02 22:00 ` Eric Blake
2018-05-02 22:02 ` Max Reitz [this message]
2018-05-02 20:20 ` [Qemu-devel] [PATCH 3/3] iotests: Add test for -U/force-share conflicts Max Reitz
2018-05-02 22:02 ` Eric Blake
2018-05-09 21:57 ` [Qemu-devel] [PATCH 0/3] qemu-io/img: Fix -U/force-share conflict testing Max Reitz
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=ca5f1a91-84fe-d11b-f805-c7a8aca84cc3@redhat.com \
--to=mreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).