Skip to content

Commit ea28a13

Browse files
committed
ci: add a test that ensures that KVM_CLOCK_CTRL works
Launch a script in the guest that continuously calls `ls -R /` and on the host side, continuously pause and resume the microVM trying to cause an RCU soft lockup. Signed-off-by: Babis Chalios <bchalios@amazon.es>
1 parent 800ec4c commit ea28a13

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/integration_tests/functional/test_pause_resume.py

+33
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""Basic tests scenarios for snapshot save/restore."""
44

55
import pytest
6+
import time
67

78

89
def verify_net_emulation_paused(metrics):
@@ -127,3 +128,35 @@ def test_pause_resume_preboot(uvm_nano):
127128
# Try to resume microvm when not running, it must fail.
128129
with pytest.raises(RuntimeError, match=expected_err):
129130
basevm.api.vm.patch(state="Resumed")
131+
132+
133+
def test_kvmclock_ctrl(uvm_plain_any):
134+
"""
135+
Test that pausing vCPUs does not trigger a soft lock-up
136+
"""
137+
138+
microvm = uvm_plain_any
139+
microvm.help.enable_console()
140+
microvm.spawn()
141+
microvm.basic_config()
142+
microvm.add_net_iface()
143+
microvm.start()
144+
145+
# Launch reproducer in host
146+
# This launches `ls -R /` in a loop inside the guest. The command writes its output in the
147+
# console. This detail is important as it writing in the console seems to increase the probability
148+
# that we will pause the execution inside the kernel and cause a lock up. Setting KVM_CLOCK_CTRL
149+
# bit that informs the guest we're pausing the vCPUs, should avoid that lock up.
150+
microvm.ssh.check_output(
151+
"sh -c 'while true; do ls -R /; done' > /dev/ttyS0 2>&1 < /dev/null &"
152+
)
153+
154+
for _ in range(12):
155+
microvm.api.vm.patch(state="Paused")
156+
time.sleep(5)
157+
microvm.api.vm.patch(state="Resumed")
158+
159+
dmesg = microvm.ssh.check_output("dmesg").stdout
160+
assert "rcu_sched self-detected stall on CPU" not in dmesg
161+
assert "rcu_preempt detected stalls on CPUs/tasks" not in dmesg
162+
assert "BUG: soft lockup -" not in dmesg

0 commit comments

Comments
 (0)