diff --git a/lib/constants.py b/lib/constants.py index 540eb1fb23f107ddcee30db0bd8ef34c731bbca2..af3df19d0728b2a4a0c08b8aa237dd87fbcaa45b 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -773,6 +773,7 @@ HV_MEM_PATH = "mem_path" HV_PASSTHROUGH = "pci_pass" HV_BLOCKDEV_PREFIX = "blockdev_prefix" HV_REBOOT_BEHAVIOR = "reboot_behavior" +HV_CPU_TYPE = "cpu_type" HVS_PARAMETER_TYPES = { HV_BOOT_ORDER: VTYPE_STRING, @@ -828,6 +829,7 @@ HVS_PARAMETER_TYPES = { HV_PASSTHROUGH: VTYPE_STRING, HV_BLOCKDEV_PREFIX: VTYPE_STRING, HV_REBOOT_BEHAVIOR: VTYPE_STRING, + HV_CPU_TYPE: VTYPE_STRING, } HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys()) @@ -1812,6 +1814,7 @@ HVC_DEFAULTS = { HV_MEM_PATH: "", HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED, HV_CPU_MASK: CPU_PINNING_ALL, + HV_CPU_TYPE: "", }, HT_FAKE: { }, diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 087939e95574182d83ff0ff067ea60fa9374b6f6..a3b4f92bc61d150d48ff56a67a64b22f14c1e1fc 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -493,6 +493,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): constants.HV_REBOOT_BEHAVIOR: hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS), constants.HV_CPU_MASK: hv_base.OPT_MULTI_CPU_MASK_CHECK, + constants.HV_CPU_TYPE: hv_base.NO_CHECK } _MIGRATION_STATUS_RE = re.compile("Migration\s+status:\s+(\w+)", @@ -1243,6 +1244,10 @@ class KVMHypervisor(hv_base.BaseHypervisor): if hvp[constants.HV_KVM_USE_CHROOT]: kvm_cmd.extend(["-chroot", self._InstanceChrootDir(instance.name)]) + # Add qemu-KVM -cpu param + if hvp[constants.HV_CPU_TYPE]: + kvm_cmd.extend(["-cpu", hvp[constants.HV_CPU_TYPE]]) + # Save the current instance nics, but defer their expansion as parameters, # as we'll need to generate executable temp files for them. kvm_nics = instance.nics diff --git a/lib/query.py b/lib/query.py index 190b1542c21df8550b886aaa442fbf0ee33578b1..db2030eb8c011b12dccee7e4dc3312c42968d818 100644 --- a/lib/query.py +++ b/lib/query.py @@ -1773,6 +1773,7 @@ def _GetInstanceParameterFields(): constants.HV_PAE: "PAE", constants.HV_VNC_BIND_ADDRESS: "VNC_bind_address", constants.HV_PASSTHROUGH: "pci_pass", + constants.HV_CPU_TYPE: "cpu_type", } fields = [ diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index b71643a15253ca93079da3024922792c400fa711..dfb6ed439be80f688ae470452d09770ed84260f3 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -385,6 +385,19 @@ spice\_use\_vdagent Enables or disables passing mouse events via SPICE vdagent. +cpu\_type + Valid for the KVM hypervisor. + + This parameter determines the emulated cpu for the instance. If this + parameter is empty (which is the default configuration), it will not + be passed to KVM. + + Be aware of setting this parameter to ``"host"`` if you have nodes + with different CPUs from each other. Live migration may stop working + in this situation. + + For more information please refer to the KVM manual. + acpi Valid for the Xen HVM and KVM hypervisors.