Blame SOURCES/kvm-block-Don-t-request-I-O-permission-with-BDRV_O_NO_IO.patch

4a2fec
From 47357547c1040e029aec3e1d9e850d6249bc2bbb Mon Sep 17 00:00:00 2001
4a2fec
From: Kevin Wolf <kwolf@redhat.com>
4a2fec
Date: Mon, 15 Jan 2018 11:23:36 +0100
4a2fec
Subject: [PATCH 11/12] block: Don't request I/O permission with BDRV_O_NO_IO
4a2fec
4a2fec
RH-Author: Kevin Wolf <kwolf@redhat.com>
4a2fec
Message-id: <20180115112337.20885-3-kwolf@redhat.com>
4a2fec
Patchwork-id: 78575
4a2fec
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH 2/3] block: Don't request I/O permission with BDRV_O_NO_IO
4a2fec
Bugzilla: 1515604
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
4a2fec
'qemu-img info' makes sense even when BLK_PERM_CONSISTENT_READ cannot be
4a2fec
granted because of a block job in a running qemu process. It already
4a2fec
sets BDRV_O_NO_IO to indicate that it doesn't access the guest visible
4a2fec
data at all.
4a2fec
4a2fec
Check the BDRV_O_NO_IO flags in blk_new_open(), so that I/O related
4a2fec
permissions are not unnecessarily requested and 'qemu-img info' can work
4a2fec
even if BLK_PERM_CONSISTENT_READ cannot be granted.
4a2fec
4a2fec
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
Reviewed-by: Fam Zheng <famz@redhat.com>
4a2fec
Reviewed-by: Alberto Garcia <berto@igalia.com>
4a2fec
(cherry picked from commit 1f4ad7d3b8f7162ec0471506d86f57a5d77b8f76)
4a2fec
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 block/block-backend.c | 10 ++++++----
4a2fec
 1 file changed, 6 insertions(+), 4 deletions(-)
4a2fec
4a2fec
diff --git a/block/block-backend.c b/block/block-backend.c
4a2fec
index 083e65f..dce8b96 100644
4a2fec
--- a/block/block-backend.c
4a2fec
+++ b/block/block-backend.c
4a2fec
@@ -299,7 +299,7 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
4a2fec
 {
4a2fec
     BlockBackend *blk;
4a2fec
     BlockDriverState *bs;
4a2fec
-    uint64_t perm;
4a2fec
+    uint64_t perm = 0;
4a2fec
 
4a2fec
     /* blk_new_open() is mainly used in .bdrv_create implementations and the
4a2fec
      * tools where sharing isn't a concern because the BDS stays private, so we
4a2fec
@@ -309,9 +309,11 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
4a2fec
      * caller of blk_new_open() doesn't make use of the permissions, but they
4a2fec
      * shouldn't hurt either. We can still share everything here because the
4a2fec
      * guest devices will add their own blockers if they can't share. */
4a2fec
-    perm = BLK_PERM_CONSISTENT_READ;
4a2fec
-    if (flags & BDRV_O_RDWR) {
4a2fec
-        perm |= BLK_PERM_WRITE;
4a2fec
+    if ((flags & BDRV_O_NO_IO) == 0) {
4a2fec
+        perm |= BLK_PERM_CONSISTENT_READ;
4a2fec
+        if (flags & BDRV_O_RDWR) {
4a2fec
+            perm |= BLK_PERM_WRITE;
4a2fec
+        }
4a2fec
     }
4a2fec
     if (flags & BDRV_O_RESIZE) {
4a2fec
         perm |= BLK_PERM_RESIZE;
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec