From nobody Sat Apr 27 21:28:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513325188851332.23067196839054; Fri, 15 Dec 2017 00:06:28 -0800 (PST) Received: from localhost ([::1]:45013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePl0i-000809-7g for importer@patchew.org; Fri, 15 Dec 2017 03:06:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePkzN-0007Dv-6P for qemu-devel@nongnu.org; Fri, 15 Dec 2017 03:05:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePkzJ-0001IN-EU for qemu-devel@nongnu.org; Fri, 15 Dec 2017 03:05:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePkzF-0001FK-BW; Fri, 15 Dec 2017 03:04:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F34BC0587D4; Fri, 15 Dec 2017 08:04:52 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-91.pek2.redhat.com [10.72.12.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id F024F614D0; Fri, 15 Dec 2017 08:04:50 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 16:04:45 +0800 Message-Id: <20171215080446.10671-2-famz@redhat.com> In-Reply-To: <20171215080446.10671-1-famz@redhat.com> References: <20171215080446.10671-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 15 Dec 2017 08:04:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] block: Open backing image in force share mode for size probe X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Blake --- block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ch= ar *fmt, back_flags =3D flags; back_flags &=3D ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKIN= G); =20 + backing_options =3D qdict_new(); if (backing_fmt) { - backing_options =3D qdict_new(); qdict_put_str(backing_options, "driver", backing_fmt); } + qdict_put_bool(backing_options, BDRV_OPT_FORCE_SHARE, true); =20 bs =3D bdrv_open(full_backing, NULL, backing_options, back_flags, &local_err); --=20 2.14.3 From nobody Sat Apr 27 21:28:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513325273092103.50557800182628; Fri, 15 Dec 2017 00:07:53 -0800 (PST) Received: from localhost ([::1]:45020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePl21-0000U4-Fe for importer@patchew.org; Fri, 15 Dec 2017 03:07:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePkzU-0007L7-Hr for qemu-devel@nongnu.org; Fri, 15 Dec 2017 03:05:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePkzO-0001L8-S9 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 03:05:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePkzH-0001Gv-HO; Fri, 15 Dec 2017 03:04:55 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8E1783F3F; Fri, 15 Dec 2017 08:04:54 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-91.pek2.redhat.com [10.72.12.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16A38614D0; Fri, 15 Dec 2017 08:04:52 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 16:04:46 +0800 Message-Id: <20171215080446.10671-3-famz@redhat.com> In-Reply-To: <20171215080446.10671-1-famz@redhat.com> References: <20171215080446.10671-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 15 Dec 2017 08:04:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] iotests: Test creating overlay when guest running X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng Reviewed-by: Eric Blake --- tests/qemu-iotests/153 | 4 ++++ tests/qemu-iotests/153.out | 3 +++ 2 files changed, 7 insertions(+) diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 index fa25eb24bd..22cb9c69a7 100755 --- a/tests/qemu-iotests/153 +++ b/tests/qemu-iotests/153 @@ -32,6 +32,7 @@ _cleanup() { _cleanup_test_img rm -f "${TEST_IMG}.base" + rm -f "${TEST_IMG}.overlay" rm -f "${TEST_IMG}.convert" rm -f "${TEST_IMG}.a" rm -f "${TEST_IMG}.b" @@ -218,6 +219,9 @@ _send_qemu_cmd $QEMU_HANDLE \ =20 _run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512' =20 +echo "Creating overlay with qemu-img when the guest is running should be a= llowed" +_run_cmd $QEMU_IMG create -f $IMGFMT -b "${TEST_IMG}" "${TEST_IMG}.overlay" + echo "Closing the other" _send_qemu_cmd $QEMU_HANDLE \ "{ 'execute': 'human-monitor-command', diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out index 5b917b177c..8131180c49 100644 --- a/tests/qemu-iotests/153.out +++ b/tests/qemu-iotests/153.out @@ -390,6 +390,9 @@ _qemu_img_wrapper info TEST_DIR/t.qcow2 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock Is another process using the image? +Creating overlay with qemu-img when the guest is running should be allowed + +_qemu_img_wrapper create -f qcow2 -b TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.ove= rlay Closing the other =20 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 --=20 2.14.3