[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] tools: Add xl python bindings for cpumap



# HG changeset patch
# User Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
# Date 1290540909 0
# Node ID 0c2b7a185ad130060b36473ea83b7610c8fb23e0
# Parent  6557d6f2c1316157af7ea91f4615ac97307f9504
tools: Add xl python bindings for cpumap

Signed-off-by: juergen.gross@xxxxxxxxxxxxxx
---
 tools/python/xen/lowlevel/xl/xl.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff -r 6557d6f2c131 -r 0c2b7a185ad1 tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c Tue Nov 23 19:33:30 2010 +0000
+++ b/tools/python/xen/lowlevel/xl/xl.c Tue Nov 23 19:35:09 2010 +0000
@@ -214,7 +214,14 @@ int attrib__libxl_cpuid_policy_list_set(
 
 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_cpuid_policy_lis
 
 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)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.