Martin Sivák has uploaded a new change for review. Change subject: Add support for direct setting of cpu_shares when creating a VM ......................................................................
Add support for direct setting of cpu_shares when creating a VM This adds new API field to the Vm structures. The new field 'cpuShares' will override the old 'nice' when used. Change-Id: I7ef73cf0579a0efd5a31c32638efcc6cdf2447d7 Signed-off-by: Martin Sivak <[email protected]> --- M vdsm/vm.py M vdsm_api/vdsmapi-schema.json 2 files changed, 15 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/03/17603/1 diff --git a/vdsm/vm.py b/vdsm/vm.py index 4333170..2440557 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -2805,8 +2805,15 @@ nice = int(self.conf.get('nice', '0')) nice = max(min(nice, 19), 0) + + # if cpu_shares weren't configured we derive the value from the + # niceness, cpu_shares has not unit, it is only meaningful when + # compared to other VMs (and can't be negative) + cpu_shares = int(self.conf.get('cpuShares', str((20 - nice) * 51))) + cpu_shares = max(cpu_shares, 0) + try: - self._dom.setSchedulerParameters({'cpu_shares': (20 - nice) * 51}) + self._dom.setSchedulerParameters({'cpu_shares': cpu_shares}) except: self.log.warning('failed to set Vm niceness', exc_info=True) diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json index 73963cf..9430148 100644 --- a/vdsm_api/vdsmapi-schema.json +++ b/vdsm_api/vdsmapi-schema.json @@ -2629,6 +2629,8 @@ # # @clientIp: The IP address of the client connected to the display # +# @cpuShares: The host scheduling priority (relative to other VMs) +# # @cpuType: #optional The type of CPU being emulated # special values 'hostPassthrough' and 'hostModel' # are reserved for host-passthrough and host-mode cpu @@ -2691,8 +2693,8 @@ # Since: 4.10.0 ## {'type': 'VmDefinition', - 'data': {'acpiEnable': 'bool', 'clientIp': 'str', '*cpuType': 'str', - '*custom': 'StringMap', '*devices': ['VmDevice'], + 'data': {'acpiEnable': 'bool', 'clientIp': 'str', 'cpuShares': 'str', + '*cpuType': 'str', '*custom': 'StringMap', '*devices': ['VmDevice'], 'display': 'VmDisplayType', 'displayIp': 'str', 'displayPort': 'int', 'displaySecurePort': 'int', '*emulatedMachine': 'str', '*keyboardLayout': 'str', @@ -2710,6 +2712,8 @@ # Parameters for creating a new virtual machine # # @acpiEnable: Indicates if ACPI is enabled inside the VM +# +# @cpuShares: The host scheduling priority (relative to other VMs) # # @custom: #optional A dictionary of custom, free-form properties # @@ -2744,7 +2748,7 @@ ## {'type': 'VmParameters', 'data': {'acpiEnable': 'bool', - '*custom': 'StringMap', '*devices': ['VmDevice'], + 'cpuShares': 'str', '*custom': 'StringMap', '*devices': ['VmDevice'], 'display': 'VmDisplayType', 'kvmEnable': 'bool', 'memSize': 'uint', 'nice': 'int', 'smp': 'uint', '*smpCoresPerSocket': 'uint', '*smpThreadsPerCore': 'uint', 'timeOffset': 'uint', -- To view, visit http://gerrit.ovirt.org/17603 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7ef73cf0579a0efd5a31c32638efcc6cdf2447d7 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.3 Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
