summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorPeter Lieven <pl@dlhnet.de>2013-02-18 13:48:31 +0100
committerKevin Wolf <kwolf@redhat.com>2013-02-22 21:21:10 +0100
commit9a665b2b8640e464f0a778216fc2dca8d02acf33 (patch)
tree840c08fece8a246200f56691d88e679fc45de7fe /block.c
parent027003152f4cf21952f9282b4487daf3fdd372ba (diff)
downloadqemu-9a665b2b8640e464f0a778216fc2dca8d02acf33.tar.gz
qemu-9a665b2b8640e464f0a778216fc2dca8d02acf33.tar.bz2
qemu-9a665b2b8640e464f0a778216fc2dca8d02acf33.zip
block: complete all IOs before .bdrv_truncate
bdrv_truncate() invalidates the bdrv_check_request() result for in-flight requests, so there should better be none. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven <pl@kamp.de> Reported-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block.c b/block.c
index a4d7125eec..f184b376da 100644
--- a/block.c
+++ b/block.c
@@ -2427,6 +2427,10 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset)
return -EACCES;
if (bdrv_in_use(bs))
return -EBUSY;
+
+ /* There better not be any in-flight IOs when we truncate the device. */
+ bdrv_drain_all();
+
ret = drv->bdrv_truncate(bs, offset);
if (ret == 0) {
ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);