diff --git a/lib/constants.py b/lib/constants.py index 6b3af5c5f2b003e1921473968c736cb24d998473..7ab360dadd855885b0641404daac1725f4c0cb4f 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -305,6 +305,7 @@ HV_INITRD_PATH = "initrd_path" HV_ROOT_PATH = "root_path" HV_SERIAL_CONSOLE = "serial_console" HV_USB_MOUSE = "usb_mouse" +HV_DEVICE_MODEL = "device_model" HVS_PARAMETER_TYPES = { HV_BOOT_ORDER: VTYPE_STRING, @@ -323,6 +324,7 @@ HVS_PARAMETER_TYPES = { HV_ROOT_PATH: VTYPE_STRING, HV_SERIAL_CONSOLE: VTYPE_BOOL, HV_USB_MOUSE: VTYPE_STRING, + HV_DEVICE_MODEL: VTYPE_STRING, } HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys()) @@ -489,6 +491,7 @@ HVC_DEFAULTS = { HV_ACPI: True, HV_PAE: True, HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader", + HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm", }, 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 683635573e620bae5f167d785e5277dd03000f68..9d6ae60565258c759337e493bcb5e66e3d19ab61 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -519,6 +519,7 @@ class XenHvmHypervisor(XenHypervisor): constants.HV_PAE, constants.HV_VNC_BIND_ADDRESS, constants.HV_KERNEL_PATH, + constants.HV_DEVICE_MODEL, ] @classmethod @@ -566,6 +567,13 @@ class XenHvmHypervisor(XenHypervisor): if not os.path.isabs(hvparams[constants.HV_KERNEL_PATH]): raise errors.HypervisorError("The kernel path must be an absolute path") + if not hvparams[constants.HV_DEVICE_MODEL]: + raise errors.HypervisorError("Need a device model for the instance") + + if not os.path.isabs(hvparams[constants.HV_DEVICE_MODEL]): + raise errors.HypervisorError("The device model must be an absolute path") + + def ValidateParameters(self, hvparams): """Check the given parameters for validity. @@ -592,6 +600,11 @@ class XenHvmHypervisor(XenHypervisor): raise errors.HypervisorError("Instance kernel '%s' not found or" " not a file" % kernel_path) + device_model = hvparams[constants.HV_DEVICE_MODEL] + if not os.path.isfile(device_model): + raise errors.HypervisorError("Device model '%s' not found or" + " not a file" % device_model) + @classmethod def _WriteConfigFile(cls, instance, block_devices): """Create a Xen 3.1 HVM config file. @@ -610,20 +623,16 @@ class XenHvmHypervisor(XenHypervisor): config.write("memory = %d\n" % instance.beparams[constants.BE_MEMORY]) config.write("vcpus = %d\n" % instance.beparams[constants.BE_VCPUS]) config.write("name = '%s'\n" % instance.name) - if instance.hvparams[constants.HV_PAE]: + if hvp[constants.HV_PAE]: config.write("pae = 1\n") else: config.write("pae = 0\n") - if instance.hvparams[constants.HV_ACPI]: + if hvp[constants.HV_ACPI]: config.write("acpi = 1\n") else: config.write("acpi = 0\n") config.write("apic = 1\n") - arch = os.uname()[4] - if '64' in arch: - config.write("device_model = '/usr/lib64/xen/bin/qemu-dm'\n") - else: - config.write("device_model = '/usr/lib/xen/bin/qemu-dm'\n") + config.write("device_model = '%s'\n" % hvp[constants.HV_DEVICE_MODEL]) config.write("boot = '%s'\n" % hvp[constants.HV_BOOT_ORDER]) config.write("sdl = 0\n") config.write("usb = 1\n")