diff options
author | Kevin Wolf <kwolf@redhat.com> | 2017-02-17 14:52:00 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-02-28 20:47:50 +0100 |
commit | c8f6d58edb0defbe1e90d44419ec8ec6d711c341 (patch) | |
tree | 3717fe97ab2df370bd059691826719d71f666cc1 | |
parent | afa4b293230c0bad3dfbfa9c0ff3f7bdfab40430 (diff) |
block: Assertions for resize permission
This adds an assertion that ensures that the necessary resize permission
has been granted before bdrv_truncate() is called.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
-rw-r--r-- | block.c | 3 | ||||
-rw-r--r-- | block/io.c | 1 |
2 files changed, 4 insertions, 0 deletions
@@ -3122,6 +3122,9 @@ int bdrv_truncate(BdrvChild *child, int64_t offset) BlockDriverState *bs = child->bs; BlockDriver *drv = bs->drv; int ret; + + assert(child->perm & BLK_PERM_RESIZE); + if (!drv) return -ENOMEDIUM; if (!drv->bdrv_truncate) diff --git a/block/io.c b/block/io.c index 4c797454a4..8f38d46de0 100644 --- a/block/io.c +++ b/block/io.c @@ -1339,6 +1339,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, assert(req->overlap_offset <= offset); assert(offset + bytes <= req->overlap_offset + req->overlap_bytes); assert(child->perm & BLK_PERM_WRITE); + assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE); ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req); |