qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v13 02/20] block: Drop consistent read perm if opene


From: Fam Zheng
Subject: [Qemu-devel] [PATCH v13 02/20] block: Drop consistent read perm if opened unsafe
Date: Thu, 20 Apr 2017 15:52:19 +0800

Signed-off-by: Fam Zheng <address@hidden>
---
 block.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 1fbbb8d..f5182d8 100644
--- a/block.c
+++ b/block.c
@@ -1722,9 +1722,15 @@ void bdrv_format_default_perms(BlockDriverState *bs, 
BdrvChild *c,
         }
 
         /* bs->file always needs to be consistent because of the metadata. We
-         * can never allow other users to resize or write to it. */
-        perm |= BLK_PERM_CONSISTENT_READ;
-        shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
+         * cannot allow other users to resize or write to it unless the caller
+         * explicitly expects unsafe readings. */
+        if (!(bdrv_get_flags(bs) & BDRV_O_UNSAFE_READ)) {
+            perm |= BLK_PERM_CONSISTENT_READ;
+            shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
+        } else {
+            perm &= ~BLK_PERM_CONSISTENT_READ;
+            shared |= BLK_PERM_WRITE | BLK_PERM_RESIZE;
+        }
     } else {
         /* We want consistent read from backing files if the parent needs it.
          * No other operations are performed on backing files. */
-- 
2.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]