summaryrefslogtreecommitdiffstats
path: root/blockdev.c
diff options
context:
space:
mode:
authorPeter Maydell2017-02-26 13:26:37 +0100
committerPeter Maydell2017-02-26 13:26:37 +0100
commit6b4e463ff35284a3c02c5ceab3351bb07137c77c (patch)
tree607bb2713ae1bb9e6c9c00185bf8949a3a3a0f4c /blockdev.c
parentMerge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (diff)
parenttests: Use opened block node for block job tests (diff)
downloadqemu-6b4e463ff35284a3c02c5ceab3351bb07137c77c.tar.gz
qemu-6b4e463ff35284a3c02c5ceab3351bb07137c77c.tar.xz
qemu-6b4e463ff35284a3c02c5ceab3351bb07137c77c.zip
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches # gpg: Signature made Fri 24 Feb 2017 18:08:26 GMT # gpg: using RSA key 0x7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: tests: Use opened block node for block job tests vvfat: Use opened node as backing file block: Add bdrv_new_open_driver() block: Factor out bdrv_open_driver() block: Use BlockBackend for image probing block: Factor out bdrv_open_child_bs() block: Attach bs->file only during .bdrv_open() block: Pass BdrvChild to bdrv_truncate() mirror: Resize active commit base in mirror_run() qcow2: Use BB for resizing in qcow2_amend_options() blockdev: Use BlockBackend to resize in qmp_block_resize() iotests: Fix another race in 030 qemu-img: Improve documentation for PREALLOC_MODE_FALLOC qemu-img: Truncate before full preallocation qemu-img: Add tests for raw image preallocation qemu-img: Do not truncate before preallocation qemu-iotests: redirect nbd server stdout to /dev/null qemu-iotests: add ability to exclude certain protocols from tests qemu-iotests: Test 137 only supports 'file' protocol Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/blockdev.c b/blockdev.c
index bbf9d4d8f1..2b2f6ceef0 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);
}