From nobody Sat Feb 7 07:10:32 2026 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 1500339296439482.54259802530214; Mon, 17 Jul 2017 17:54:56 -0700 (PDT) Received: from localhost ([::1]:53281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXGms-0004SI-Vm for importer@patchew.org; Mon, 17 Jul 2017 20:54:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXGTB-0002KA-CF for qemu-devel@nongnu.org; Mon, 17 Jul 2017 20:34:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXGTA-00060z-Do for qemu-devel@nongnu.org; Mon, 17 Jul 2017 20:34:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39884) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXGT5-0005xQ-Jb; Mon, 17 Jul 2017 20:34:27 -0400 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 8B4CB2F86D6; Tue, 18 Jul 2017 00:34:26 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-231.bos.redhat.com [10.18.17.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF28677C1E; Tue, 18 Jul 2017 00:34:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B4CB2F86D6 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jsnow@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8B4CB2F86D6 From: John Snow To: qemu-block@nongnu.org Date: Mon, 17 Jul 2017 20:34:21 -0400 Message-Id: <20170718003422.4497-2-jsnow@redhat.com> In-Reply-To: <20170718003422.4497-1-jsnow@redhat.com> References: <20170718003422.4497-1-jsnow@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.29]); Tue, 18 Jul 2017 00:34:26 +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 v5 1/2] blockdev: move BDRV_O_NO_BACKING option forward 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: kwolf@redhat.com, John Snow , qemu-devel@nongnu.org, mreitz@redhat.com 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" For both external_snapshot_prepare and qmp_drive_mirror, we eventually append the option BDRV_O_NO_BACKING. However, we generally do so after we create the image. To accommodate image creation wanting to verify that a backing file exists or not, add this option prior to create to override checking the existence of the backing file. This prevents QEMU from trying to re-open a backing file that's already in use (thanks to qcow2 locking). Signed-off-by: John Snow Reviewed-by: Eric Blake --- blockdev.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/blockdev.c b/blockdev.c index 7f53cc8..6469f16 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1710,7 +1710,8 @@ static void external_snapshot_prepare(BlkActionState = *common, } =20 flags =3D state->old_bs->open_flags; - flags &=3D ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_COPY_ON_= READ); + flags &=3D ~(BDRV_O_SNAPSHOT | BDRV_O_COPY_ON_READ); + flags |=3D BDRV_O_NO_BACKING; =20 /* create new image w/backing file */ mode =3D s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS; @@ -1735,8 +1736,6 @@ static void external_snapshot_prepare(BlkActionState = *common, qdict_put_str(options, "node-name", snapshot_node_name); } qdict_put_str(options, "driver", format); - - flags |=3D BDRV_O_NO_BACKING; } =20 state->new_bs =3D bdrv_open(new_image_file, snapshot_ref, options, fla= gs, @@ -3548,6 +3547,9 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) backing_mode =3D MIRROR_OPEN_BACKING_CHAIN; } =20 + /* Don't open backing image in create() */ + flags |=3D BDRV_O_NO_BACKING; + if ((arg->sync =3D=3D MIRROR_SYNC_MODE_FULL || !source) && arg->mode !=3D NEW_IMAGE_MODE_EXISTING) { @@ -3587,8 +3589,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) /* Mirroring takes care of copy-on-write using the source's backing * file. */ - target_bs =3D bdrv_open(arg->target, NULL, options, - flags | BDRV_O_NO_BACKING, errp); + target_bs =3D bdrv_open(arg->target, NULL, options, flags, errp); if (!target_bs) { goto out; } --=20 2.9.4