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

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