Skip to content

Commit 2256920

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 <[email protected]>
1 parent 0b9cf39 commit 2256920

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/integration_tests/functional/test_pause_resume.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# SPDX-License-Identifier: Apache-2.0
33
"""Basic tests scenarios for snapshot save/restore."""
44

5+
import platform
6+
import time
7+
58
import pytest
69

710

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

0 commit comments

Comments
 (0)