From patchwork Fri Jan 5 10:03:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard W.M. Jones" X-Patchwork-Id: 10146237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D75CD60153 for ; Fri, 5 Jan 2018 10:12:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8A7C223C7 for ; Fri, 5 Jan 2018 10:12:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD31927BFF; Fri, 5 Jan 2018 10:12:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE233223C7 for ; Fri, 5 Jan 2018 10:12:05 +0000 (UTC) Received: from localhost ([::1]:59792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXOyr-00061n-04 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 Jan 2018 05:12:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXOxj-00058K-08 for qemu-devel@nongnu.org; Fri, 05 Jan 2018 05:11:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXOxe-0007FX-H0 for qemu-devel@nongnu.org; Fri, 05 Jan 2018 05:10:54 -0500 Received: from indium.canonical.com ([91.189.90.7]:34406) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eXOxd-0007Dn-Vj for qemu-devel@nongnu.org; Fri, 05 Jan 2018 05:10:50 -0500 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.86_2 #2 (Debian)) id 1eXOxd-0002Zz-44 for ; Fri, 05 Jan 2018 10:10:49 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 1D2B12E802D for ; Fri, 5 Jan 2018 10:10:49 +0000 (UTC) MIME-Version: 1.0 Date: Fri, 05 Jan 2018 10:03:34 -0000 From: Richard Jones To: qemu-devel@nongnu.org X-Launchpad-Notification-Type: bug X-Launchpad-Bug: product=qemu; status=New; importance=Undecided; assignee=None; X-Launchpad-Bug-Tags: regression X-Launchpad-Bug-Information-Type: Public X-Launchpad-Bug-Private: no X-Launchpad-Bug-Security-Vulnerability: no X-Launchpad-Bug-Commenters: pingl rjones-redhat ykaul X-Launchpad-Bug-Reporter: Yaniv Kaul (ykaul) X-Launchpad-Bug-Modifier: Richard Jones (rjones-redhat) References: <151444692163.26459.1330629893044006612.malonedeb@gac.canonical.com> <151512029457.2799.7813958810864461287.malone@soybean.canonical.com> Message-Id: <20180105100334.GH2787@redhat.com> X-Launchpad-Message-Rationale: Subscriber (QEMU) @qemu-devel-ml X-Launchpad-Message-For: qemu-devel-ml Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="18521"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 5cbe2e3baeb50541a99dc6decd1e5e624629a453 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 91.189.90.7 Subject: Re: [Qemu-devel] [Bug 1740364] Re: qemu-img: fails to get shared 'write' lock X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Bug 1740364 <1740364@bugs.launchpad.net> Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --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);