-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 5bf4f93
Showing
3 changed files
with
101 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
67 changes: 67 additions & 0 deletions
67
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,67 @@ | ||
# Copyright 2020 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 pytest | ||
import subprocess | ||
from pathlib import Path | ||
|
||
|
||
@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 | ||
): | ||
""" | ||
""" | ||
|
||
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.ssh.run("true") | ||
|
||
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.ssh.run("true") | ||
|
||
uvm.kill() |