Blame SOURCES/kvm-qemu-io-Use-purely-string-blockdev-options.patch

1bdc94
From 31e4b214ef764476e99ddbbfd4b039235e3a4ea1 Mon Sep 17 00:00:00 2001
1bdc94
From: Max Reitz <mreitz@redhat.com>
1bdc94
Date: Mon, 25 Jun 2018 13:04:46 +0200
1bdc94
Subject: [PATCH 37/54] qemu-io: Use purely string blockdev options
1bdc94
1bdc94
RH-Author: Max Reitz <mreitz@redhat.com>
1bdc94
Message-id: <20180618163106.23010-2-mreitz@redhat.com>
1bdc94
Patchwork-id: 80775
1bdc94
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/3] qemu-io: Use purely string blockdev options
1bdc94
Bugzilla: 1576598
1bdc94
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
RH-Acked-by: Fam Zheng <famz@redhat.com>
1bdc94
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
1bdc94
Currently, qemu-io only uses string-valued blockdev options (as all are
1bdc94
converted directly from QemuOpts) -- with one exception: -U adds the
1bdc94
force-share option as a boolean.  This in itself is already a bit
1bdc94
questionable, but a real issue is that it also assumes the value already
1bdc94
existing in the options QDict would be a boolean, which is wrong.
1bdc94
1bdc94
That has the following effect:
1bdc94
1bdc94
$ ./qemu-io -r -U --image-opts \
1bdc94
    driver=file,filename=/dev/null,force-share=off
1bdc94
[1]    15200 segmentation fault (core dumped)  ./qemu-io -r -U
1bdc94
--image-opts driver=file,filename=/dev/null,force-share=off
1bdc94
1bdc94
Since @opts is converted from QemuOpts, the value must be a string, and
1bdc94
we have to compare it as such.  Consequently, it makes sense to also set
1bdc94
it as a string instead of a boolean.
1bdc94
1bdc94
Cc: qemu-stable@nongnu.org
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
Message-id: 20180502202051.15493-2-mreitz@redhat.com
1bdc94
Reviewed-by: Eric Blake <eblake@redhat.com>
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
(cherry picked from commit 2a01c01f9ecb43af4c0a85fe6adc429ffc9c31b5)
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 qemu-io.c | 4 ++--
1bdc94
 1 file changed, 2 insertions(+), 2 deletions(-)
1bdc94
1bdc94
diff --git a/qemu-io.c b/qemu-io.c
1bdc94
index 72fee0d..73c638f 100644
1bdc94
--- a/qemu-io.c
1bdc94
+++ b/qemu-io.c
1bdc94
@@ -95,12 +95,12 @@ static int openfile(char *name, int flags, bool writethrough, bool force_share,
1bdc94
             opts = qdict_new();
1bdc94
         }
1bdc94
         if (qdict_haskey(opts, BDRV_OPT_FORCE_SHARE)
1bdc94
-            && !qdict_get_bool(opts, BDRV_OPT_FORCE_SHARE)) {
1bdc94
+            && strcmp(qdict_get_str(opts, BDRV_OPT_FORCE_SHARE), "on")) {
1bdc94
             error_report("-U conflicts with image options");
1bdc94
             qobject_unref(opts);
1bdc94
             return 1;
1bdc94
         }
1bdc94
-        qdict_put_bool(opts, BDRV_OPT_FORCE_SHARE, true);
1bdc94
+        qdict_put_str(opts, BDRV_OPT_FORCE_SHARE, "on");
1bdc94
     }
1bdc94
     qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);
1bdc94
     if (!qemuio_blk) {
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94