[XEND][XM] Move system memory reporting to XendConfig rather than getSysMem.
authorAlastair Tse <atse@xensource.com>
Thu, 9 Nov 2006 12:36:20 +0000 (12:36 +0000)
committerAlastair Tse <atse@xensource.com>
Thu, 9 Nov 2006 12:36:20 +0000 (12:36 +0000)
Remove the additional XMLRPC calls per domain just to get system
memory and instead make sure we update that value and return it via
the SXP that gets returned when xm list is called.

Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xend/XendConfig.py
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xend/server/XMLRPCServer.py
tools/python/xen/xm/main.py

index 68d4e48ec6065561744d0a7c1cfd58c22ca33c0d..98f1f572faea1fe92c3fcce99425ef22ac2cff5b 100644 (file)
@@ -661,6 +661,8 @@ class XendConfig(dict):
             sxpr.append(['status', str(DOM_STATE_HALTED)])
 
         sxpr.append(['state', self._get_old_state_string()])
+        sxpr.append(['memory_dynamic_max', self.get('memory_dynamic_max',
+                                                    self['memory'])])
 
         # For save/restore migration
         if domain:
@@ -718,6 +720,10 @@ class XendConfig(dict):
 
         self['maxmem'] = max(self['memory'], self['maxmem'])
 
+        # convert mem_kb from domain_getinfo to something more descriptive
+        if 'mem_kb' in self:
+            self['memory_dynamic_max'] = (self['mem_kb'] + 1023)/1024
+
         # Verify devices
         for d_uuid, (d_type, d_info) in self['device'].items():
             if d_type not in XendDevices.valid_devices():
index 03ca41660af669cf039d41450c53e3bcdeefc4a1..e13d2bc42d89e76047b94fc0f58299c28e69a669 100644 (file)
@@ -1044,11 +1044,6 @@ class XendDomainInfo:
         except:
             log.exception('Failed to restart domain %s.', str(old_domid))
 
-    def getSysMem(self):
-        info = dom_get(self.domid)
-        xs_memory=int(info['mem_kb'])/1024
-        return xs_memory
-
     def _preserveForRestart(self):
         """Preserve a domain that has been shut down, by giving it a new UUID,
         cloning the VM details, and giving it a new name.  This allows us to
index eb662c4fabdd650b1ceeccc983ce55fdcbeea5bb..4ab43ca7f91f13a313fc236e3c717c68937047cd 100644 (file)
@@ -79,7 +79,7 @@ methods = ['device_create', 'device_configure',
            'destroyDevice','getDeviceSxprs',
            'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown',
            'send_sysrq', 'getVCPUInfo', 'waitForDevices',
-           'getRestartCount', 'getSysMem']
+           'getRestartCount']
 
 exclude = ['domain_create', 'domain_restore']
 
index 48fa4229edea16b2739a6f6e5fa2e225909b9ca4..56467f4df32f607c248eee923435e1f3e1afd272 100644 (file)
@@ -540,7 +540,7 @@ def parse_doms_info(info):
     return {
         'domid'    : get_info('domid',        int,   -1),
         'name'     : get_info('name',         str,   '??'),
-        'mem'      : get_info('memory',       int,   0),
+        'mem'      : get_info('memory_dynamic_max', int,   0),
         'vcpus'    : get_info('online_vcpus', int,   0),
         'state'    : get_info('state',        str,    ''),
         'cpu_time' : get_info('cpu_time',     float, 0),
@@ -563,12 +563,6 @@ def parse_sedf_info(info):
         }
 
 def xm_brief_list(doms):
-    def get_mem_info():
-       dom_sysMem=server.xend.domain.getSysMem(d['domid'])
-       if dom_sysMem:
-               d['mem']=dom_sysMem
-
-
     print '%-40s %3s %5s %5s %10s %9s' % \
           ('Name', 'ID', 'Mem', 'VCPUs', 'State', 'Time(s)')
     
@@ -577,7 +571,6 @@ def xm_brief_list(doms):
     
     for dom in doms:
         d = parse_doms_info(dom)
-        get_mem_info()
         print format % d
 
 def xm_label_list(doms):