Skip to content
Snippets Groups Projects
Commit 8bd977e9 authored by Sébastien Bocahu's avatar Sébastien Bocahu Committed by Guido Trotter
Browse files

Add support for cpu_cap and cpu_weight Xen params


This patch adds support for Xen's CPU scheduler 'cpu_cap' and
'cpu_weight' parameters.

Ganeti default values (cap: 0=unlimited, weight: 256) are Xen defaults.

cpu_cap is not validated correctly because of actual Ganeti limitation
on checks. I'd need check methods to get beparams or vcpus to get moved
to hvparams.

Signed-off-by: default avatarSébastien Bocahu <sebastien.bocahu@nuxit.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent d5cc16d7
No related branches found
No related tags found
No related merge requests found
...@@ -704,6 +704,9 @@ HV_PASSTHROUGH = "pci_pass" ...@@ -704,6 +704,9 @@ HV_PASSTHROUGH = "pci_pass"
HV_BLOCKDEV_PREFIX = "blockdev_prefix" HV_BLOCKDEV_PREFIX = "blockdev_prefix"
HV_REBOOT_BEHAVIOR = "reboot_behavior" HV_REBOOT_BEHAVIOR = "reboot_behavior"
HV_CPU_TYPE = "cpu_type" HV_CPU_TYPE = "cpu_type"
HV_CPU_CAP = "cpu_cap"
HV_CPU_WEIGHT = "cpu_weight"
HVS_PARAMETER_TYPES = { HVS_PARAMETER_TYPES = {
HV_BOOT_ORDER: VTYPE_STRING, HV_BOOT_ORDER: VTYPE_STRING,
...@@ -760,6 +763,8 @@ HVS_PARAMETER_TYPES = { ...@@ -760,6 +763,8 @@ HVS_PARAMETER_TYPES = {
HV_BLOCKDEV_PREFIX: VTYPE_STRING, HV_BLOCKDEV_PREFIX: VTYPE_STRING,
HV_REBOOT_BEHAVIOR: VTYPE_STRING, HV_REBOOT_BEHAVIOR: VTYPE_STRING,
HV_CPU_TYPE: VTYPE_STRING, HV_CPU_TYPE: VTYPE_STRING,
HV_CPU_CAP: VTYPE_INT,
HV_CPU_WEIGHT: VTYPE_INT,
} }
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys()) HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
...@@ -1701,6 +1706,8 @@ HVC_DEFAULTS = { ...@@ -1701,6 +1706,8 @@ HVC_DEFAULTS = {
HV_BLOCKDEV_PREFIX: "sd", HV_BLOCKDEV_PREFIX: "sd",
HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED, HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
HV_CPU_MASK: CPU_PINNING_ALL, HV_CPU_MASK: CPU_PINNING_ALL,
HV_CPU_CAP: 0,
HV_CPU_WEIGHT: 256,
}, },
HT_XEN_HVM: { HT_XEN_HVM: {
HV_BOOT_ORDER: "cd", HV_BOOT_ORDER: "cd",
...@@ -1720,6 +1727,8 @@ HVC_DEFAULTS = { ...@@ -1720,6 +1727,8 @@ HVC_DEFAULTS = {
HV_PASSTHROUGH: "", HV_PASSTHROUGH: "",
HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED, HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
HV_CPU_MASK: CPU_PINNING_ALL, HV_CPU_MASK: CPU_PINNING_ALL,
HV_CPU_CAP: 0,
HV_CPU_WEIGHT: 256,
}, },
HT_KVM: { HT_KVM: {
HV_KERNEL_PATH: KVM_KERNEL, HV_KERNEL_PATH: KVM_KERNEL,
......
...@@ -630,6 +630,9 @@ class XenPvmHypervisor(XenHypervisor): ...@@ -630,6 +630,9 @@ class XenPvmHypervisor(XenHypervisor):
constants.HV_REBOOT_BEHAVIOR: constants.HV_REBOOT_BEHAVIOR:
hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS), hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS),
constants.HV_CPU_MASK: hv_base.OPT_MULTI_CPU_MASK_CHECK, constants.HV_CPU_MASK: hv_base.OPT_MULTI_CPU_MASK_CHECK,
constants.HV_CPU_CAP: hv_base.NO_CHECK,
constants.HV_CPU_WEIGHT:
(False, lambda x: 0 < x < 65536, "invalid weight", None, None),
} }
@classmethod @classmethod
...@@ -672,6 +675,12 @@ class XenPvmHypervisor(XenHypervisor): ...@@ -672,6 +675,12 @@ class XenPvmHypervisor(XenHypervisor):
cpu_pinning = cls._CreateConfigCpus(hvp[constants.HV_CPU_MASK]) cpu_pinning = cls._CreateConfigCpus(hvp[constants.HV_CPU_MASK])
if cpu_pinning: if cpu_pinning:
config.write("%s\n" % cpu_pinning) config.write("%s\n" % cpu_pinning)
cpu_cap = hvp[constants.HV_CPU_CAP]
if cpu_cap:
config.write("cpu_cap=%d\n" % cpu_cap)
cpu_weight = hvp[constants.HV_CPU_WEIGHT]
if cpu_weight:
config.write("cpu_weight=%d\n" % cpu_weight)
config.write("name = '%s'\n" % instance.name) config.write("name = '%s'\n" % instance.name)
...@@ -743,6 +752,9 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -743,6 +752,9 @@ class XenHvmHypervisor(XenHypervisor):
constants.HV_REBOOT_BEHAVIOR: constants.HV_REBOOT_BEHAVIOR:
hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS), hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS),
constants.HV_CPU_MASK: hv_base.OPT_MULTI_CPU_MASK_CHECK, constants.HV_CPU_MASK: hv_base.OPT_MULTI_CPU_MASK_CHECK,
constants.HV_CPU_CAP: hv_base.NO_CHECK,
constants.HV_CPU_WEIGHT:
(False, lambda x: 0 < x < 65535, "invalid weight", None, None),
} }
@classmethod @classmethod
...@@ -766,6 +778,12 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -766,6 +778,12 @@ class XenHvmHypervisor(XenHypervisor):
cpu_pinning = cls._CreateConfigCpus(hvp[constants.HV_CPU_MASK]) cpu_pinning = cls._CreateConfigCpus(hvp[constants.HV_CPU_MASK])
if cpu_pinning: if cpu_pinning:
config.write("%s\n" % cpu_pinning) config.write("%s\n" % cpu_pinning)
cpu_cap = hvp[constants.HV_CPU_CAP]
if cpu_cap:
config.write("cpu_cap=%d\n" % cpu_cap)
cpu_weight = hvp[constants.HV_CPU_WEIGHT]
if cpu_weight:
config.write("cpu_weight=%d\n" % cpu_weight)
config.write("name = '%s'\n" % instance.name) config.write("name = '%s'\n" % instance.name)
if hvp[constants.HV_PAE]: if hvp[constants.HV_PAE]:
......
...@@ -587,6 +587,18 @@ cpu\_mask ...@@ -587,6 +587,18 @@ cpu\_mask
# Turn off CPU pinning (default setting) # Turn off CPU pinning (default setting)
gnt-instance modify -H cpu_mask=all my-inst gnt-instance modify -H cpu_mask=all my-inst
cpu\_cap
Valid for the Xen hypervisor.
Set the maximum amount of cpu usage by the VM. The value is a percentage
between 0 and (100 * number of VCPUs). Default cap is 0: unlimited.
cpu\_weight
Valid for the Xen hypervisor.
Set the cpu time ratio to be allocated to the VM. Valid values are
between 1 and 65535. Default weight is 256.
usb\_mouse usb\_mouse
Valid for the KVM hypervisor. Valid for the KVM hypervisor.
......
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