Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/vmm/src/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ fn snapshot_memory_to_file(
.dump_dirty(&mut file, &dirty_bitmap)
.map_err(Memory)
}
SnapshotType::Full => vmm.guest_memory().dump(&mut file).map_err(Memory),
SnapshotType::Full => {
let _ = vmm.get_dirty_bitmap().map_err(DirtyBitmap)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only get the bitmap if it exists (see CI errors). Probably by handling the error here.

vmm.guest_memory().dump(&mut file).map_err(Memory)
}
}?;
file.flush()
.map_err(|err| MemoryBackingFile("flush", err))?;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""Test scenario for reseting dirty pages after making a full snapshot."""


def test_dirty_pages_after_full_snapshot(uvm_plain):
"""
Test if dirty pages are erased after making a full snapshot of a VM
"""

vm_mem_size = 128
uvm = uvm_plain
uvm.spawn()
uvm.basic_config(mem_size_mib=vm_mem_size, track_dirty_pages=True)
uvm.add_net_iface()
uvm.start()
uvm.ssh.run("true")

snap_full = uvm.snapshot_full(vmstate_path="vmstate_full", mem_path="mem_full")
snap_diff = uvm.snapshot_diff(vmstate_path="vmstate_diff", mem_path="mem_diff")
snap_diff2 = uvm.snapshot_diff(vmstate_path="vmstate_diff2", mem_path="mem_diff2")

# file size is the same, but the `diff` snapshot is actually a sparse file
assert snap_full.mem.stat().st_size == snap_diff.mem.stat().st_size

# diff -> diff there should be no differences
assert snap_diff2.mem.stat().st_blocks == 0

# full -> diff there should be no differences
assert snap_diff.mem.stat().st_blocks == 0