Skip to content

Commit 9febf6c

Browse files
committed
test: ensure swiotlb works
Add an integration test on ARM that configures an in-guest swiotlb region to which all virtio devices should be bound. Asserts the guest sees the swiotlb region, and also that block and net I/O work (indirectly through loading of rootfs during boot and by running commands via SSH). Also add a test for snapshotting VMs with swiotlb regions, which just checks the network device after restoration to sanity check that the swiotlb region was correctly restored. Signed-off-by: Patrick Roy <[email protected]>
1 parent 6488806 commit 9febf6c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

Comments
 (0)