diff --git a/lib/constants.py b/lib/constants.py index 058f2dd62e7daef392d4424d4a3899127ad41f3e..6b3af5c5f2b003e1921473968c736cb24d998473 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -488,6 +488,7 @@ HVC_DEFAULTS = { HV_VNC_BIND_ADDRESS: '0.0.0.0', HV_ACPI: True, HV_PAE: True, + HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader", }, HT_KVM: { HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU", diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 959958deb9cdedb5e810770ef0ee9263c015ef99..683635573e620bae5f167d785e5277dd03000f68 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -518,6 +518,7 @@ class XenHvmHypervisor(XenHypervisor): constants.HV_NIC_TYPE, constants.HV_PAE, constants.HV_VNC_BIND_ADDRESS, + constants.HV_KERNEL_PATH, ] @classmethod @@ -559,6 +560,12 @@ class XenHvmHypervisor(XenHypervisor): " be an absolute path or None, not %s" % iso_path) + 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" % iso_path) + 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) + @classmethod 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])