aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2017-02-17 14:52:00 +0100
committerKevin Wolf <kwolf@redhat.com>2017-02-28 20:47:50 +0100
commitc8f6d58edb0defbe1e90d44419ec8ec6d711c341 (patch)
tree3717fe97ab2df370bd059691826719d71f666cc1 /block.c
parentafa4b293230c0bad3dfbfa9c0ff3f7bdfab40430 (diff)
downloadqemu-c8f6d58edb0defbe1e90d44419ec8ec6d711c341.zip
qemu-c8f6d58edb0defbe1e90d44419ec8ec6d711c341.tar.gz
qemu-c8f6d58edb0defbe1e90d44419ec8ec6d711c341.tar.bz2
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>
Diffstat (limited to 'block.c')
-rw-r--r--block.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block.c b/block.c
index 79d9ad0..74ac7dc 100644
--- a/block.c
+++ b/block.c
@@ -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)