forked from autotest/tp-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request autotest#5037 from meinaLi/useserial
guest_os_booting: add new case for useserial attribute
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
libvirt/tests/cfg/guest_os_booting/useserial/useserial.cfg
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,17 @@ | ||
- guest_os_booting.useserial: | ||
type = useserial | ||
start_vm = no | ||
useserial_dict = {'bios_useserial': '%s', 'bios_reboot_timeout': '0', 'bootmenu_enable': 'yes', 'bootmenu_timeout': '3000'} | ||
variants: | ||
- enable_useserial: | ||
enable_useserial = "yes" | ||
useserial = "yes" | ||
- disable_useserial: | ||
useserial = "no" | ||
variants: | ||
- by_ovmf: | ||
only q35 | ||
firmware_type = "ovmf" | ||
- by_seabios: | ||
firmware_type = "seabios" | ||
check_prompt = "Press ESC for boot menu" |
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,58 @@ | ||
# | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# | ||
# Copyright Red Hat | ||
# | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
# Author: Meina Li <[email protected]> | ||
# | ||
import time | ||
|
||
from virttest import virsh | ||
from virttest.libvirt_xml import vm_xml | ||
|
||
from provider.guest_os_booting import guest_os_booting_base as guest_os | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
This case is to verify the use-serial elements. | ||
1) Prepare a guest with bios use-serial attribute. | ||
2) Start the guest and pause it directly. | ||
3) Open the console. | ||
4) Resume the guest. | ||
5) Check the result in console. | ||
""" | ||
vm_name = guest_os.get_vm(params) | ||
useserial = params.get("useserial") | ||
useserial_dict = eval(params.get("useserial_dict") % useserial) | ||
enable_useserial = "yes" == params.get("enable_useserial", "no") | ||
check_prompt = params.get("check_prompt") | ||
firmware_type = params.get("firmware_type") | ||
|
||
vm = env.get_vm(vm_name) | ||
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) | ||
bkxml = vmxml.copy() | ||
|
||
try: | ||
guest_os.prepare_os_xml(vm_name, useserial_dict) | ||
if firmware_type == "seabios" and enable_useserial: | ||
virsh.start(vm_name, "--paused", debug=True, ignore_status=False) | ||
vm.create_serial_console() | ||
time.sleep(1) | ||
vm.resume() | ||
match, text = vm.serial_console.read_until_any_line_matches([check_prompt], | ||
timeout=30, | ||
internal_timeout=0.5) | ||
if match == -1: | ||
test.log.info("Get check point as expected") | ||
else: | ||
test.fail("Can't get matched prompts!") | ||
vm.wait_for_login().close() | ||
else: | ||
guest_os.check_vm_startup(vm, vm_name) | ||
finally: | ||
if vm.is_alive(): | ||
virsh.destroy(vm_name) | ||
bkxml.sync() |