Commit 703dc23d authored by Iustin Pop's avatar Iustin Pop
Browse files

Move HVM's device_model to a hypervisor parameter



This moves yet another hardcoded value to a hypervisor parameter. I
removed the 64/32 difference as it doesn't seem valid to me - it's more
of a local site config rather than arch config.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
(cherry picked from commit 09ea8710)
parent e71b560a
...@@ -308,6 +308,7 @@ HV_INITRD_PATH = "initrd_path" ...@@ -308,6 +308,7 @@ HV_INITRD_PATH = "initrd_path"
HV_ROOT_PATH = "root_path" HV_ROOT_PATH = "root_path"
HV_SERIAL_CONSOLE = "serial_console" HV_SERIAL_CONSOLE = "serial_console"
HV_USB_MOUSE = "usb_mouse" HV_USB_MOUSE = "usb_mouse"
HV_DEVICE_MODEL = "device_model"
HVS_PARAMETER_TYPES = { HVS_PARAMETER_TYPES = {
HV_BOOT_ORDER: VTYPE_STRING, HV_BOOT_ORDER: VTYPE_STRING,
...@@ -326,6 +327,7 @@ HVS_PARAMETER_TYPES = { ...@@ -326,6 +327,7 @@ HVS_PARAMETER_TYPES = {
HV_ROOT_PATH: VTYPE_STRING, HV_ROOT_PATH: VTYPE_STRING,
HV_SERIAL_CONSOLE: VTYPE_BOOL, HV_SERIAL_CONSOLE: VTYPE_BOOL,
HV_USB_MOUSE: VTYPE_STRING, HV_USB_MOUSE: VTYPE_STRING,
HV_DEVICE_MODEL: VTYPE_STRING,
} }
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys()) HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
...@@ -511,6 +513,7 @@ HVC_DEFAULTS = { ...@@ -511,6 +513,7 @@ HVC_DEFAULTS = {
HV_ACPI: True, HV_ACPI: True,
HV_PAE: True, HV_PAE: True,
HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader", HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
}, },
HT_KVM: { HT_KVM: {
HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU", HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
......
...@@ -519,6 +519,7 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -519,6 +519,7 @@ class XenHvmHypervisor(XenHypervisor):
constants.HV_PAE, constants.HV_PAE,
constants.HV_VNC_BIND_ADDRESS, constants.HV_VNC_BIND_ADDRESS,
constants.HV_KERNEL_PATH, constants.HV_KERNEL_PATH,
constants.HV_DEVICE_MODEL,
] ]
@classmethod @classmethod
...@@ -566,6 +567,13 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -566,6 +567,13 @@ class XenHvmHypervisor(XenHypervisor):
if not os.path.isabs(hvparams[constants.HV_KERNEL_PATH]): if not os.path.isabs(hvparams[constants.HV_KERNEL_PATH]):
raise errors.HypervisorError("The kernel path must be an absolute 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): def ValidateParameters(self, hvparams):
"""Check the given parameters for validity. """Check the given parameters for validity.
...@@ -592,6 +600,11 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -592,6 +600,11 @@ class XenHvmHypervisor(XenHypervisor):
raise errors.HypervisorError("Instance kernel '%s' not found or" raise errors.HypervisorError("Instance kernel '%s' not found or"
" not a file" % kernel_path) " 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 @classmethod
def _WriteConfigFile(cls, instance, block_devices): def _WriteConfigFile(cls, instance, block_devices):
"""Create a Xen 3.1 HVM config file. """Create a Xen 3.1 HVM config file.
...@@ -610,20 +623,16 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -610,20 +623,16 @@ class XenHvmHypervisor(XenHypervisor):
config.write("memory = %d\n" % instance.beparams[constants.BE_MEMORY]) config.write("memory = %d\n" % instance.beparams[constants.BE_MEMORY])
config.write("vcpus = %d\n" % instance.beparams[constants.BE_VCPUS]) config.write("vcpus = %d\n" % instance.beparams[constants.BE_VCPUS])
config.write("name = '%s'\n" % instance.name) config.write("name = '%s'\n" % instance.name)
if instance.hvparams[constants.HV_PAE]: if hvp[constants.HV_PAE]:
config.write("pae = 1\n") config.write("pae = 1\n")
else: else:
config.write("pae = 0\n") config.write("pae = 0\n")
if instance.hvparams[constants.HV_ACPI]: if hvp[constants.HV_ACPI]:
config.write("acpi = 1\n") config.write("acpi = 1\n")
else: else:
config.write("acpi = 0\n") config.write("acpi = 0\n")
config.write("apic = 1\n") config.write("apic = 1\n")
arch = os.uname()[4] config.write("device_model = '%s'\n" % hvp[constants.HV_DEVICE_MODEL])
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("boot = '%s'\n" % hvp[constants.HV_BOOT_ORDER]) config.write("boot = '%s'\n" % hvp[constants.HV_BOOT_ORDER])
config.write("sdl = 0\n") config.write("sdl = 0\n")
config.write("usb = 1\n") config.write("usb = 1\n")
......
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