-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store kvm dirty bitmap inside firecrackers internal bitmap so no data is lost incase of an error Signed-off-by: Jack Thomson <jackabt@amazon.com> Co-authored-by: Roman Kovtyukh <HelloDearGrandma@gmail.com> Co-authored-by: Pablo Barbáchano <pablob@amazon.com>
- Loading branch information
1 parent
fd40204
commit cd0eb6b
Showing
3 changed files
with
102 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
tests/integration_tests/functional/test_snapshot_not_losing_dirty_pages.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
"""Test that the no dirty pages lost in case of error during snapshot creation.""" | ||
|
||
import subprocess | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def mount_tmpfs_small(worker_id): | ||
"""Mount a small tmpfs and return its path""" | ||
mnt_path = Path(f"/mnt/{worker_id}") | ||
mnt_path.mkdir(parents=True) | ||
subprocess.check_call( | ||
["mount", "-o", "size=512M", "-t", "tmpfs", "none", str(mnt_path)] | ||
) | ||
try: | ||
yield mnt_path | ||
finally: | ||
subprocess.check_call(["umount", mnt_path]) | ||
mnt_path.rmdir() | ||
|
||
|
||
def test_diff_snapshot_works_after_error( | ||
microvm_factory, guest_kernel_linux_5_10, rootfs_ubuntu_22, mount_tmpfs_small | ||
): | ||
""" | ||
Test that if a partial snapshot errors it will work after and not lose data | ||
""" | ||
uvm = microvm_factory.build( | ||
guest_kernel_linux_5_10, | ||
rootfs_ubuntu_22, | ||
jailer_kwargs={"chroot_base": mount_tmpfs_small}, | ||
) | ||
|
||
vm_mem_size = 128 | ||
uvm.spawn() | ||
uvm.basic_config(mem_size_mib=vm_mem_size, track_dirty_pages=True) | ||
uvm.add_net_iface() | ||
uvm.start() | ||
uvm.wait_for_up() | ||
|
||
chroot = Path(uvm.chroot()) | ||
|
||
# Create a large file, so we run out of space (ENOSPC) during the snapshot | ||
# Assumes a Docker /srv tmpfs of 1G, derived by trial and error | ||
fill = chroot / "fill" | ||
subprocess.check_call(f"fallocate -l 330M {fill}", shell=True) | ||
|
||
try: | ||
uvm.snapshot_diff() | ||
except RuntimeError: | ||
msg = "No space left on device" | ||
uvm.check_log_message(msg) | ||
else: | ||
assert False, "This should fail" | ||
|
||
fill.unlink() | ||
|
||
# Now there is enough space for it to work | ||
snap2 = uvm.snapshot_diff() | ||
|
||
vm2 = microvm_factory.build() | ||
vm2.spawn() | ||
vm2.restore_from_snapshot(snap2, resume=True) | ||
vm2.wait_for_up() | ||
|
||
uvm.kill() |