diff mbox

[Bug,1740364] Re: qemu-img: fails to get shared 'write' lock

Message ID 20180105100334.GH2787@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Richard W.M. Jones Jan. 5, 2018, 10:03 a.m. UTC
On Fri, Jan 05, 2018 at 02:44:54AM -0000, Ping Li wrote:
> The behaviour should be expected. Since qemu 2.10, image locking is
> enabled which make multiple QEMU processes cannot write to the same
> image, even if boot snapshot and backing file at the same time are
> not allowed. 
> You could get image info with the option "-U" as below:
> $qemu-img info -U $ImageName
> The reason qcow2 is not allowed is because metadata has to be read 
> from the image file, and it is not safe if the image is being used 
> by the VM, because it may update metadata while we read it, 
> resulting in inconsistent or wrong output.

The higher layers deal with inconsistent output.  We want a way to
turn off locking when *we* know that it's safe, qemu doesn't have a
way to know that.

Interestingly the -U option is undocumented, but it seems like what we
want here.

Yaniv, how about this (only lightly tested):



Rich.
diff mbox

Patch

diff --git a/lib/info.c b/lib/info.c
index 4464df994..460596373 100644
--- a/lib/info.c
+++ b/lib/info.c
@@ -193,6 +193,7 @@  get_json_output (guestfs_h *g, const char *filename)
 
   guestfs_int_cmd_add_arg (cmd, QEMU_IMG);
   guestfs_int_cmd_add_arg (cmd, "info");
+  guestfs_int_cmd_add_arg (cmd, "-U");
   guestfs_int_cmd_add_arg (cmd, "--output");
   guestfs_int_cmd_add_arg (cmd, "json");
   guestfs_int_cmd_add_arg (cmd, fdpath);