From: Peter Lieven Date: Mon, 11 Mar 2013 10:04:24 +0000 (+0100) Subject: block: complete all IOs before resizing a device X-Git-Tag: v1.4.1~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b92aa36d112780674d5686ad9c98e8cfe68d207;p=thirdparty%2Fqemu.git block: complete all IOs before resizing a device this patch ensures that all pending IOs are completed before a device is resized. this is especially important if a device is shrinked as it the bdrv_check_request() result is invalidated. Signed-off-by: Peter Lieven Signed-off-by: Kevin Wolf (cherry picked from commit 92b7a08d64e5e3129fa885f9d180e5bddcb76b42) Signed-off-by: Michael Roth --- diff --git a/blockdev.c b/blockdev.c index 63e6f1eafa8..4ea2725fce1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1043,6 +1043,9 @@ void qmp_block_resize(const char *device, int64_t size, Error **errp) return; } + /* complete all in-flight operations before resizing the device */ + bdrv_drain_all(); + switch (bdrv_truncate(bs, size)) { case 0: break;