From: Juergen Gross Subject: [PATCH] Add xl python bindings for cpumap Date: Mon, 22 Nov 2010 13:24:07 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5947289441277648305==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============5947289441277648305== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Signed-off-by: juergen.gross@ts.fujitsu.com 1 file changed, 21 insertions(+), 2 deletions(-) tools/python/xen/lowlevel/xl/xl.c | 23 +++++++++++++++++++++-- --===============5947289441277648305== Content-Type: text/x-patch; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=xen-work.patch # 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@ts.fujitsu.com 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) --===============5947289441277648305== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============5947289441277648305==--