All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Harper <ryanh@us.ibm.com>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: [PATCH] build cpumap from list of ints
Date: Fri, 21 Oct 2005 12:52:16 -0500	[thread overview]
Message-ID: <20051021175216.GA5159@us.ibm.com> (raw)
In-Reply-To: <d991b1090117f3d765ca59d183a7fe86@cl.cam.ac.uk>

* Keir Fraser <Keir.Fraser@cl.cam.ac.uk> [2005-10-21 10:00]:
> 
> On 21 Oct 2005, at 15:03, Ryan Harper wrote:
> 
> >I'm not sure what to do about the python binding in pincpu.  As you
> >mentioned, python2.2 doesn't support 'K' (unsigned long long), but it
> >can support 'L' (long long).
> 
> The usage examples you posted look fine to me.
> 
> As for pincpu: I think it should accept a list of integers and turn 
> that into a cpumap_t (i.e., do the reverse operation of what we do in 
> vcpu_getinfo).
> 
> Then python code does not see cpumap bitmaps at all. Just lists of 
> integers.

This patch removes the assembly of the cpumap_t from python.  xm/xend
only pass around a list of ints, or a string representation of the list
as xc_domain_pincpu now constructs the cpumap from the list if it is
passed.

-- 
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         |   19 ++++++++++++++-----
 xend/XendClient.py       |    2 +-
 xend/XendDomain.py       |    9 ++++++---
 xend/server/SrvDomain.py |    2 +-
 xm/main.py               |    6 +-----
 5 files changed, 23 insertions(+), 15 deletions(-)

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
---
diff -r 3fea5df6d4cd tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c	Fri Oct 21 15:03:28 2005
+++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Oct 21 11:55:55 2005
@@ -204,14 +204,23 @@
     XcObject *xc = (XcObject *)self;
 
     uint32_t dom;
-    int vcpu = 0;
+    int vcpu = 0, i;
     cpumap_t cpumap = ~0ULL;
+    PyObject *list;
 
     static char *kwd_list[] = { "dom", "vcpu", "cpumap", NULL };
 
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|il", kwd_list, 
-                                      &dom, &vcpu, &cpumap) )
-        return NULL;
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|iO", kwd_list, 
+                                      &dom, &vcpu, &list) )
+        return NULL;
+
+    /* see if a list was passed  */
+    if(PyList_Check(list)) {
+        /* clear the map for building the value from list */
+        cpumap = 0ULL;
+        for ( i = 0; i < PyList_Size(list); i++ ) 
+            cpumap |= (cpumap_t)(1 << PyInt_AsLong(PyList_GetItem(list, i)));
+    } 
 
     if ( xc_domain_pincpu(xc->xc_handle, dom, vcpu, cpumap) != 0 )
         return PyErr_SetFromErrno(xc_error);
@@ -900,7 +909,7 @@
       "Pin a VCPU to a specified set CPUs.\n"
       " dom [int]:     Identifier of domain to which VCPU belongs.\n"
       " vcpu [int, 0]: VCPU being pinned.\n"
-      " cpumap [int, -1]: Bitmap of usable CPUs.\n\n"
+      " cpumap [list, []]: list of usable CPUs.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
     { "domain_setcpuweight", 
diff -r 3fea5df6d4cd tools/python/xen/xend/XendClient.py
--- a/tools/python/xen/xend/XendClient.py	Fri Oct 21 15:03:28 2005
+++ b/tools/python/xen/xend/XendClient.py	Fri Oct 21 11:55:55 2005
@@ -258,7 +258,7 @@
         return self.xendPost(self.domainurl(id),
                              {'op'      : 'pincpu',
                               'vcpu'    : vcpu,
-                              'cpumap'  : cpumap })
+                              'cpumap'  : str(cpumap) })
 
     def xend_domain_cpu_bvt_set(self, id, mcuadv, warpback, warpvalue, warpl, warpu):
         return self.xendPost(self.domainurl(id),
diff -r 3fea5df6d4cd tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py	Fri Oct 21 15:03:28 2005
+++ b/tools/python/xen/xend/XendDomain.py	Fri Oct 21 11:55:55 2005
@@ -412,9 +412,12 @@
     def domain_pincpu(self, domid, vcpu, cpumap):
         """Set which cpus vcpu can use
 
-        @param cpumap:  bitmap of usable cpus
-        """
-        dominfo = self.domain_lookup(domid)
+        @param cpumap:  string repr of list of usable cpus
+        """
+        dominfo = self.domain_lookup(domid)
+        # convert cpumap string into a list of ints
+        cpumap = map(lambda x: int(x),
+                     cpumap.replace("[", "").replace("]", "").split(","))
         try:
             return xc.domain_pincpu(dominfo.getDomid(), vcpu, cpumap)
         except Exception, ex:
diff -r 3fea5df6d4cd tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py	Fri Oct 21 15:03:28 2005
+++ b/tools/python/xen/xend/server/SrvDomain.py	Fri Oct 21 11:55:55 2005
@@ -89,7 +89,7 @@
         fn = FormFn(self.xd.domain_pincpu,
                     [['dom', 'int'],
                      ['vcpu', 'int'],
-                     ['cpumap', 'int']])
+                     ['cpumap', 'str']])
         val = fn(req.args, {'dom': self.dom.domid})
         return val
 
diff -r 3fea5df6d4cd tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py	Fri Oct 21 15:03:28 2005
+++ b/tools/python/xen/xm/main.py	Fri Oct 21 11:55:55 2005
@@ -411,7 +411,6 @@
 
 def cpu_make_map(cpulist):
     cpus = []
-    cpumap = 0
     for c in cpulist.split(','):
         if c.find('-') != -1:
             (x,y) = c.split('-')
@@ -420,10 +419,7 @@
         else:
             cpus.append(int(c))
     cpus.sort()
-    for c in cpus:
-        cpumap = cpumap | 1<<c
-
-    return cpumap
+    return cpus
 
 def xm_vcpu_pin(args):
     arg_check(args, 3, "vcpu-pin")

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

      parent reply	other threads:[~2005-10-21 17:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20051021175216.GA5159@us.ibm.com \
    --to=ryanh@us.ibm.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --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.