-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
guest os booting: add new modular case for direct kernel boot
This PR mainly automate the function of direct kernel boot feature in os element. Signed-off-by: Meina Li <[email protected]>
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
libvirt/tests/cfg/guest_os_booting/direct_kernel_boot/direct_kernel_boot.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,12 @@ | ||
- guest_os_booting.direct_kernel_boot: | ||
type = direct_kernel_boot | ||
start_vm = no | ||
memory_value = 3573760 | ||
#repo_url = "EXAMPLE_REPO_URL" | ||
repo_url = "http://download.eng.pek2.redhat.com/rhel-9/nightly/RHEL-9/latest-RHEL-9.3.0/compose/BaseOS/x86_64/os" | ||
initrd_url = "${repo_url}/images/pxeboot/initrd.img" | ||
vmlinuz_url = "${repo_url}/images/pxeboot/vmlinuz" | ||
direct_kernel_dict = {'cmdline': 'console=ttyS0 inst.repo=${repo_url}', 'initrd': '%s', 'kernel': '%s'} | ||
variants: | ||
- start_guest: | ||
check_prompt = "Starting installer" |
54 changes: 54 additions & 0 deletions
54
libvirt/tests/src/guest_os_booting/direct_kernel_boot/direct_kernel_boot.py
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,54 @@ | ||
# | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# | ||
# Copyright Red Hat | ||
# | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
# Author: Meina Li <[email protected]> | ||
# | ||
import os | ||
|
||
from virttest import data_dir | ||
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 direct kernel boot. | ||
1) Prepare a guest with direct kernel boot. | ||
2) Start the guest. | ||
3) Save and restore the guest. | ||
""" | ||
vm_name = params.get("main_vm") | ||
memory_value = int(params.get("memory_value", "2097152")) | ||
initrd_url = params.get("initrd_url") | ||
vmlinuz_url = params.get("vmlinuz_url") | ||
check_prompt = params.get("check_prompt") | ||
|
||
vm = env.get_vm(vm_name) | ||
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) | ||
bkxml = vmxml.copy() | ||
|
||
try: | ||
boot_initrd = os.path.join(data_dir.get_data_dir(), "initrd.img") | ||
boot_vmlinuz = os.path.join(data_dir.get_data_dir(), "vmlinuz") | ||
guest_os.download_file(initrd_url, boot_initrd, test) | ||
guest_os.download_file(vmlinuz_url, boot_vmlinuz, test) | ||
direct_kernel_dict = eval(params.get("direct_kernel_dict", "{}") | ||
% (boot_initrd, boot_vmlinuz)) | ||
vmxml = guest_os.prepare_os_xml(vm_name, direct_kernel_dict) | ||
vmxml.set_memory(memory_value) | ||
vmxml.set_current_mem(memory_value) | ||
vmxml.sync() | ||
test.log.info("The final guest xml is %s", vmxml) | ||
if not vm.is_alive(): | ||
vm.start() | ||
vm.serial_console.read_until_any_line_matches([check_prompt], timeout=360) | ||
finally: | ||
bkxml.sync() | ||
for file_path in [boot_initrd, boot_vmlinuz]: | ||
if os.path.exists(file_path): | ||
os.remove(file_path) |
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