Skip to content

Commit 1348fe9

Browse files
committed
test: Check all vCPUs are oneline
As seen in firecracker-microvm#4925, a bad CPU template made secondary CPUs not come up. To catch similar bugs of CPU templates, check all the vCPUs are online from guests' perspective. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent 4d2467c commit 1348fe9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/framework/microvm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ def make_snapshot(
937937
ssh_key=self.ssh_key,
938938
snapshot_type=snapshot_type,
939939
meta={
940+
"vcpus_count": self.vcpus_count,
940941
"kernel_file": self.kernel_file,
941942
},
942943
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""
5+
Test all vCPUs are configured correctly and work properly.
6+
7+
This test suite aims to catch bugs of Firecracker's vCPU configuration and
8+
CPU templates especially under multi-vCPU setup, by checking that all vCPUs
9+
are operating identically, except for the expected differences.
10+
"""
11+
12+
13+
def test_all_vcpus_online(uvm_any):
14+
"""Check all vCPUs are online inside guest"""
15+
vm = uvm_any
16+
for idx in range(vm.vcpus_count):
17+
assert (
18+
vm.ssh.check_output(f"cat /sys/devices/system/cpu/cpu{idx}/online").stdout.strip()
19+
== "1"
20+
)

0 commit comments

Comments
 (0)