All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Harper <ryanh@us.ibm.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] tools: convert cpumap bitmap to list
Date: Wed, 19 Oct 2005 17:45:07 -0500	[thread overview]
Message-ID: <20051019224507.GC2004@us.ibm.com> (raw)

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())

             reply	other threads:[~2005-10-19 22:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-19 22:45 Ryan Harper [this message]
2005-10-20 10:44 ` [PATCH] tools: convert cpumap bitmap to list 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051019224507.GC2004@us.ibm.com \
    --to=ryanh@us.ibm.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.