# HG changeset patch # User Juergen Gross # Date 1290428619 -3600 # Node ID eb50c4e522e19b5b1a0fcddb50319c31ea589df9 # Parent 117d82dcd6ba785a702e2d0cfdb93642d84da1b9 Add xl python bindings for cpumap Signed-off-by: juergen.gross@xxxxxxxxxxxxxx diff -r 117d82dcd6ba -r eb50c4e522e1 tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Fri Nov 19 18:55:18 2010 +0000 +++ b/tools/python/xen/lowlevel/xl/xl.c Mon Nov 22 13:23:39 2010 +0100 @@ -214,7 +214,14 @@ int attrib__libxl_cpumap_set(PyObject *v, libxl_cpumap *pptr) { - return -1; + int i; + long cpu; + + for (i = 0; i < PyList_Size(v); i++) { + cpu = PyInt_AsLong(PyList_GetItem(v, i)); + libxl_cpumap_set(pptr, cpu); + } + return 0; } int attrib__libxl_domain_build_state_ptr_set(PyObject *v, libxl_domain_build_state **pptr) @@ -264,7 +271,19 @@ PyObject *attrib__libxl_cpumap_get(libxl_cpumap *pptr) { - return NULL; + PyObject *cpulist = NULL; + int i; + + cpulist = PyList_New(0); + libxl_for_each_cpu(i, *pptr) { + if ( libxl_cpumap_test(pptr, i) ) { + PyObject* pyint = PyInt_FromLong(i); + + PyList_Append(cpulist, pyint); + Py_DECREF(pyint); + } + } + return cpulist; } PyObject *attrib__libxl_domain_build_state_ptr_get(libxl_domain_build_state **pptr)