Skip to content
Snippets Groups Projects
Commit 09ea8710 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>
parent e2ee1cea
No related branches found
No related tags found
No related merge requests found
......@@ -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",
......
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment