diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-09-06 12:20:08 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-09-12 10:12:46 +0200 |
commit | 1ebf561c11302f4fbe4afdd82758fe053cf1d5fc (patch) | |
tree | 97ddd797d3feefe5751a858b3b2df42efbd3dea1 /block/qcow2-snapshot.c | |
parent | 670df5e3b4b5ef830a7c3c970170dbfa11cbb8d2 (diff) | |
download | qemu-1ebf561c11302f4fbe4afdd82758fe053cf1d5fc.zip qemu-1ebf561c11302f4fbe4afdd82758fe053cf1d5fc.tar.gz qemu-1ebf561c11302f4fbe4afdd82758fe053cf1d5fc.tar.bz2 |
qcow2: Discard VM state in active L1 after creating snapshot
During savevm, the VM state is written to the active L1 of the image and
then a snapshot is taken. After that, the VM state isn't needed any more
in the active L1 and should be discarded. This is implemented by this
patch.
The impact of not discarding the VM state is that a snapshot can never
become smaller than any previous snapshot (because it would be padded
with old VM state), and more importantly that future savevm operations
cause unnecessary COWs (with associated flushes), which makes subsequent
snapshots much slower.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qcow2-snapshot.c')
-rw-r--r-- | block/qcow2-snapshot.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index e7e6013..ffead08 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -416,6 +416,13 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) g_free(old_snapshot_list); + /* The VM state isn't needed any more in the active L1 table; in fact, it + * hurts by causing expensive COW for the next snapshot. */ + qcow2_discard_clusters(bs, qcow2_vm_state_offset(s), + align_offset(sn->vm_state_size, s->cluster_size) + >> BDRV_SECTOR_BITS, + QCOW2_DISCARD_NEVER); + #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; |