[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 2/7] block: Don't request I/O permission with BDRV_O_
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 2/7] block: Don't request I/O permission with BDRV_O_NO_IO |
Date: |
Tue, 21 Nov 2017 16:10:12 +0100 |
'qemu-img info' makes sense even when BLK_PERM_CONSISTENT_READ cannot be
granted because of a block job in a running qemu process. It already
sets BDRV_O_NO_IO to indicate that it doesn't access the guest visible
data at all.
Check the BDRV_O_NO_IO flags in blk_new_open(), so that I/O related
permissions are not unnecessarily requested and 'qemu-img info' can work
even if BLK_PERM_CONSISTENT_READ cannot be granted.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
---
block/block-backend.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 5836cb3087..baef8e7abc 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -299,7 +299,7 @@ BlockBackend *blk_new_open(const char *filename, const char
*reference,
{
BlockBackend *blk;
BlockDriverState *bs;
- uint64_t perm;
+ uint64_t perm = 0;
/* blk_new_open() is mainly used in .bdrv_create implementations and the
* tools where sharing isn't a concern because the BDS stays private, so we
@@ -309,9 +309,11 @@ 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;
- if (flags & BDRV_O_RDWR) {
- perm |= BLK_PERM_WRITE;
+ if ((flags & BDRV_O_NO_IO) == 0) {
+ perm |= BLK_PERM_CONSISTENT_READ;
+ if (flags & BDRV_O_RDWR) {
+ perm |= BLK_PERM_WRITE;
+ }
}
if (flags & BDRV_O_RESIZE) {
perm |= BLK_PERM_RESIZE;
--
2.13.6
- [Qemu-block] [PULL 0/7] Block layer patches for 2.11.0-rc2, Kevin Wolf, 2017/11/21
- [Qemu-block] [PULL 1/7] block: Don't use BLK_PERM_CONSISTENT_READ for format probing, Kevin Wolf, 2017/11/21
- [Qemu-block] [PULL 2/7] block: Don't request I/O permission with BDRV_O_NO_IO,
Kevin Wolf <=
- [Qemu-block] [PULL 3/7] block: Add errp to bdrv_snapshot_goto(), Kevin Wolf, 2017/11/21
- [Qemu-block] [PULL 4/7] block: Add errp to bdrv_all_goto_snapshot(), Kevin Wolf, 2017/11/21
- [Qemu-block] [PULL 5/7] block: Error out on load_vm with active dirty bitmaps, Kevin Wolf, 2017/11/21
- [Qemu-block] [PULL 6/7] block: Close a BlockDriverState completely even when bs->drv is NULL, Kevin Wolf, 2017/11/21
- [Qemu-block] [PULL 7/7] iotests: Fix 176 on 32-bit host, Kevin Wolf, 2017/11/21
- Re: [Qemu-block] [PULL 0/7] Block layer patches for 2.11.0-rc2, Peter Maydell, 2017/11/21