diff mbox series

[1/2] block: Open backing image in force share mode for size probe

Message ID 20171215080446.10671-2-famz@redhat.com
State New
Headers show
Series block: Fix qemu-img creating overlay when guest running | expand

Commit Message

Fam Zheng Dec. 15, 2017, 8:04 a.m. UTC
Management tools create overlays of running guests with qemu-img:

  $ qemu-img create -b /image/in/use.qcow2 -f qcow2 /overlay/image.qcow2

but this doesn't work anymore due to image locking:

    qemu-img: /overlay/image.qcow2: Failed to get shared "write" lock
    Is another process using the image?
    Could not open backing image to determine size.
Use the force share option to allow this use case again.

Cc: qemu-stable@nongnu.org
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kevin Wolf Dec. 22, 2017, 12:49 p.m. UTC | #1
Am 15.12.2017 um 09:04 hat Fam Zheng geschrieben:
> Management tools create overlays of running guests with qemu-img:
> 
>   $ qemu-img create -b /image/in/use.qcow2 -f qcow2 /overlay/image.qcow2
> 
> but this doesn't work anymore due to image locking:
> 
>     qemu-img: /overlay/image.qcow2: Failed to get shared "write" lock
>     Is another process using the image?
>     Could not open backing image to determine size.
> Use the force share option to allow this use case again.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Fam Zheng <famz@redhat.com>

Thanks, applied this patch to the block branch. Please resend a fixed
version of the test case.

Kevin
diff mbox series

Patch

diff --git a/block.c b/block.c
index 9a1a0d1e73..f236431da1 100644
--- a/block.c
+++ b/block.c
@@ -4593,10 +4593,11 @@  void bdrv_img_create(const char *filename, const char *fmt,
         back_flags = flags;
         back_flags &= ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
 
+        backing_options = qdict_new();
         if (backing_fmt) {
-            backing_options = qdict_new();
             qdict_put_str(backing_options, "driver", backing_fmt);
         }
+        qdict_put_bool(backing_options, BDRV_OPT_FORCE_SHARE, true);
 
         bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
                        &local_err);