Topology-info sysctl cleanups.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
This commit is contained in:
Keir Fraser committed 2010-04-13 09:38:54 +01:00
1 parent 81f77532b5
commit 645f5ea7cb
8 files changed
+77 -195

No files matched your search

+31 -13
View File
@@ -1191,7 +1191,7 @@ static PyObject *pyxc_physinfo(XcObject *self)
static PyObject *pyxc_topologyinfo(XcObject *self)
{
#define MAX_CPU_INDEX 255
xc_topologyinfo_t tinfo;
xc_topologyinfo_t tinfo = { 0 };
int i, max_cpu_index;
PyObject *ret_obj;
PyObject *cpu_to_core_obj, *cpu_to_socket_obj, *cpu_to_node_obj;
@@ -1199,7 +1199,6 @@ static PyObject *pyxc_topologyinfo(XcObject *self)
xc_cpu_to_socket_t socketmap[MAX_CPU_INDEX + 1];
xc_cpu_to_node_t nodemap[MAX_CPU_INDEX + 1];
set_xen_guest_handle(tinfo.cpu_to_core, coremap);
set_xen_guest_handle(tinfo.cpu_to_socket, socketmap);
set_xen_guest_handle(tinfo.cpu_to_node, nodemap);
@@ -1218,19 +1217,38 @@ static PyObject *pyxc_topologyinfo(XcObject *self)
cpu_to_node_obj = PyList_New(0);
for ( i = 0; i < max_cpu_index; i++ )
{
PyObject *pyint;
if ( coremap[i] == INVALID_TOPOLOGY_ID )
{
PyList_Append(cpu_to_core_obj, Py_None);
}
else
{
PyObject *pyint = PyInt_FromLong(coremap[i]);
PyList_Append(cpu_to_core_obj, pyint);
Py_DECREF(pyint);
}
pyint = PyInt_FromLong(coremap[i]);
PyList_Append(cpu_to_core_obj, pyint);
Py_DECREF(pyint);
if ( socketmap[i] == INVALID_TOPOLOGY_ID )
{
PyList_Append(cpu_to_socket_obj, Py_None);
}
else
{
PyObject *pyint = PyInt_FromLong(socketmap[i]);
PyList_Append(cpu_to_socket_obj, pyint);
Py_DECREF(pyint);
}
pyint = PyInt_FromLong(socketmap[i]);
PyList_Append(cpu_to_socket_obj, pyint);
Py_DECREF(pyint);
pyint = PyInt_FromLong(nodemap[i]);
PyList_Append(cpu_to_node_obj, pyint);
Py_DECREF(pyint);
if ( nodemap[i] == INVALID_TOPOLOGY_ID )
{
PyList_Append(cpu_to_node_obj, Py_None);
}
else
{
PyObject *pyint = PyInt_FromLong(nodemap[i]);
PyList_Append(cpu_to_node_obj, pyint);
Py_DECREF(pyint);
}
}
ret_obj = Py_BuildValue("{s:i}", "max_cpu_index", max_cpu_index);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.