ia64/xen-unstable

changeset 8140:e33f8d664e2d

Move the translation from pages to MiB out of XendNode and into the xc layer.
xc has access to the page size for the platform and the Python layer does not,
so there was a hardcoded "/ 256" in there.

Rename the "memory" physinfo parameter to "total_memory", to match the usage
elsewhere.

Tidy the code generating the SXP for xm info.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Wed Nov 30 18:43:00 2005 +0000 (2005-11-30)
parents 341c56e34b0d
children 69df979de1a7
files tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendNode.py tools/xm-test/lib/XmTestReport/OSReport.py
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Wed Nov 30 18:38:48 2005 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Wed Nov 30 18:43:00 2005 +0000
     1.3 @@ -575,6 +575,13 @@ static PyObject *pyxc_readconsolering(Xc
     1.4      return PyString_FromStringAndSize(str, count);
     1.5  }
     1.6  
     1.7 +
     1.8 +static unsigned long pages_to_mb(unsigned long pages)
     1.9 +{
    1.10 +    return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024;
    1.11 +}
    1.12 +
    1.13 +
    1.14  static PyObject *pyxc_physinfo(XcObject *self)
    1.15  {
    1.16      xc_physinfo_t info;
    1.17 @@ -599,8 +606,8 @@ static PyObject *pyxc_physinfo(XcObject 
    1.18                           "cores_per_socket", info.cores_per_socket,
    1.19                           "sockets_per_node", info.sockets_per_node,
    1.20                           "nr_nodes",         info.nr_nodes,
    1.21 -                         "total_pages",      info.total_pages,
    1.22 -                         "free_pages",       info.free_pages,
    1.23 +                         "total_memory",     pages_to_mb(info.total_pages),
    1.24 +                         "free_memory",      pages_to_mb(info.free_pages),
    1.25                           "cpu_khz",          info.cpu_khz,
    1.26                           "hw_caps",          cpu_cap);
    1.27  }
     2.1 --- a/tools/python/xen/xend/XendNode.py	Wed Nov 30 18:38:48 2005 +0000
     2.2 +++ b/tools/python/xen/xend/XendNode.py	Wed Nov 30 18:43:00 2005 +0000
     2.3 @@ -57,30 +57,45 @@ class XendNode:
     2.4                  ['machine', mch]]
     2.5  
     2.6      def physinfo(self):
     2.7 -        pinfo = self.xc.physinfo()
     2.8 -        info = [['nr_cpus',          pinfo['nr_nodes']*pinfo['sockets_per_node']*pinfo['cores_per_socket']*pinfo['threads_per_core']],
     2.9 -                ['nr_nodes',         pinfo['nr_nodes']],
    2.10 -                ['sockets_per_node', pinfo['sockets_per_node']],
    2.11 -                ['cores_per_socket', pinfo['cores_per_socket']],
    2.12 -                ['threads_per_core', pinfo['threads_per_core']],
    2.13 -                ['cpu_mhz',          pinfo['cpu_khz']/1000],
    2.14 -                ['hw_caps',          pinfo['hw_caps']],
    2.15 -                ['memory',           pinfo['total_pages']/256],
    2.16 -                ['free_memory',      pinfo['free_pages']/256]]
    2.17 -        return info
    2.18 -        
    2.19 +        info = self.xc.physinfo()
    2.20 +
    2.21 +        info['nr_cpus'] = (info['nr_nodes'] *
    2.22 +                           info['sockets_per_node'] *
    2.23 +                           info['cores_per_socket'] *
    2.24 +                           info['threads_per_core'])
    2.25 +        info['cpu_mhz'] = info['cpu_khz'] / 1000
    2.26 +
    2.27 +        ITEM_ORDER = ['nr_cpus',
    2.28 +                      'nr_nodes',
    2.29 +                      'sockets_per_node',
    2.30 +                      'cores_per_socket',
    2.31 +                      'threads_per_core',
    2.32 +                      'cpu_mhz',
    2.33 +                      'hw_caps',
    2.34 +                      'total_memory',
    2.35 +                      'free_memory',
    2.36 +                      ]
    2.37 +
    2.38 +        return [[k, info[k]] for k in ITEM_ORDER]
    2.39 +
    2.40 +
    2.41      def xeninfo(self):
    2.42 -        xinfo = self.xc.xeninfo()
    2.43 -        return [['xen_major', xinfo['xen_major']],
    2.44 -                ['xen_minor', xinfo['xen_minor']],
    2.45 -                ['xen_extra', xinfo['xen_extra']],
    2.46 -                ['xen_caps',  xinfo['xen_caps']],
    2.47 -                ['platform_params',xinfo['platform_params']],
    2.48 -                ['xen_changeset', xinfo['xen_changeset']],
    2.49 -                ['cc_compiler', xinfo['cc_compiler']],
    2.50 -                ['cc_compile_by', xinfo['cc_compile_by']],
    2.51 -                ['cc_compile_domain', xinfo['cc_compile_domain']],
    2.52 -                ['cc_compile_date', xinfo['cc_compile_date']]]
    2.53 +        info = self.xc.xeninfo()
    2.54 +
    2.55 +        ITEM_ORDER = ['xen_major',
    2.56 +                      'xen_minor',
    2.57 +                      'xen_extra',
    2.58 +                      'xen_caps',
    2.59 +                      'platform_params',
    2.60 +                      'xen_changeset',
    2.61 +                      'cc_compiler',
    2.62 +                      'cc_compile_by',
    2.63 +                      'cc_compile_domain',
    2.64 +                      'cc_compile_date',
    2.65 +                      ]
    2.66 +
    2.67 +        return [[k, info[k]] for k in ITEM_ORDER]
    2.68 +
    2.69  
    2.70  def instance():
    2.71      global inst
     3.1 --- a/tools/xm-test/lib/XmTestReport/OSReport.py	Wed Nov 30 18:38:48 2005 +0000
     3.2 +++ b/tools/xm-test/lib/XmTestReport/OSReport.py	Wed Nov 30 18:43:00 2005 +0000
     3.3 @@ -97,7 +97,7 @@ class Machine:
     3.4                       "cores_per_socket" : "Unknown",
     3.5                       "threads_per_core" : "Unknown",
     3.6                       "cpu_mhz"          : "Unknown",
     3.7 -                     "memory"           : "Unknown"}
     3.8 +                     "total_memory"     : "Unknown"}
     3.9  
    3.10          xen = self.__getXenInfo(xenValues)
    3.11          cpu = self.__getCpuInfo(cpuValues)