[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/30] qcow2: Restore total_sectors value in save_vms
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 02/30] qcow2: Restore total_sectors value in save_vmstate |
Date: |
Thu, 31 Oct 2013 16:48:16 +0100 |
From: Max Reitz <address@hidden>
Since df2a6f29a5, bdrv_co_do_writev increases the total_sectors value of
a growable block devices on writes after the current end. This leads to
the virtual disk apparently growing in qcow2_save_vmstate, which in turn
affects the disk size captured by the internal snapshot taken directly
afterwards through e.g. the HMP savevm command. Such a "grown" snapshot
cannot be loaded after reopening the qcow2 image, since its disk size
differs from the actual virtual disk size (writing a VM state does not
actually increase the virtual disk size).
Fix this by restoring total_sectors at the end of qcow2_save_vmstate.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index c1abaff..4a3e8b4 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1939,6 +1939,7 @@ static int qcow2_save_vmstate(BlockDriverState *bs,
QEMUIOVector *qiov,
int64_t pos)
{
BDRVQcowState *s = bs->opaque;
+ int64_t total_sectors = bs->total_sectors;
int growable = bs->growable;
int ret;
@@ -1947,6 +1948,11 @@ static int qcow2_save_vmstate(BlockDriverState *bs,
QEMUIOVector *qiov,
ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);
bs->growable = growable;
+ /* bdrv_co_do_writev will have increased the total_sectors value to include
+ * the VM state - the VM state is however not an actual part of the block
+ * device, therefore, we need to restore the old value. */
+ bs->total_sectors = total_sectors;
+
return ret;
}
--
1.8.1.4
- [Qemu-devel] [PULL v2 00/30] Block patches, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 02/30] qcow2: Restore total_sectors value in save_vmstate,
Kevin Wolf <=
- [Qemu-devel] [PULL 04/30] qemu-img: add special exit code if bdrv_check is not supported, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 05/30] block/vpc: check that the image has not been truncated, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 01/30] qapi: fix documentation example, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 03/30] qcow2: Unset zero_beyond_eof in save_vmstate, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 06/30] qemu-iotests: Test for loading VM state from qcow2, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 07/30] qcow2: Flush image after creation, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 09/30] ide-test: Check what happens with bus mastering disabled, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 10/30] tests: Multiboot mmap test case, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 11/30] block: Don't copy backing file name on error, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 08/30] exec: Fix bounce buffer allocation in address_space_map(), Kevin Wolf, 2013/10/31