From 0a8f7588364cd04c37e202a83e0e6a4cd7f00160 Mon Sep 17 00:00:00 2001 From: Xudong Hao Date: Tue, 18 Jun 2024 13:12:52 +0800 Subject: [PATCH] Add 3 TDX cases by booting TD several times td_boot_multimes.one_socket.one_cpu td_boot_multimes.one_socket.four_cpu td_boot_multimes.two_socket.four_cpu Signed-off-by: Xudong Hao --- KVM/qemu/td_boot_multimes.cfg | 24 ++++++++++++++++++ KVM/qemu/tests/td_boot_multimes.py | 40 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 KVM/qemu/td_boot_multimes.cfg create mode 100644 KVM/qemu/tests/td_boot_multimes.py diff --git a/KVM/qemu/td_boot_multimes.cfg b/KVM/qemu/td_boot_multimes.cfg new file mode 100644 index 00000000..be68dfca --- /dev/null +++ b/KVM/qemu/td_boot_multimes.cfg @@ -0,0 +1,24 @@ +- td_boot_multimes: + virt_test_type = qemu + type = td_boot_multimes + vm_accelerator = kvm + machine_type_extra_params = "kernel-irqchip=split" + vm_secure_guest_type = tdx + start_vm = no + vga = std + auto_cpu_model = "no" + cpu_model = host + iterations = 10 + variants: + - one_cpu: + smp = 1 + vcpu_maxcpus = 1 + - four_cpu: + smp = 4 + vcpu_maxcpus = 4 + variants: + - one_socket: + vcpu_sockets = 1 + - two_socket: + vcpu_sockets = 2 + no one_cpu diff --git a/KVM/qemu/tests/td_boot_multimes.py b/KVM/qemu/tests/td_boot_multimes.py new file mode 100644 index 00000000..3e6d5bae --- /dev/null +++ b/KVM/qemu/tests/td_boot_multimes.py @@ -0,0 +1,40 @@ +#!/usr/bin/python3 + +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (c) 2024 Intel Corporation + +# Author: Xudong Hao +# +# History: Jun. 2024 - Xudong Hao - creation +from virttest import env_process +from virttest import error_context + + +# This decorator makes the test function aware of context strings +@error_context.context_aware +def run(test, params, env): + """ + Boot TD by multiple times: + 1) Boot up one TDVM + 2) Shutdown TDVM + 3) repeat step1 and step2 multiple times + + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment + """ + + params["start_vm"] = 'yes' + timeout = params.get_numeric("login_timeout", 240) + iterations = params.get_numeric("iterations") + for i in range(iterations): + error_context.context("The iteration %s of booting TDVM" % i, test.log.info) + vm_name = params['main_vm'] + try: + env_process.preprocess_vm(test, params, env, vm_name) + except: + raise + vm = env.get_vm(vm_name) + vm.verify_alive() + session = vm.wait_for_login(timeout=timeout) + vm.destroy()