This adds an assertion that ensures that the necessary resize permission has been granted before bdrv_truncate() is called.
Signed-off-by: Kevin Wolf <[email protected]> --- block.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block.c b/block.c index 560e84a..33e6415 100644 --- a/block.c +++ b/block.c @@ -3098,6 +3098,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) -- 1.8.3.1
