From nobody Sun May 5 16:23:37 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1512060350826750.8412357634204; Thu, 30 Nov 2017 08:45:50 -0800 (PST) Received: from localhost ([::1]:49249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKRy6-000353-5b for importer@patchew.org; Thu, 30 Nov 2017 11:45:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKRwk-0002NE-Fc for qemu-devel@nongnu.org; Thu, 30 Nov 2017 11:44:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eKRwj-0000Zk-QB for qemu-devel@nongnu.org; Thu, 30 Nov 2017 11:44:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eKRwc-0000OU-2w; Thu, 30 Nov 2017 11:44:14 -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 37578820E6; Thu, 30 Nov 2017 16:44:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0394260A98; Thu, 30 Nov 2017 16:44:11 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 30 Nov 2017 17:44:01 +0100 Message-Id: <20171130164401.29221-1-kwolf@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.26]); Thu, 30 Nov 2017 16:44:13 +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] block: Formats don't need CONSISTENT_READ with NO_IO 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, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 1f4ad7d fixed 'qemu-img info' for raw images that are currently in use as a mirror target. It is not enough for image formats, though, as these still unconditionally request BLK_PERM_CONSISTENT_READ. As this permission is meaningless unless you do actual I/O on the image, drop the requirement and allow 'qemu-img info' even for image formats under conditions where BLK_PERM_CONSISTENT_READ can't be granted. Signed-off-by: Kevin Wolf --- block.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 9a1a0d1e73..ddb6836c52 100644 --- a/block.c +++ b/block.c @@ -1924,6 +1924,8 @@ void bdrv_format_default_perms(BlockDriverState *bs, = BdrvChild *c, assert(role =3D=3D &child_backing || role =3D=3D &child_file); =20 if (!backing) { + int flags =3D bdrv_reopen_get_flags(reopen_queue, bs); + /* Apart from the modifications below, the same permissions are * forwarded and left alone as for filters */ bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, @@ -1936,7 +1938,9 @@ void bdrv_format_default_perms(BlockDriverState *bs, = BdrvChild *c, =20 /* bs->file always needs to be consistent because of the metadata.= We * can never allow other users to resize or write to it. */ - perm |=3D BLK_PERM_CONSISTENT_READ; + if (!(flags & BDRV_O_NO_IO)) { + perm |=3D BLK_PERM_CONSISTENT_READ; + } shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); } else { /* We want consistent read from backing files if the parent needs = it. --=20 2.13.6