In order to be able to do permission checking and to keep working with
the BdrvChild based bdrv_truncate() that this involves, we need to
create a temporary BlockBackend to resize the image.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
int64_t size, Error **errp)
{
Error *local_err = NULL;
+ BlockBackend *blk = NULL;
BlockDriverState *bs;
AioContext *aio_context;
int ret;
goto out;
}
+ blk = blk_new();
+ blk_insert_bs(blk, bs);
+
/* complete all in-flight operations before resizing the device */
bdrv_drain_all();
- ret = bdrv_truncate(bs, size);
+ ret = blk_truncate(blk, size);
switch (ret) {
case 0:
break;
}
out:
+ blk_unref(blk);
aio_context_release(aio_context);
}