Change in vdsm[master]: Add support for direct setting of cpu_shares when creating a...

msivak at redhat.com msivak at redhat.com
Wed Jul 31 13:05:22 UTC 2013


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 <msivak at redhat.com>
---
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/28/17528/1

diff --git a/vdsm/vm.py b/vdsm/vm.py
index 2fa5a45..c1cc51f 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -2804,8 +2804,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 71878e4..fdb4c66 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -2632,6 +2632,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
@@ -2694,8 +2696,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',
@@ -2713,6 +2715,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
 #
@@ -2747,7 +2751,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/17528
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ef73cf0579a0efd5a31c32638efcc6cdf2447d7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <msivak at redhat.com>


More information about the vdsm-patches mailing list