diff --git a/KVM/qemu/multi_vms.cfg b/KVM/qemu/multi_vms.cfg new file mode 100644 index 00000000..d63ee0a2 --- /dev/null +++ b/KVM/qemu/multi_vms.cfg @@ -0,0 +1,20 @@ +- multi_vms: + type = boot + virt_test_type = qemu + vm_accelerator = kvm + vms = "vm1 vm2" + image_snapshot = yes + start_vm = yes + vga = std + auto_cpu_model = "no" + cpu_model = host + variants: + - 1td_1vm: + machine_type_extra_params_vm2 = "kernel-irqchip=split" + vm_secure_guest_type_vm2 = tdx + - 2td: + machine_type_extra_params = "kernel-irqchip=split" + vm_secure_guest_type = tdx + - 2vm: + - 4vm: + vms = "vm1 vm2 vm3 vm4" diff --git a/KVM/qemu/tests/boot.py b/KVM/qemu/tests/boot.py new file mode 100644 index 00000000..2cb7537f --- /dev/null +++ b/KVM/qemu/tests/boot.py @@ -0,0 +1,71 @@ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; specifically version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See LICENSE for more details. +# +# Copyright: Red Hat (c) 2024 and Avocado contributors +# Copy from tp-qemu + +import time + +from virttest import error_context +from virttest import utils_test + + +@error_context.context_aware +def run(test, params, env): + """ + Qemu reboot test: + 1) Log into a guest + 3) Send a reboot command or a system_reset monitor command (optional) + 4) Wait until the guest is up again + 5) Log into the guest to verify it's up again + + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + + timeout = float(params.get("login_timeout", 240)) + serial_login = params.get("serial_login", "no") == "yes" + vms = env.get_all_vms() + for vm in vms: + error_context.context("Try to log into guest '%s'." % vm.name, + test.log.info) + if serial_login: + session = vm.wait_for_serial_login(timeout=timeout) + else: + session = vm.wait_for_login(timeout=timeout) + session.close() + + if params.get("rh_perf_envsetup_script"): + for vm in vms: + if serial_login: + session = vm.wait_for_serial_login(timeout=timeout) + else: + session = vm.wait_for_login(timeout=timeout) + utils_test.service_setup(vm, session, test.virtdir) + session.close() + if params.get("reboot_method"): + for vm in vms: + error_context.context("Reboot guest '%s'." % vm.name, + test.log.info) + if params["reboot_method"] == "system_reset": + time.sleep(int(params.get("sleep_before_reset", 10))) + # Reboot the VM + if serial_login: + session = vm.wait_for_serial_login(timeout=timeout) + else: + session = vm.wait_for_login(timeout=timeout) + for i in range(int(params.get("reboot_count", 1))): + session = vm.reboot(session, + params["reboot_method"], + 0, + timeout, + serial_login) + session.close()