Skip to content
Permalink
Browse files

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
  • Loading branch information...
sathnaga committed Dec 21, 2016
1 parent 6ac5bea commit 09d46e331ae20b96dc882330fbb82ef6536af98e
Showing with 34 additions and 0 deletions.
  1. +34 −0 virttest/libvirt_vm.py
@@ -659,6 +659,33 @@ def add_memballoon(help_text, memballoon_model):
logging.debug("vm.add_memballoon returning: %s", result)
return result

def add_kernel(help_text, cmdline, kernel_path=None, initrd_path=None,
kernel_args=None):
"""
Adding Custom kernel option to boot.
: param help_text: string, virt-install help text
: param cmdline: string, current virt-install cmdline
: param kernel_path: string, custom kernel path.
: param initrd_path: string, custom initrd path.
: param kernel_args: string, custom boot args.
"""
if has_option(help_text, "boot"):
if "--boot" in cmdline:
result = ","
else:
result = " --boot "
if has_sub_option("boot", "kernel") and kernel_path:
result += "kernel=%s," % kernel_path
if has_sub_option("boot", "initrd") and initrd_path:
result += "initrd=%s," % initrd_path
if has_sub_option("boot", "kernel_args") and kernel_args:
result += "kernel_args=%s," % kernel_args
else:
result = ""
logging.warning("boot option is not supported")
return result.strip(',')

# End of command line option wrappers

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

kernel = params.get("kernel", None)
initrd = params.get("initrd", None)
kernel_args = params.get("kernel_args", None)
if (kernel or initrd) and kernel_args:
virt_install_cmd += add_kernel(help_text, virt_install_cmd, kernel,
initrd, kernel_args)

# bz still open, not fully functional yet
if params.get("use_virt_install_wait") == "yes":
virt_install_cmd += (" --wait %s" %

0 comments on commit 09d46e3

Please sign in to comment.
You can’t perform that action at this time.