[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 41/41] block: Assertions for write permissions
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [RFC PATCH 41/41] block: Assertions for write permissions |
Date: |
Mon, 13 Feb 2017 18:23:03 +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 cb2feff..74929e5 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] [RFC PATCH 35/41] stream: Use real permissions in streaming block job, (continued)
- [Qemu-devel] [RFC PATCH 35/41] stream: Use real permissions in streaming block job, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 36/41] hmp: Request permissions in qemu-io, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 38/41] nbd/server: Use real permissions for NBD exports, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 26/41] block: Factor out bdrv_open_driver(), Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 29/41] commit: Use real permissions for HMP 'commit', Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 28/41] commit: Use real permissions in commit block job, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 34/41] mirror: Use real permissions in mirror/active commit block job, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 37/41] migration/block: Use real permissions, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 39/41] tests: Remove FIXME comments, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 40/41] block: Pass BdrvChild to bdrv_aligned_preadv/pwritev, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 41/41] block: Assertions for write permissions,
Kevin Wolf <=
- Re: [Qemu-devel] [RFC PATCH 00/41] New op blocker system, no-reply, 2017/02/13