This flag clears out the "consistent read" permission that blk_new_open
requests.

Signed-off-by: Fam Zheng <f...@redhat.com>
Reviewed-by: Eric Blake <ebl...@redhat.com>
---
 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 7405024..b4ba182 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -200,7 +200,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 5ddc0cf..a4917d7 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)
 
-- 
2.9.3


Reply via email to