aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/qcow2.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index 9637f2ea3a..b8eae902a3 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -677,7 +677,9 @@ static int preallocate(BlockDriverState *bs)
* EOF). Extend the image to the last allocated sector.
*/
if (cluster_offset != 0) {
- bdrv_truncate(s->hd, cluster_offset + (num << 9));
+ uint8_t buf[512];
+ memset(buf, 0, 512);
+ bdrv_write(s->hd, (cluster_offset >> 9) + num - 1, buf, 1);
}
return 0;