[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 01/54] blockdev: Use BlockBackend to resize in qmp_b
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH 01/54] blockdev: Use BlockBackend to resize in qmp_block_resize() |
Date: |
Tue, 21 Feb 2017 15:57:57 +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>
---
blockdev.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index db82ac9..3596d87 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2855,6 +2855,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;
@@ -2885,10 +2886,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;
@@ -2910,6 +2914,7 @@ void qmp_block_resize(bool has_device, const char *device,
}
out:
+ blk_unref(blk);
aio_context_release(aio_context);
}
--
1.8.3.1
- Re: [Qemu-block] [PATCH 03/54] mirror: Resize active commit base in mirror_run(), (continued)
- [Qemu-block] [PATCH 04/54] block: Pass BdrvChild to bdrv_truncate(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 06/54] block: Factor out bdrv_open_child_bs(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 05/54] block: Attach bs->file only during .bdrv_open(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 07/54] block: Use BlockBackend for image probing, Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 01/54] blockdev: Use BlockBackend to resize in qmp_block_resize(),
Kevin Wolf <=
- [Qemu-block] [PATCH 08/54] block: Factor out bdrv_open_driver(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 09/54] block: Add bdrv_new_open_driver(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 10/54] vvfat: Use opened node as backing file, Kevin Wolf, 2017/02/21