From patchwork Tue Mar 14 02:39:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 738533 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vhzVh2DFxz9s5g for ; Tue, 14 Mar 2017 13:40:28 +1100 (AEDT) Received: from localhost ([::1]:56057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cncNt-0002SB-MF for incoming@patchwork.ozlabs.org; Mon, 13 Mar 2017 22:40:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cncNE-0002OY-9p for qemu-devel@nongnu.org; Mon, 13 Mar 2017 22:39:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cncND-0008Aw-HE for qemu-devel@nongnu.org; Mon, 13 Mar 2017 22:39:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55422) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cncNB-00089P-AZ; Mon, 13 Mar 2017 22:39:41 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7131881F01; Tue, 14 Mar 2017 02:39:41 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-40.pek2.redhat.com [10.72.8.40]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2E2da4v010132; Mon, 13 Mar 2017 22:39:39 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 14 Mar 2017 10:39:31 +0800 Message-Id: <20170314023933.12118-2-famz@redhat.com> In-Reply-To: <20170314023933.12118-1-famz@redhat.com> References: <20170314023933.12118-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 14 Mar 2017 02:39:41 +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 RFC 1/3] block: Introduce BDRV_O_UNSAFE_READ 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This flag clears out the "consistent read" permission that blk_new_open requests. Signed-off-by: Fam Zheng Reviewed-by: Eric Blake --- block/block-backend.c | 2 +- include/block/block.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 5742c09..99428ee 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -197,7 +197,7 @@ BlockBackend *blk_new_open(const char *filename, const char *reference, * caller of blk_new_open() doesn't make use of the permissions, but they * shouldn't hurt either. We can still share everything here because the * guest devices will add their own blockers if they can't share. */ - perm = BLK_PERM_CONSISTENT_READ; + perm = flags & BDRV_O_UNSAFE_READ ? 0 : BLK_PERM_CONSISTENT_READ; if (flags & BDRV_O_RDWR) { perm |= BLK_PERM_WRITE; } diff --git a/include/block/block.h b/include/block/block.h index 5149260..d43b563 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -98,6 +98,7 @@ typedef struct HDGeometry { select an appropriate protocol driver, ignoring the format layer */ #define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */ +#define BDRV_O_UNSAFE_READ 0x20000 /* don't require consistent read */ #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH)