|
| 1 | +# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | +"""Test swiotlb related functionality.""" |
| 4 | + |
| 5 | +import pytest |
| 6 | + |
| 7 | +from framework.properties import global_props |
| 8 | + |
| 9 | +pytestmark = pytest.mark.skipif( |
| 10 | + global_props.cpu_architecture != "aarch64", reason="swiotlb only supported on ARM" |
| 11 | +) |
| 12 | + |
| 13 | + |
| 14 | +def test_swiotlb_boot(microvm_factory, guest_kernel_linux_6_1, rootfs): |
| 15 | + """Tests that a VM can boot if all virtio devices are bound to a swiotlb region, and |
| 16 | + that this swiotlb region is actually discovered by the guest.""" |
| 17 | + vm = microvm_factory.build(guest_kernel_linux_6_1, rootfs) |
| 18 | + vm.spawn() |
| 19 | + vm.basic_config(memory_config={"initial_swiotlb_size": 64}) |
| 20 | + vm.add_net_iface() |
| 21 | + vm.start() |
| 22 | + |
| 23 | + _, dmesg, _ = vm.ssh.check_output("dmesg") |
| 24 | + |
| 25 | + assert ( |
| 26 | + "OF: reserved mem: initialized node bouncy_boi, compatible id restricted-dma-pool" |
| 27 | + in dmesg |
| 28 | + ) |
| 29 | + |
| 30 | + |
| 31 | +def test_swiotlb_snapshot(microvm_factory, guest_kernel_linux_6_1, rootfs): |
| 32 | + """Tests that a VM with swiotlb regions attached can be snapshotted and restored |
| 33 | + again, and that the restored VM can still do I/O.""" |
| 34 | + vm = microvm_factory.build(guest_kernel_linux_6_1, rootfs) |
| 35 | + vm.spawn() |
| 36 | + vm.basic_config(memory_config={"initial_swiotlb_size": 64}) |
| 37 | + vm.add_net_iface() |
| 38 | + vm.start() |
| 39 | + snapshot = vm.snapshot_full() |
| 40 | + vm.kill() |
| 41 | + |
| 42 | + vm = microvm_factory.build_from_snapshot(snapshot) |
| 43 | + |
| 44 | + vm.ssh.check_output("true") |
0 commit comments