summaryrefslogtreecommitdiff
path: root/block/io.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2017-02-09 16:49:53 +0100
committerKevin Wolf <kwolf@redhat.com>2017-02-28 20:47:50 +0100
commitafa4b293230c0bad3dfbfa9c0ff3f7bdfab40430 (patch)
tree8ce9f74142ecd9146a3a38decb61afb758628db7 /block/io.c
parent85c97ca7a10b93216bc95052e9dabe3a4bb8736a (diff)
downloadqemu-afa4b293230c0bad3dfbfa9c0ff3f7bdfab40430.tar.gz
block: Assertions for write permissions
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 <kwolf@redhat.com> Acked-by: Fam Zheng <famz@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/io.c')
-rw-r--r--block/io.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/io.c b/block/io.c
index 2592ca1bd4..4c797454a4 100644
--- a/block/io.c
+++ b/block/io.c
@@ -945,6 +945,8 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
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.
*/
@@ -1336,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);