[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 51/54] block: Assertions for write permissions
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 51/54] block: Assertions for write permissions |
Date: |
Tue, 21 Feb 2017 15:58:47 +0100 |
This adds assertions that ensure that the necessary write permissions
have been granted before someone attempts to write to a node.
Signed-off-by: Kevin Wolf <address@hidden>
---
block/io.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/block/io.c b/block/io.c
index 63e4400..4c79745 100644
--- a/block/io.c
+++ b/block/io.c
@@ -925,9 +925,11 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs,
uint64_t offset,
return drv->bdrv_co_pwritev_compressed(bs, offset, bytes, qiov);
}
-static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs,
+static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
int64_t offset, unsigned int bytes, QEMUIOVector *qiov)
{
+ BlockDriverState *bs = child->bs;
+
/* Perform I/O through a temporary buffer so that users who scribble over
* their read buffer while the operation is in progress do not end up
* modifying the image file. This is critical for zero-copy guest I/O
@@ -943,6 +945,8 @@ static int coroutine_fn
bdrv_co_do_copy_on_readv(BlockDriverState *bs,
size_t skip_bytes;
int ret;
+ assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
+
/* Cover entire cluster so no additional backing file I/O is required when
* allocating cluster in the image file.
*/
@@ -1051,7 +1055,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild
*child,
}
if (!ret || pnum != nb_sectors) {
- ret = bdrv_co_do_copy_on_readv(bs, offset, bytes, qiov);
+ ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov);
goto out;
}
}
@@ -1334,6 +1338,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild
*child,
assert(!waited || !req->serialising);
assert(req->overlap_offset <= offset);
assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
+ assert(child->perm & BLK_PERM_WRITE);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
--
1.8.3.1
- [Qemu-devel] [PATCH 43/54] stream: Use real permissions in streaming block job, (continued)
- [Qemu-devel] [PATCH 43/54] stream: Use real permissions in streaming block job, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 42/54] mirror: Use real permissions in mirror/active commit block job, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 46/54] hmp: Request permissions in qemu-io, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 45/54] commit: Add filter-node-name to block-commit, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 49/54] tests: Remove FIXME comments, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 51/54] block: Assertions for write permissions,
Kevin Wolf <=
- [Qemu-devel] [PATCH 47/54] migration/block: Use real permissions, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 50/54] block: Pass BdrvChild to bdrv_aligned_preadv/pwritev, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 48/54] nbd/server: Use real permissions for NBD exports, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 52/54] block: Assertions for resize permission, Kevin Wolf, 2017/02/21