Change in vdsm[master]: [WIP]add mem cgroup support to vdsm

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Tue Sep 18 08:29:40 UTC 2012


Royce Lv has uploaded a new change for review.

Change subject: [WIP]add mem cgroup support to vdsm
......................................................................

[WIP]add mem cgroup support to vdsm

add vdsm mem cgroup support,
New version libvirt memtune function has a bug,
tested uncompleted until I fix the bug.

Change-Id: If2ad220e21b114985ead4bd64e81133173566444
Signed-off-by: Royce Lv<lvroyce at linux.vnet.ibm.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/define.py
M vdsm/libvirtvm.py
M vdsm_api/vdsmapi-schema.json
M vdsm_cli/vdsClient.py
6 files changed, 90 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/8031/1

diff --git a/vdsm/API.py b/vdsm/API.py
index 566d6e5..f5889f9 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -37,6 +37,7 @@
 import storage.volume
 import storage.sd
 import storage.image
+import storage.storage_exception as se
 from vdsm.define import doneCode, errCode, Kbytes, Mbytes
 import caps
 from vdsm.config import config
@@ -555,6 +556,19 @@
             message = USER_SHUTDOWN_MESSAGE
         return v.shutdown(delay, message)
 
+    def tuneMem(self, tuneParams):
+        try:
+            v = self._cif.vmContainer[self._UUID]
+            for key in tuneParams:
+                tuneParams[key] = storage.misc.validateN(
+                                          tuneParams[key], key)
+        except KeyError:
+            return errCode['noVM']
+        except se.InvalidParameterException:
+            return errCode['tuneMemErr']
+
+        return v.tuneMem(tuneParams)
+
     def _createSysprepFloppyFromInf(self, infFileBinary, floppyImage):
         try:
             rc, out, err = utils.execCmd([constants.EXT_MK_SYSPREP_FLOPPY,
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 826c125..fe7b9d5 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -265,6 +265,10 @@
         vm = API.VM(vmId)
         return vm.snapshot(snapDrives)
 
+    def vmTuneMem(self, params):
+        vm = API.VM(params.pop('vmId'))
+        return vm.tuneMem(params)
+
     def vmMerge(self, vmId, mergeDrives):
         vm = API.VM(vmId)
         return vm.merge(mergeDrives)
@@ -765,7 +769,8 @@
                 (self.vmHotplugDisk, 'hotplugDisk'),
                 (self.vmHotunplugDisk, 'hotunplugDisk'),
                 (self.vmHotplugNic, 'hotplugNic'),
-                (self.vmHotunplugNic, 'hotunplugNic'))
+                (self.vmHotunplugNic, 'hotunplugNic'),
+                (self.vmTuneMem, 'tuneMem'))
 
     def getIrsMethods(self):
         return ((self.domainActivate, 'activateStorageDomain'),
diff --git a/vdsm/define.py b/vdsm/define.py
index 049d36c..ba71bf6 100644
--- a/vdsm/define.py
+++ b/vdsm/define.py
@@ -117,6 +117,9 @@
             'momErr':       {'status':
                              {'code': 54,
                               'message': 'Failed to set mom policy'}},
+            'tuneMemErr':   {'status':
+                             {'code': 56,
+                              'message': 'Failed to tune Mem'}},
             'recovery':     {'status':
                              {'code': 99,
                               'message':
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 4dc47e3..048fa7d 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1887,6 +1887,22 @@
                 (snapFlags & libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
                     == libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE)}
 
+    def tuneMem(self, tuneParams):
+        try:
+            self._dom.setMemoryParameters(tuneParams)
+            for param in tuneParams:
+                self.conf[param] = tuneParams[param]
+            self.saveState()
+            return {'status': doneCode}
+        except libvirt.libvirtError, e:
+            self.log.error("TuneMem failed:%s",
+                               e.message, exc_info=True)
+            return errCode['tuneMemErr']
+        except LookupError:
+            self.log.error('TuneMem failed: unrecongnized params',
+                               exc_info=True)
+            return errCode['tuneMemErr']
+
     def _runMerge(self):
         for mergeStatus in self.conf.get('liveMerge', []):
             if mergeStatus['status'] != MERGESTATUS.NOT_STARTED:
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index c0440d2..509a90c 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -5099,6 +5099,34 @@
 {'command': {'class': 'VM', 'name': 'mergeStatus'},
  'returns': ['MergeStatus']}
 
+##
+# @TuneMemParams:
+#
+# Parameters for @VM.tuneMem.
+#
+# @hard_limit:       Maximum memory the VM can consume
+#
+# @soft_limit:       Memory limit during contention
+#
+# @min_gurantee:     Min memory guranteed to the VM
+#
+# Since: 4.10.0
+##
+{'type': 'TuneMemParams',
+ 'data': {'hard_limit': 'uint', 'soft_limit': 'uint',
+	  'min_gurantee': 'uint'}}
+##
+# @VM.tuneMem:
+#
+# Tune memory hard limits and min allocation guranteed.
+#
+# @TuneMemParams: Tunning parameters for memory
+#
+# Since: 4.10.0
+##
+{'command': {'class': 'VM', 'name': 'tuneMem'},
+ 'data': {'tuneParams': 'TuneMemParams'}}
+
 ## Category: @Volume ###########################################################
 ##
 # @Volume:
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index fe2f083..8787c28 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -204,6 +204,16 @@
 
         return self.ExecAndExit(self.s.create(params))
 
+    def tuneMem(self, args):
+        params = {}
+        params['vmId'] = args[0]
+        if len(args) > 1:
+            for param in args[1:]:
+                if '=' in param:
+                    key, value = line.split("=", 1)
+                    params[key] = value
+        return self.ExecAndExit(self.s.tuneMem(params))
+
     def hotplugNic(self, args):
         nic = self._parseDriveSpec(args[1])
         nic['type'] = 'interface'
@@ -1801,6 +1811,19 @@
                          'Optional additional parameters in dictionary format,'
                          ' name:value,name:value'
                         )),
+        'tuneMem': (serv.tuneMem,
+                       ('<vmId>'
+                            '[hard_limit=value soft_limit=value min_gurantee]',
+                        'Parameters list: r=required, o=optional',
+                        'r   vmId: The vm to be tuned',
+                        'o   hard_limit=<value>: '
+                            'maximum memory the VM can use(in KiB)',
+                        'o   soft_limit=<value>:'
+                            'memory limit to enforce during memory contention',
+                        'o   min_gurantee=<value>:'
+                            'min memory guranteed to the VM',
+                        'Tune memory hard limits and min allocation gurantee'
+                       )),
         'migrate':   (serv.do_migrate,
                        ('vmId=<id> method=<offline|online> src=<host:[port]> '
                            'dst=<host:[port]>',


--
To view, visit http://gerrit.ovirt.org/8031
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2ad220e21b114985ead4bd64e81133173566444
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce at linux.vnet.ibm.com>


More information about the vdsm-patches mailing list