|
|
ae23c9 |
From f939ed0a804f86ba8cde7f2401ade2a3b108c81d Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Date: Mon, 25 Jun 2018 13:06:56 +0200
|
|
|
ae23c9 |
Subject: [PATCH 047/268] qemu-img: Use only string options in img_open_opts
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180618163106.23010-3-mreitz@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 80774
|
|
|
ae23c9 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 2/3] qemu-img: Use only string options in img_open_opts
|
|
|
ae23c9 |
Bugzilla: 1576598
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
img_open_opts() takes a QemuOpts and converts them to a QDict, so all
|
|
|
ae23c9 |
values therein are strings. Then it may try to call qdict_get_bool(),
|
|
|
ae23c9 |
however, which will fail with a segmentation fault every time:
|
|
|
ae23c9 |
|
|
|
ae23c9 |
$ ./qemu-img info -U --image-opts \
|
|
|
ae23c9 |
driver=file,filename=/dev/null,force-share=off
|
|
|
ae23c9 |
[1] 27869 segmentation fault (core dumped) ./qemu-img info -U
|
|
|
ae23c9 |
--image-opts driver=file,filename=/dev/null,force-share=off
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Fix this by using qdict_get_str() and comparing the value as a string.
|
|
|
ae23c9 |
Also, when adding a force-share value to the QDict, add it as a string
|
|
|
ae23c9 |
so it fits the rest of the dict.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Cc: qemu-stable@nongnu.org
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Message-id: 20180502202051.15493-3-mreitz@redhat.com
|
|
|
ae23c9 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 4615f87832d2fcb7a544bedeece2741bf8c21f94)
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
qemu-img.c | 4 ++--
|
|
|
ae23c9 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
ae23c9 |
index 62b29e7..60e45ec 100644
|
|
|
ae23c9 |
--- a/qemu-img.c
|
|
|
ae23c9 |
+++ b/qemu-img.c
|
|
|
ae23c9 |
@@ -277,12 +277,12 @@ static BlockBackend *img_open_opts(const char *optstr,
|
|
|
ae23c9 |
options = qemu_opts_to_qdict(opts, NULL);
|
|
|
ae23c9 |
if (force_share) {
|
|
|
ae23c9 |
if (qdict_haskey(options, BDRV_OPT_FORCE_SHARE)
|
|
|
ae23c9 |
- && !qdict_get_bool(options, BDRV_OPT_FORCE_SHARE)) {
|
|
|
ae23c9 |
+ && strcmp(qdict_get_str(options, BDRV_OPT_FORCE_SHARE), "on")) {
|
|
|
ae23c9 |
error_report("--force-share/-U conflicts with image options");
|
|
|
ae23c9 |
qobject_unref(options);
|
|
|
ae23c9 |
return NULL;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
- qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true);
|
|
|
ae23c9 |
+ qdict_put_str(options, BDRV_OPT_FORCE_SHARE, "on");
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
blk = blk_new_open(NULL, NULL, options, flags, &local_err);
|
|
|
ae23c9 |
if (!blk) {
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|