diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index c63968f424..29f64641d6 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -575,6 +575,13 @@ static PyObject *pyxc_readconsolering(XcObject *self, return PyString_FromStringAndSize(str, count); } + +static unsigned long pages_to_mb(unsigned long pages) +{ + return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024; +} + + static PyObject *pyxc_physinfo(XcObject *self) { xc_physinfo_t info; @@ -599,8 +606,8 @@ static PyObject *pyxc_physinfo(XcObject *self) "cores_per_socket", info.cores_per_socket, "sockets_per_node", info.sockets_per_node, "nr_nodes", info.nr_nodes, - "total_pages", info.total_pages, - "free_pages", info.free_pages, + "total_memory", pages_to_mb(info.total_pages), + "free_memory", pages_to_mb(info.free_pages), "cpu_khz", info.cpu_khz, "hw_caps", cpu_cap); } diff --git a/tools/python/xen/xend/XendNode.py b/tools/python/xen/xend/XendNode.py index 250d11cece..02899bec27 100644 --- a/tools/python/xen/xend/XendNode.py +++ b/tools/python/xen/xend/XendNode.py @@ -57,30 +57,45 @@ class XendNode: ['machine', mch]] def physinfo(self): - pinfo = self.xc.physinfo() - info = [['nr_cpus', pinfo['nr_nodes']*pinfo['sockets_per_node']*pinfo['cores_per_socket']*pinfo['threads_per_core']], - ['nr_nodes', pinfo['nr_nodes']], - ['sockets_per_node', pinfo['sockets_per_node']], - ['cores_per_socket', pinfo['cores_per_socket']], - ['threads_per_core', pinfo['threads_per_core']], - ['cpu_mhz', pinfo['cpu_khz']/1000], - ['hw_caps', pinfo['hw_caps']], - ['memory', pinfo['total_pages']/256], - ['free_memory', pinfo['free_pages']/256]] - return info - + info = self.xc.physinfo() + + info['nr_cpus'] = (info['nr_nodes'] * + info['sockets_per_node'] * + info['cores_per_socket'] * + info['threads_per_core']) + info['cpu_mhz'] = info['cpu_khz'] / 1000 + + ITEM_ORDER = ['nr_cpus', + 'nr_nodes', + 'sockets_per_node', + 'cores_per_socket', + 'threads_per_core', + 'cpu_mhz', + 'hw_caps', + 'total_memory', + 'free_memory', + ] + + return [[k, info[k]] for k in ITEM_ORDER] + + def xeninfo(self): - xinfo = self.xc.xeninfo() - return [['xen_major', xinfo['xen_major']], - ['xen_minor', xinfo['xen_minor']], - ['xen_extra', xinfo['xen_extra']], - ['xen_caps', xinfo['xen_caps']], - ['platform_params',xinfo['platform_params']], - ['xen_changeset', xinfo['xen_changeset']], - ['cc_compiler', xinfo['cc_compiler']], - ['cc_compile_by', xinfo['cc_compile_by']], - ['cc_compile_domain', xinfo['cc_compile_domain']], - ['cc_compile_date', xinfo['cc_compile_date']]] + info = self.xc.xeninfo() + + ITEM_ORDER = ['xen_major', + 'xen_minor', + 'xen_extra', + 'xen_caps', + 'platform_params', + 'xen_changeset', + 'cc_compiler', + 'cc_compile_by', + 'cc_compile_domain', + 'cc_compile_date', + ] + + return [[k, info[k]] for k in ITEM_ORDER] + def instance(): global inst diff --git a/tools/xm-test/lib/XmTestReport/OSReport.py b/tools/xm-test/lib/XmTestReport/OSReport.py index c1d94b9774..dff20399e2 100644 --- a/tools/xm-test/lib/XmTestReport/OSReport.py +++ b/tools/xm-test/lib/XmTestReport/OSReport.py @@ -97,7 +97,7 @@ class Machine: "cores_per_socket" : "Unknown", "threads_per_core" : "Unknown", "cpu_mhz" : "Unknown", - "memory" : "Unknown"} + "total_memory" : "Unknown"} xen = self.__getXenInfo(xenValues) cpu = self.__getCpuInfo(cpuValues)