Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TDX huge resource test case #280

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions KVM/qemu/td_huge_resource.cfg
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions KVM/qemu/tests/td_huge_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/python3

# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 Intel Corporation

# Author: Xudong Hao <[email protected]>
#
# 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()
Loading