thebeanogamer / rpms / qemu-kvm

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