-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
snp_multi_vm: Add multi vms SNP tests
Boot multi vms with different cpu and memory resources Signed-off-by: Zixi Chen <zixchen@redhat.com>
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
- snp_multi_vm: | ||
type = snp_multi_vm | ||
kill_vm = yes | ||
login_timeout = 240 | ||
image_snapshot = yes | ||
vm_secure_guest_type = snp | ||
vm_sev_reduced_phys_bits = 1 | ||
vm_sev_cbitpos = 51 | ||
virtio_dev_disable_legacy = on | ||
bios_path = /usr/share/edk2/ovmf/OVMF.amdsev.fd | ||
snp_module_path = "/sys/module/kvm_amd/parameters/sev_snp" | ||
module_status = Y y 1 | ||
snp_guest_check = "journalctl|grep -i -w snp" | ||
guest_tool_install = "dnf install -y snpguest" | ||
attestation_script = regular_attestation_workflow.sh | ||
guest_dir = /home | ||
guest_cmd = ${guest_dir}/${attestation_script} | ||
host_script = sev-snp/${attestation_script} | ||
variants: | ||
- single_vcpu: | ||
vms += " vm2" | ||
smp_vm2 = 1 | ||
mem_vm2 = 4096 | ||
- four_vms: | ||
vms += " vm2 vm3 vm4" | ||
smp = 8 | ||
mem = 10240 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import os | ||
|
||
from virttest import data_dir as virttest_data_dir | ||
from virttest import error_context | ||
from virttest.utils_misc import verify_dmesg | ||
|
||
|
||
@error_context.context_aware | ||
def run(test, params, env): | ||
""" | ||
Qemu snp basic test on Milan and above host: | ||
1. Check host snp capability | ||
2. Boot snp VM | ||
3. Verify snp enabled in guest | ||
4. Check snp qmp cmd and policy | ||
:param test: QEMU test object | ||
:param params: Dictionary with the test parameters | ||
:param env: Dictionary with test environment. | ||
""" | ||
|
||
error_context.context("Start sev-snp test", test.log.info) | ||
timeout = params.get_numeric("login_timeout", 240) | ||
|
||
snp_module_path = params["snp_module_path"] | ||
if os.path.exists(snp_module_path): | ||
f = open(snp_module_path, "r") | ||
output = f.read().strip() | ||
f.close() | ||
if output not in params.objects("module_status"): | ||
test.cancel("Host sev-snp support check fail.") | ||
else: | ||
test.cancel("Host sev-snp support check fail.") | ||
|
||
vms = params.objects("vms") | ||
for vm_name in vms: | ||
vm = env.get_vm(vm_name) | ||
vm.verify_alive() | ||
session = vm.wait_for_login(timeout=timeout) | ||
verify_dmesg() | ||
guest_check_cmd = params["snp_guest_check"] | ||
try: | ||
session.cmd_output(guest_check_cmd, timeout=240) | ||
except Exception as e: | ||
test.fail("Guest snp verify fail: %s" % str(e)) | ||
else: | ||
# Verify attestation | ||
error_context.context("Start to do attestation", test.log.info) | ||
guest_dir = params["guest_dir"] | ||
host_script = params["host_script"] | ||
guest_cmd = params["guest_cmd"] | ||
deps_dir = virttest_data_dir.get_deps_dir() | ||
host_file = os.path.join(deps_dir, host_script) | ||
try: | ||
vm.copy_files_to(host_file, guest_dir) | ||
session.cmd_output(params["guest_tool_install"], timeout=240) | ||
session.cmd_output("chmod 755 %s" % guest_cmd) | ||
except Exception as e: | ||
test.fail("Guest test preperation fail: %s" % str(e)) | ||
status, output = session.cmd_status_output(guest_cmd, timeout=360) | ||
if status: | ||
test.fail("Guest script error") | ||
finally: | ||
session.close() | ||
vm.destroy() |