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