Skip to content

Commit

Permalink
test: full snapshot resets dirty pages
Browse files Browse the repository at this point in the history
Test that taking full snapshot is as described in documentation:

> the diff consists of the memory pages which have been dirtied since
> the last snapshot creation or since the creation of the microVM,
> whichever of these events was the most recent.

Co-authored-by: Pablo Barbáchano <[email protected]>
Signed-off-by: Roman Kovtyukh <[email protected]>
  • Loading branch information
pb8o authored and Grandmother committed Jan 19, 2024
1 parent 1f30c73 commit 8498cbc
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/integration_tests/test_dirty_pages_after_full_snapshot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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

0 comments on commit 8498cbc

Please sign in to comment.