[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/19] blockdev: Use BlockBackend to resize in qmp_bl
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 09/19] blockdev: Use BlockBackend to resize in qmp_block_resize() |
Date: |
Fri, 24 Feb 2017 19:17:00 +0100 |
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 <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
blockdev.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index bbf9d4d..2b2f6ce 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2858,6 +2858,7 @@ void qmp_block_resize(bool has_device, const char *device,
int64_t size, Error **errp)
{
Error *local_err = NULL;
+ BlockBackend *blk = NULL;
BlockDriverState *bs;
AioContext *aio_context;
int ret;
@@ -2888,10 +2889,13 @@ void qmp_block_resize(bool has_device, const char
*device,
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;
@@ -2913,6 +2917,7 @@ void qmp_block_resize(bool has_device, const char *device,
}
out:
+ blk_unref(blk);
aio_context_release(aio_context);
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/19] Block layer patches, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 02/19] qemu-iotests: add ability to exclude certain protocols from tests, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 01/19] qemu-iotests: Test 137 only supports 'file' protocol, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 03/19] qemu-iotests: redirect nbd server stdout to /dev/null, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 04/19] qemu-img: Do not truncate before preallocation, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 05/19] qemu-img: Add tests for raw image preallocation, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 07/19] qemu-img: Improve documentation for PREALLOC_MODE_FALLOC, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 06/19] qemu-img: Truncate before full preallocation, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 08/19] iotests: Fix another race in 030, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 09/19] blockdev: Use BlockBackend to resize in qmp_block_resize(),
Kevin Wolf <=
- [Qemu-devel] [PULL 11/19] mirror: Resize active commit base in mirror_run(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 12/19] block: Pass BdrvChild to bdrv_truncate(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 15/19] block: Use BlockBackend for image probing, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 10/19] qcow2: Use BB for resizing in qcow2_amend_options(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 14/19] block: Factor out bdrv_open_child_bs(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 16/19] block: Factor out bdrv_open_driver(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 17/19] block: Add bdrv_new_open_driver(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 18/19] vvfat: Use opened node as backing file, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 13/19] block: Attach bs->file only during .bdrv_open(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 19/19] tests: Use opened block node for block job tests, Kevin Wolf, 2017/02/24