Skip to content

Commit

Permalink
Add 4 cases of multiple VMs boot
Browse files Browse the repository at this point in the history
1. 1 TDVM and 1 VM co-exist
2. 2 TDVM
3. 2 VM
4. 4 VM

Signed-off-by: Xudong Hao <[email protected]>
  • Loading branch information
xhao22 committed Jul 4, 2024
1 parent 07ba370 commit c4f27dd
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
20 changes: 20 additions & 0 deletions KVM/qemu/multi_vms.cfg
Original file line number Diff line number Diff line change
@@ -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"
71 changes: 71 additions & 0 deletions KVM/qemu/tests/boot.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit c4f27dd

Please sign in to comment.