qmemman: use 'Memtotal' from /proc/meminfo to calculate used memory

Previously, memory_actual (retrieved from xen) was used; it can be inconsistent.
'Memtotal' can be spoofed, but anyway we rely on other fields from /proc/meminfo.
This commit is contained in:
Rafal Wojtczuk 2010-09-09 11:08:20 +02:00
parent 5a33ed71ce
commit 24b3baf063
2 changed files with 3 additions and 3 deletions

View File

@ -50,7 +50,7 @@ class SystemState:
dict[string.rstrip(l2[0], ":")] = l2[1]
try:
for i in ('MemFree', 'Buffers', 'Cached', 'SwapTotal', 'SwapFree'):
for i in ('MemTotal', 'MemFree', 'Buffers', 'Cached', 'SwapTotal', 'SwapFree'):
val = int(dict[i])*1024
if (val < 0):
return None

View File

@ -2,7 +2,7 @@ def is_suspicious(dom):
ret = False
if dom.meminfo['SwapTotal'] < dom.meminfo['SwapFree']:
ret = True
if dom.memory_actual < dom.meminfo['MemFree'] + dom.meminfo['Cached'] + dom.meminfo['Buffers']:
if dom.meminfo['MemTotal'] < dom.meminfo['MemFree'] + dom.meminfo['Cached'] + dom.meminfo['Buffers']:
ret = True
if ret:
print 'suspicious meminfo for domain', dom.id, 'mem actual', dom.memory_actual, dom.meminfo
@ -17,7 +17,7 @@ def recalc_mem_used(domdict):
dom.meminfo = None
dom.mem_used = None
else:
dom.mem_used = dom.memory_actual - dom.meminfo['MemFree'] - dom.meminfo['Cached'] - dom.meminfo['Buffers'] + dom.meminfo['SwapTotal'] - dom.meminfo['SwapFree']
dom.mem_used = dom.meminfo['MemTotal'] - dom.meminfo['MemFree'] - dom.meminfo['Cached'] - dom.meminfo['Buffers'] + dom.meminfo['SwapTotal'] - dom.meminfo['SwapFree']
def prefmem(dom):
if dom.meminfo_updated: