|
3 | 3 | """Basic tests scenarios for snapshot save/restore."""
|
4 | 4 |
|
5 | 5 | import pytest
|
| 6 | +import time |
6 | 7 |
|
7 | 8 |
|
8 | 9 | def verify_net_emulation_paused(metrics):
|
@@ -127,3 +128,35 @@ def test_pause_resume_preboot(uvm_nano):
|
127 | 128 | # Try to resume microvm when not running, it must fail.
|
128 | 129 | with pytest.raises(RuntimeError, match=expected_err):
|
129 | 130 | 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