diff --git a/KVM/qemu/td_disable_ept.cfg b/KVM/qemu/td_disable_ept.cfg new file mode 100644 index 00000000..a1e91f3a --- /dev/null +++ b/KVM/qemu/td_disable_ept.cfg @@ -0,0 +1,17 @@ +- td_disable_ept: + virt_test_type = qemu + type = td_disable_ept + 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 + xfail = "yes" + expected_status = 'N' + default_status = 'Y' + parameter_name = 'ept' + pre_command = 'modprobe -r kvm_intel && modprobe kvm_intel ${parameter_name}=${expected_status}' + post_command = 'modprobe -r kvm_intel && modprobe kvm_intel ${parameter_name}=${default_status}' + check_status_cmd = 'cat /sys/module/kvm_intel/parameters/${parameter_name}' diff --git a/KVM/qemu/tests/td_disable_ept.py b/KVM/qemu/tests/td_disable_ept.py new file mode 100644 index 00000000..6cc5cb24 --- /dev/null +++ b/KVM/qemu/tests/td_disable_ept.py @@ -0,0 +1,43 @@ +#!/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 process + +from virttest import env_process + + +def run(test, params, env): + """ + Boot TD after disable ept: + 1) Disable ept + 2) Boot up TDVM + 3) TDVM can not be lanuch as expect + + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment + """ + xfail = False + if (params.get("xfail") is not None) and (params.get("xfail") == "yes"): + xfail = True + + output = process.getoutput(params["check_status_cmd"]) + if output != params["expected_status"]: + test.fail("Disable %s failed" % params["parameter_name"]) + + params["start_vm"] = 'yes' + has_error = False + try: + env_process.preprocess_vm(test, params, env, params["main_vm"]) + except: + has_error = True + if xfail is False: + raise + + if (has_error is False) and (xfail is True): + test.fail("Test was expected to fail, but it didn't")