Commit 2f2dbb4b authored by Jun Futagawa's avatar Jun Futagawa Committed by Michael Hanselmann

Add support for using the bootloader in xen-pvm

This patch adds three optional parameters:
  - 'use_bootloader', whether use or not the bootloader
  - 'bootloader_path', absolute path to the bootloader
  - 'bootloader_args', extra arguments to the bootloader

Syntax:
  gnt-cluster modify --hypervisor-parameters \
    xen-pvm:bootloader_path=/usr/bin/pygrub,use_bootloader=False
  gnt-instance modify -H use_bootloader=True instance1.example.com

If use_bootloader is True, each domU can boot with its own kernel
instead of using the dom0 kernel.
Signed-off-by: default avatarJun Futagawa <jfut@integ.jp>
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: ultortter
parent 11c684bf
......@@ -377,6 +377,7 @@ lib/_autoconf.py: Makefile stamp-directories
echo "SSH_INITD_SCRIPT = '$(SSH_INITD_SCRIPT)'"; \
echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
echo "XEN_INITRD = '$(XEN_INITRD)'"; \
echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
......@@ -397,6 +398,7 @@ $(REPLACE_VARS_SED): Makefile stamp-directories
echo 's#@BINDIR@#$(bindir)#g'; \
echo 's#@SBINDIR@#$(sbindir)#g'; \
echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
......
......@@ -61,6 +61,15 @@ AC_ARG_WITH([iallocator-search-path],
[iallocator_search_path="'$libdir/$PACKAGE_NAME/iallocators'"])
AC_SUBST(IALLOCATOR_SEARCH_PATH, $iallocator_search_path)
# --with-xen-bootloader=...
AC_ARG_WITH([xen-bootloader],
[AS_HELP_STRING([--with-xen-bootloader=PATH],
[bootloader for Xen hypervisor (default is empty)]
)],
[xen_bootloader="$withval"],
[xen_bootloader=])
AC_SUBST(XEN_BOOTLOADER, $xen_bootloader)
# --with-xen-kernel=...
AC_ARG_WITH([xen-kernel],
[AS_HELP_STRING([--with-xen-kernel=PATH],
......
......@@ -159,6 +159,7 @@ EXPORT_DIR = _autoconf.EXPORT_DIR
EXPORT_CONF_FILE = "config.ini"
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
XEN_KERNEL = _autoconf.XEN_KERNEL
XEN_INITRD = _autoconf.XEN_INITRD
......@@ -368,6 +369,9 @@ HV_VNC_X509 = "vnc_x509_path"
HV_VNC_X509_VERIFY = "vnc_x509_verify"
HV_ACPI = "acpi"
HV_PAE = "pae"
HV_USE_BOOTLOADER = "use_bootloader"
HV_BOOTLOADER_ARGS = "bootloader_args"
HV_BOOTLOADER_PATH = "bootloader_path"
HV_KERNEL_ARGS = "kernel_args"
HV_KERNEL_PATH = "kernel_path"
HV_INITRD_PATH = "initrd_path"
......@@ -388,6 +392,9 @@ HVS_PARAMETER_TYPES = {
HV_VNC_X509_VERIFY: VTYPE_BOOL,
HV_ACPI: VTYPE_BOOL,
HV_PAE: VTYPE_BOOL,
HV_USE_BOOTLOADER: VTYPE_BOOL,
HV_BOOTLOADER_PATH: VTYPE_STRING,
HV_BOOTLOADER_ARGS: VTYPE_STRING,
HV_KERNEL_PATH: VTYPE_STRING,
HV_KERNEL_ARGS: VTYPE_STRING,
HV_INITRD_PATH: VTYPE_STRING,
......@@ -580,6 +587,9 @@ DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
HVC_DEFAULTS = {
HT_XEN_PVM: {
HV_USE_BOOTLOADER: False,
HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
HV_BOOTLOADER_ARGS: '',
HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
HV_INITRD_PATH: '',
HV_ROOT_PATH: '/dev/sda1',
......
......@@ -424,6 +424,9 @@ class XenPvmHypervisor(XenHypervisor):
"""Xen PVM hypervisor interface"""
PARAMETERS = {
constants.HV_USE_BOOTLOADER: hv_base.NO_CHECK,
constants.HV_BOOTLOADER_PATH: hv_base.OPT_FILE_CHECK,
constants.HV_BOOTLOADER_ARGS: hv_base.NO_CHECK,
constants.HV_KERNEL_PATH: hv_base.REQ_FILE_CHECK,
constants.HV_INITRD_PATH: hv_base.OPT_FILE_CHECK,
constants.HV_ROOT_PATH: hv_base.REQUIRED_CHECK,
......@@ -439,14 +442,29 @@ class XenPvmHypervisor(XenHypervisor):
config = StringIO()
config.write("# this is autogenerated by Ganeti, please do not edit\n#\n")
# kernel handling
kpath = hvp[constants.HV_KERNEL_PATH]
config.write("kernel = '%s'\n" % kpath)
# if bootloader is True, use bootloader instead of kernel and ramdisk
# parameters.
if hvp[constants.HV_USE_BOOTLOADER]:
# bootloader handling
bootloader_path = hvp[constants.HV_BOOTLOADER_PATH]
if bootloader_path:
config.write("bootloader = '%s'\n" % bootloader_path)
else:
raise errors.HypervisorError("Bootloader enabled, but missing"
" bootloader path")
# initrd handling
initrd_path = hvp[constants.HV_INITRD_PATH]
if initrd_path:
config.write("ramdisk = '%s'\n" % initrd_path)
bootloader_args = hvp[constants.HV_BOOTLOADER_ARGS]
if bootloader_args:
config.write("bootargs = '%s'\n" % bootloader_args)
else:
# kernel handling
kpath = hvp[constants.HV_KERNEL_PATH]
config.write("kernel = '%s'\n" % kpath)
# initrd handling
initrd_path = hvp[constants.HV_INITRD_PATH]
if initrd_path:
config.write("ramdisk = '%s'\n" % initrd_path)
# rest of the settings
config.write("memory = %d\n" % instance.beparams[constants.BE_MEMORY])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment