All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: convert cpumap bitmap to list
@ 2005-10-19 22:45 Ryan Harper
  2005-10-20 10:44 ` Keir Fraser
  0 siblings, 1 reply; 11+ messages in thread
From: Ryan Harper @ 2005-10-19 22:45 UTC (permalink / raw)
  To: xen-devel

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@us.ibm.com


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@us.ibm.com>
---
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())

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-10-21 17:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-19 22:45 [PATCH] tools: convert cpumap bitmap to list Ryan Harper
2005-10-20 10:44 ` Keir Fraser
2005-10-20 15:24   ` Ryan Harper
2005-10-20 16:03     ` Keir Fraser
2005-10-20 16:23       ` Ryan Harper
2005-10-20 20:10         ` Keir Fraser
2005-10-21 14:03           ` Ryan Harper
2005-10-21 15:04             ` Keir Fraser
2005-10-21 15:02               ` Ryan Harper
2005-10-21 16:59               ` [PATCH] build cpumap from list of ints Ryan Harper
2005-10-21 17:52               ` Ryan Harper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.