qemu-img: Use only string options in img_open_opts
commit4615f87832d2fcb7a544bedeece2741bf8c21f94
authorMax Reitz <mreitz@redhat.com>
Wed, 2 May 2018 20:20:50 +0000 (2 22:20 +0200)
committerMax Reitz <mreitz@redhat.com>
Tue, 15 May 2018 14:15:21 +0000 (15 16:15 +0200)
tree2710d1ae05b64d7fb8d7c9b2bdcf82901f160c7d
parent2a01c01f9ecb43af4c0a85fe6adc429ffc9c31b5
qemu-img: Use only string options in img_open_opts

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:

$ ./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>
Message-id: 20180502202051.15493-3-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
qemu-img.c