From 07fd3bbf7c48806789b5e90a857fe48e926fa18a Mon Sep 17 00:00:00 2001 From: Xudong Hao Date: Wed, 19 Jun 2024 10:53:10 +0800 Subject: [PATCH] Add TDX huge resource test case Allocate half of online CPUs to TDVM, half of availiable memory resource to TDVM, check if TD can boot up. Signed-off-by: Xudong Hao --- KVM/qemu/td_huge_resource.cfg | 10 +++++++ KVM/qemu/tests/td_huge_resource.py | 47 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 KVM/qemu/td_huge_resource.cfg create mode 100644 KVM/qemu/tests/td_huge_resource.py diff --git a/KVM/qemu/td_huge_resource.cfg b/KVM/qemu/td_huge_resource.cfg new file mode 100644 index 0000000..7d73842 --- /dev/null +++ b/KVM/qemu/td_huge_resource.cfg @@ -0,0 +1,10 @@ +- td_huge_resource: + virt_test_type = qemu + type = td_huge_resource + 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 diff --git a/KVM/qemu/tests/td_huge_resource.py b/KVM/qemu/tests/td_huge_resource.py new file mode 100644 index 0000000..d6791b9 --- /dev/null +++ b/KVM/qemu/tests/td_huge_resource.py @@ -0,0 +1,47 @@ +#!/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 avocado.utils import cpu + +from virttest import env_process +from virttest import error_context +from virttest import utils_misc + + +# This decorator makes the test function aware of context strings +@error_context.context_aware +def run(test, params, env): + """ + Boot TD with huge CPU and memory: + 1) Caculate the host online CPU number and usable memory size + 2) Boot up one TDVM with half resource of host + 3) Shutdown TDVM + + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment + """ + + timeout = params.get_numeric("login_timeout", 240) + params["start_vm"] = 'yes' + host_cpu = cpu.online_count() + host_free_mem = utils_misc.get_usable_memory_size() + params['smp'] = params['vcpu_maxcpus'] = host_cpu//2 + params['mem'] = host_free_mem//2 + + error_context.context("Booting TDVM with large CPU and memory", 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() + session.close()