diff --git a/lib/constants.py b/lib/constants.py index b24c055b8bb9dfd224ccfafa1c6ded7b06f5c9ae..c036ba431ad7b8f283796c0b6a7ba9eee007122c 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 16f105a4dd307ee97826c36e7e9906955aaf6bb4..2e7fda49261783fed144d33defe40801cd2bec6f 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 0d6b931ee4cd05961e9c1fc44acfb37c02c144eb..c33c559fd0aa2807620aaaaf47c1e6f01a8332fb 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