Change in vdsm[master]: Add qemu's memory usage to VM statistics.
wudxw at linux.vnet.ibm.com
wudxw at linux.vnet.ibm.com
Thu Nov 8 02:16:50 UTC 2012
Mark Wu has posted comments on this change.
Change subject: Add qemu's memory usage to VM statistics.
......................................................................
Patch Set 2: (1 inline comment)
....................................................
File vdsm/libvirtvm.py
Line 172: return netSamples
Line 173:
Line 174: def _sampleMem(self):
Line 175: memUsage = {}
Line 176: for line in open('/proc/%d/status' %(self.conf['pid'])):
vmStats thread is started in _initVmStats(), which is called by _domDependentInit, but it's executed before it gets the real pid.
_domDependentInit:
self._initVmStats()
...
self.conf['pid'] = self._getPid()
So when _initVmStats() is called, self.conf['pid'] is 0. _sampleMem could be invoked after _getPid() is done, but we shouldn't rely on it.
The advantage of using a with statement is that it is guaranteed to close the file no matter how its nested block exits.
BTW,
a space is missed after the seconde '%'
open('/proc/%d/status' %(self.conf['pid']))
should be
open('/proc/%d/status' % (self.conf['pid']))
to meet pep8's requirement.
Line 177: var, value = line.strip().split()[0:2]
Line 178: if var in ('VmSize:', 'VmRSS:', 'VmData:'):
Line 179: memUsage[var[:-1]] = long(value)
Line 180: return memUsage
--
To view, visit http://gerrit.ovirt.org/9006
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ibeb35759454c4a9b41e1303956267e93ca3545a0
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Gal Hammer <ghammer at redhat.com>
Gerrit-Reviewer: Gal Hammer <ghammer at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek at redhat.com>
Gerrit-Reviewer: Royce Lv <lvroyce at linux.vnet.ibm.com>
Gerrit-Reviewer: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
More information about the vdsm-patches
mailing list