From 4ab7559954a082d3294ca3c0017f4e3db59b9c85 Mon Sep 17 00:00:00 2001 From: Dimitris Aragiorgis <dimara@grnet.gr> Date: Tue, 15 Jan 2013 03:56:48 +0200 Subject: [PATCH] Add KVM machine version as hv param This is needed in case an instance must be booted with an exact type of machine version (due to e.g. outdated drivers). If this hv param explicitly defined (during instance creation/modification) then the kvm process will be started having this version for the -M option. Otherwise the default (derived from _GetDefaultMachineVersion() will be used. Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/constants.py | 3 +++ lib/hypervisor/hv_kvm.py | 7 ++++++- man/gnt-instance.rst | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/constants.py b/lib/constants.py index b24c055b8..c036ba431 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -834,6 +834,7 @@ HV_SOUNDHW = "soundhw" HV_USB_DEVICES = "usb_devices" HV_VGA = "vga" HV_KVM_EXTRA = "kvm_extra" +HV_KVM_MACHINE_VERSION = "machine_version" HVS_PARAMETER_TYPES = { @@ -901,6 +902,7 @@ HVS_PARAMETER_TYPES = { HV_USB_DEVICES: VTYPE_STRING, HV_VGA: VTYPE_STRING, HV_KVM_EXTRA: VTYPE_STRING, + HV_KVM_MACHINE_VERSION: VTYPE_STRING, } HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys()) @@ -1972,6 +1974,7 @@ HVC_DEFAULTS = { HV_USB_DEVICES: "", HV_VGA: "", HV_KVM_EXTRA: "", + HV_KVM_MACHINE_VERSION: "", }, HT_FAKE: {}, HT_CHROOT: { diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 16f105a4d..2e7fda492 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -539,6 +539,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): constants.HV_USB_DEVICES: hv_base.NO_CHECK, constants.HV_VGA: hv_base.NO_CHECK, constants.HV_KVM_EXTRA: hv_base.NO_CHECK, + constants.HV_KVM_MACHINE_VERSION: hv_base.NO_CHECK, } _MIGRATION_STATUS_RE = re.compile("Migration\s+status:\s+(\w+)", @@ -1025,7 +1026,6 @@ class KVMHypervisor(hv_base.BaseHypervisor): pidfile = self._InstancePidFile(instance.name) kvm = constants.KVM_PATH kvm_cmd = [kvm] - kvm_cmd.extend(["-M", self._GetDefaultMachineVersion()]) # used just by the vnc server, if enabled kvm_cmd.extend(["-name", instance.name]) kvm_cmd.extend(["-m", instance.beparams[constants.BE_MAXMEM]]) @@ -1049,6 +1049,11 @@ class KVMHypervisor(hv_base.BaseHypervisor): constants.INSTANCE_REBOOT_EXIT: kvm_cmd.extend(["-no-reboot"]) + mversion = hvp[constants.HV_KVM_MACHINE_VERSION] + if not mversion: + mversion = self._GetDefaultMachineVersion() + kvm_cmd.extend(["-M", mversion]) + kernel_path = hvp[constants.HV_KERNEL_PATH] if kernel_path: boot_disk = boot_cdrom = boot_floppy = boot_network = False diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index 0d6b931ee..c33c559fd 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -674,6 +674,12 @@ kvm\_extra Any other option to the KVM hypervisor, useful tweaking anything that Ganeti doesn't support. +machine\_version + Valid for the KVM hypervisor. + + Use in case an instance must be booted with an exact type of + machine version (due to e.g. outdated drivers). In case it's not set + the default version supported by your version of kvm is used. The ``-O (--os-parameters)`` option allows customisation of the OS parameters. The actual parameter names and values depends on the OS -- GitLab