Blame SOURCES/kvm-block-Open-backing-image-in-force-share-mode-for-siz.patch

4a2fec
From 20103e6ef28af483bb8aa54b1272fbd480b61aa4 Mon Sep 17 00:00:00 2001
4a2fec
From: Fam Zheng <famz@redhat.com>
4a2fec
Date: Mon, 15 Jan 2018 06:15:18 +0100
4a2fec
Subject: [PATCH 08/12] block: Open backing image in force share mode for size
4a2fec
 probe
4a2fec
4a2fec
RH-Author: Fam Zheng <famz@redhat.com>
4a2fec
Message-id: <20180115061518.16303-1-famz@redhat.com>
4a2fec
Patchwork-id: 78570
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH] block: Open backing image in force share mode for size probe
4a2fec
Bugzilla: 1526212
4a2fec
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
4a2fec
Management tools create overlays of running guests with qemu-img:
4a2fec
4a2fec
  $ qemu-img create -b /image/in/use.qcow2 -f qcow2 /overlay/image.qcow2
4a2fec
4a2fec
but this doesn't work anymore due to image locking:
4a2fec
4a2fec
    qemu-img: /overlay/image.qcow2: Failed to get shared "write" lock
4a2fec
    Is another process using the image?
4a2fec
    Could not open backing image to determine size.
4a2fec
Use the force share option to allow this use case again.
4a2fec
4a2fec
Cc: qemu-stable@nongnu.org
4a2fec
Signed-off-by: Fam Zheng <famz@redhat.com>
4a2fec
Reviewed-by: Eric Blake <eblake@redhat.com>
4a2fec
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
(cherry picked from commit cc954f01e3c004aad081aa36736a17e842b80211)
4a2fec
Signed-off-by: Fam Zheng <famz@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 block.c | 3 ++-
4a2fec
 1 file changed, 2 insertions(+), 1 deletion(-)
4a2fec
4a2fec
diff --git a/block.c b/block.c
4a2fec
index b5736dd..17629ab 100644
4a2fec
--- a/block.c
4a2fec
+++ b/block.c
4a2fec
@@ -4515,10 +4515,11 @@ void bdrv_img_create(const char *filename, const char *fmt,
4a2fec
         back_flags = flags;
4a2fec
         back_flags &= ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
4a2fec
 
4a2fec
+        backing_options = qdict_new();
4a2fec
         if (backing_fmt) {
4a2fec
-            backing_options = qdict_new();
4a2fec
             qdict_put_str(backing_options, "driver", backing_fmt);
4a2fec
         }
4a2fec
+        qdict_put_bool(backing_options, BDRV_OPT_FORCE_SHARE, true);
4a2fec
 
4a2fec
         bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
4a2fec
                        &local_err);
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec