Skip to content

Commit 09d46e3

Browse files
author
Satheesh Rajendran
committed
Added virt-install kernel and initrd params support
Added support for using custom kernel, initrd and kernel args params to virt-install command line This will help us booting VM with custom complied kernel
1 parent 6ac5bea commit 09d46e3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

virttest/libvirt_vm.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,33 @@ def add_memballoon(help_text, memballoon_model):
659659
logging.debug("vm.add_memballoon returning: %s", result)
660660
return result
661661

662+
def add_kernel(help_text, cmdline, kernel_path=None, initrd_path=None,
663+
kernel_args=None):
664+
"""
665+
Adding Custom kernel option to boot.
666+
667+
: param help_text: string, virt-install help text
668+
: param cmdline: string, current virt-install cmdline
669+
: param kernel_path: string, custom kernel path.
670+
: param initrd_path: string, custom initrd path.
671+
: param kernel_args: string, custom boot args.
672+
"""
673+
if has_option(help_text, "boot"):
674+
if "--boot" in cmdline:
675+
result = ","
676+
else:
677+
result = " --boot "
678+
if has_sub_option("boot", "kernel") and kernel_path:
679+
result += "kernel=%s," % kernel_path
680+
if has_sub_option("boot", "initrd") and initrd_path:
681+
result += "initrd=%s," % initrd_path
682+
if has_sub_option("boot", "kernel_args") and kernel_args:
683+
result += "kernel_args=%s," % kernel_args
684+
else:
685+
result = ""
686+
logging.warning("boot option is not supported")
687+
return result.strip(',')
688+
662689
# End of command line option wrappers
663690

664691
if name is None:
@@ -978,6 +1005,13 @@ def add_memballoon(help_text, memballoon_model):
9781005
else:
9791006
virt_install_cmd += " --boot emulator=%s" % emulator_path
9801007

1008+
kernel = params.get("kernel", None)
1009+
initrd = params.get("initrd", None)
1010+
kernel_args = params.get("kernel_args", None)
1011+
if (kernel or initrd) and kernel_args:
1012+
virt_install_cmd += add_kernel(help_text, virt_install_cmd, kernel,
1013+
initrd, kernel_args)
1014+
9811015
# bz still open, not fully functional yet
9821016
if params.get("use_virt_install_wait") == "yes":
9831017
virt_install_cmd += (" --wait %s" %

0 commit comments

Comments
 (0)