mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
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>
This commit is contained in:
1 parent
9d72feba41
commit
fa45226f84
3 files changed
+48
-26
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||