WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] tools: convert cpumap bitmap to list

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] tools: convert cpumap bitmap to list
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Wed, 19 Oct 2005 17:45:07 -0500
Delivery-date: Wed, 19 Oct 2005 22:42:26 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
This patch modifies the lowlevel xc vcpuinfo call to convert a vcpu's
cpumap to a list of int.  XendDomainInfo.py filters the cpumap into a
smaller list that is bound by the number of vcpus allocated to a domain.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@xxxxxxxxxx


diffstat output:
 lowlevel/xc/xc.c       |   21 +++++++++++++++------
 xend/XendDomainInfo.py |    6 +++++-
 xm/main.py             |    4 ++--
 3 files changed, 22 insertions(+), 9 deletions(-)

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
---
diff -r 7c951e3eb5ab tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Wed Oct 19 10:53:00 2005
+++ b/tools/python/xen/lowlevel/xc/xc.c Wed Oct 19 17:35:34 2005
@@ -347,11 +347,11 @@
                                    PyObject *kwds)
 {
     XcObject *xc = (XcObject *)self;
-    PyObject *info_dict;
+    PyObject *info_dict, *cpumap;
 
     uint32_t dom, vcpu = 0;
     xc_vcpuinfo_t info;
-    int rc;
+    int rc, i;
 
     static char *kwd_list[] = { "dom", "vcpu", NULL };
     
@@ -363,14 +363,23 @@
     if ( rc < 0 )
         return PyErr_SetFromErrno(xc_error);
 
-    info_dict = Py_BuildValue("{s:i,s:i,s:i,s:L,s:i,s:i}",
+    info_dict = Py_BuildValue("{s:i,s:i,s:i,s:L,s:i}",
                               "online",   info.online,
                               "blocked",  info.blocked,
                               "running",  info.running,
                               "cpu_time", info.cpu_time,
-                              "cpu",      info.cpu,
-                              "cpumap",   info.cpumap);
-
+                              "cpu",      info.cpu);
+    /* XXX: we should truncate this list by max_vcpu_id+1 instead
+     * of calculating # of bits in cpumap_t. */
+    cpumap = PyList_New(sizeof(cpumap_t)*8);
+    for ( i = 0; i < sizeof(cpumap_t)*8; i++ ) {
+        if ( (1 << i) & info.cpumap )
+            PyList_SetItem(cpumap, i, PyInt_FromLong(i));
+        else
+            PyList_SetItem(cpumap, i, PyInt_FromLong(-1));
+    }
+
+    PyDict_SetItemString(info_dict, "cpumap", cpumap);
     return info_dict;
 }
 
diff -r 7c951e3eb5ab tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Oct 19 10:53:00 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Oct 19 17:35:34 2005
@@ -982,6 +982,9 @@
 
     def getVCPUInfo(self):
         try:
+            def filter_cpumap(map, max):
+                return filter(lambda x: x >= 0, map[0:max])
+
             # We include the domain name and ID, to help xm.
             sxpr = ['domain',
                     ['domid',      self.domid],
@@ -998,7 +1001,8 @@
                              ['running',  info['running']],
                              ['cpu_time', info['cpu_time'] / 1e9],
                              ['cpu',      info['cpu']],
-                             ['cpumap',   info['cpumap']]])
+                             ['cpumap',   filter_cpumap(info['cpumap'],
+                                self.info['vcpus'])]])
 
             return sxpr
 
diff -r 7c951e3eb5ab tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Wed Oct 19 10:53:00 2005
+++ b/tools/python/xen/xm/main.py       Wed Oct 19 17:35:34 2005
@@ -299,7 +299,7 @@
 
             number   = vinfo('number',   int)
             cpu      = vinfo('cpu',      int)
-            cpumap   = vinfo('cpumap',   int)
+            cpumap   = vinfo('cpumap',   list)
             online   = vinfo('online',   int)
             cpu_time = vinfo('cpu_time', float)
             running  = vinfo('running',  int)
@@ -321,7 +321,7 @@
                 s = "--p"
 
             print (
-                "%(name)-32s %(domid)3d  %(number)4d  %(c)3s   %(s)-3s   
%(cpu_time)7.1f  0x%(cpumap)x" %
+                "%(name)-32s %(domid)3d  %(number)4d  %(c)3s   %(s)-3s   
%(cpu_time)7.1f  %(cpumap)s" %
                 locals())
 
 

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