Commit e71b560a authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement the KERNEL_PATH parameter for xen-hvm

For the xen-hvm hypervisor, the KERNEL_PATH parameter is needed but
today is hardcoded to a constants in the xen hypervisor library (argh!).

This patch moves this to a hypervisor constant with the default value
being the current hardcoded path. This will allow cluster/instance
customisation based on the installed xen version.

This should fix Debian bug #528618.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
(cherry picked from commit e2ee1cea)
parent 77b60cdb
......@@ -510,6 +510,7 @@ HVC_DEFAULTS = {
HV_ACPI: True,
HV_PAE: True,
HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
......@@ -518,6 +518,7 @@ class XenHvmHypervisor(XenHypervisor):
......@@ -559,6 +560,12 @@ class XenHvmHypervisor(XenHypervisor):
" be an absolute path or None, not %s" %
if not hvparams[constants.HV_KERNEL_PATH]:
raise errors.HypervisorError("Need a kernel for the instance")
if not os.path.isabs(hvparams[constants.HV_KERNEL_PATH]):
raise errors.HypervisorError("The kernel path must be an absolute path")
def ValidateParameters(self, hvparams):
"""Check the given parameters for validity.
......@@ -580,6 +587,11 @@ class XenHvmHypervisor(XenHypervisor):
" an existing regular file, not %s" %
kernel_path = hvparams[constants.HV_KERNEL_PATH]
if not os.path.isfile(kernel_path):
raise errors.HypervisorError("Instance kernel '%s' not found or"
" not a file" % kernel_path)
def _WriteConfigFile(cls, instance, block_devices):
"""Create a Xen 3.1 HVM config file.
......@@ -589,7 +601,11 @@ class XenHvmHypervisor(XenHypervisor):
config = StringIO()
config.write("# this is autogenerated by Ganeti, please do not edit\n#\n")
config.write("kernel = '/usr/lib/xen/boot/hvmloader'\n")
# kernel handling
kpath = hvp[constants.HV_KERNEL_PATH]
config.write("kernel = '%s'\n" % kpath)
config.write("builder = 'hvm'\n")
config.write("memory = %d\n" % instance.beparams[constants.BE_MEMORY])
config.write("vcpus = %d\n" % instance.beparams[constants.BE_VCPUS])
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