Skip to content

Commit 59b61af

Browse files
committed
KVM: Add tdx_cpuoff_pinedVMdown case
1 parent ba7d3f7 commit 59b61af

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
- tdx_cpuoff_pinedVMdown:
2+
type = tdx_cpuoff_pinedVMdown
3+
virt_test_type = qemu
4+
machine_type_extra_params = "kernel-irqchip=split"
5+
vm_secure_guest_type = tdx
6+
# Don't create/remove guest images
7+
start_vm = no
8+
# Stop VM after testing
9+
kill_vm = yes
10+
auto_cpu_model = "no"
11+
cpu_model = host
12+
guest_flags = "tdx_guest"
13+
hkid = "hkid"
14+
tdx_crash_flag = "0x8000070100000000"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/python3
2+
3+
# SPDX-License-Identifier: GPL-2.0-only
4+
# Copyright (c) 2026 Intel Corporation
5+
6+
# Author: Kai Zhang <kai.zhang@intel.com>
7+
#
8+
# History: Apr. 2026 - Kai Zhang - creation
9+
10+
import re
11+
import time
12+
13+
from provider import dmesg_router # pylint: disable=unused-import
14+
from avocado.utils import process
15+
from virttest import error_context, env_process
16+
from provider.cpu_utils import check_cpu_flags
17+
18+
19+
@error_context.context_aware
20+
def run(test, params, env):
21+
"""
22+
TDX CPU off pinned VM down test:
23+
1. Boot TDVM
24+
2. Pin a TD VM to a cpu, poweroff the cpu and shutdown the TD VM
25+
26+
:param test: QEMU test object
27+
:param params: Dictionary with the test parameters
28+
:param env: Dictionary with test environment.
29+
"""
30+
31+
for i in range(0, 20):
32+
params["smp"] = 64
33+
params["start_vm"] = "yes"
34+
env_process.preprocess_vm(test, params, env, params["main_vm"])
35+
vm = env.get_vm(params["main_vm"])
36+
vm.verify_alive()
37+
timeout = params.get_numeric("login_timeout", 240)
38+
session = vm.wait_for_login(timeout=timeout)
39+
flags = params["guest_flags"]
40+
check_cpu_flags(params, flags, test, session)
41+
pid = process.getoutput("ps -edf | grep qemu | grep -E 'avocado-vt-vm.*' | grep -v grep | awk '{print $2}'")
42+
process.system(f"taskset -pc 18 {pid}", ignore_status=True)
43+
process.system("echo 0 > /sys/devices/system/cpu/cpu18/online")
44+
session.cmd("init 0 &", ignore_all_errors=True)
45+
time.sleep(3)
46+
47+
hkid = params["hkid"]
48+
tdx_crash_flag = params["tdx_crash_flag"]
49+
dmesg = process.system_output("dmesg")
50+
hkid_str = re.findall(r'%s' % hkid, dmesg.decode('utf-8'))
51+
crash_str = re.findall(r'%s' % tdx_crash_flag, dmesg.decode('utf-8'))
52+
seamcall_failed_pattern = re.compile(r'^.*SEAMCALL.*failed.*$', re.MULTILINE)
53+
seamcall_failed_match = seamcall_failed_pattern.search(dmesg.decode('utf-8'))
54+
if hkid_str or crash_str or seamcall_failed_match:
55+
test.fail(f"Detected the crash information in {i} time run. Fail!")
56+
process.system("echo 1 > /sys/devices/system/cpu/cpu18/online")
57+
session.close()

0 commit comments

Comments
 (0)