* Keir Fraser <Keir.Fraser@xxxxxxxxxxxx> [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@xxxxxxxxxx
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@xxxxxxxxxx>
---
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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|