[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 4 of 5] Add keyword 'all' to vcpu-pin


  • To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • From: Ryan Harper <ryanh@xxxxxxxxxx>
  • Date: Wed, 16 Aug 2006 15:49:38 -0500
  • Delivery-date: Wed, 16 Aug 2006 13:50:57 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

4 files changed, 24 insertions(+), 8 deletions(-)
docs/man/xm.pod.1                         |    4 +++-
tools/python/xen/xend/XendDomain.py       |   17 +++++++++++++----
tools/python/xen/xend/server/SrvDomain.py |    2 +-
tools/python/xen/xm/main.py               |    9 +++++++--


# HG changeset patch
# User Ryan Harper <ryanh@xxxxxxxxxx>
# Date 1155579483 18000
# Node ID 556a93b6cca9b99b2ad0a2d6dcc24dc1a3a581ad
# Parent  734570be7e0592f20e6f97089c89541feed03abc
Add keyword 'all' to vcpu-pin

diff -r 734570be7e05 -r 556a93b6cca9 docs/man/xm.pod.1
--- a/docs/man/xm.pod.1 Mon Aug 14 13:17:03 2006 -0500
+++ b/docs/man/xm.pod.1 Mon Aug 14 13:18:03 2006 -0500
@@ -393,7 +393,9 @@ specified, VCPU information for all doma
 
 =item B<vcpu-pin> I<domain-id> I<vcpu> I<cpus>
 
-Pins the the VCPU to only run on the specific CPUs.  
+Pins the the VCPU to only run on the specific CPUs.  The keyword
+I<all> can be used to apply the I<cpus> list to all VCPUs in the
+domain.
 
 Normally VCPUs can float between available CPUs whenever Xen deems a
 different run state is appropriate.  Pinning can be used to restrict
diff -r 734570be7e05 -r 556a93b6cca9 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Mon Aug 14 13:17:03 2006 -0500
+++ b/tools/python/xen/xend/XendDomain.py       Mon Aug 14 13:18:03 2006 -0500
@@ -466,10 +466,19 @@ class XendDomain:
         if not dominfo:
             raise XendInvalidDomain(str(domid))
 
-        try:
-            return xc.vcpu_setaffinity(dominfo.getDomid(), vcpu, cpumap)
-        except Exception, ex:
-            raise XendError(str(ex))
+        # if vcpu is keyword 'all', apply the cpumap to all vcpus
+        vcpus = [ vcpu ]
+        if str(vcpu).lower() == "all":
+            vcpus = range(0, int(dominfo.getVCpuCount()))
+       
+        # set the same cpumask for all vcpus
+        rc = 0
+        for v in vcpus:
+            try:
+                rc = xc.vcpu_setaffinity(dominfo.getDomid(), int(v), cpumap)
+            except Exception, ex:
+                raise XendError(str(ex))
+        return rc
 
     def domain_cpu_bvt_set(self, domid, mcuadv, warpback, warpvalue, warpl,
                            warpu):
diff -r 734570be7e05 -r 556a93b6cca9 tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Mon Aug 14 13:17:03 2006 -0500
+++ b/tools/python/xen/xend/server/SrvDomain.py Mon Aug 14 13:18:03 2006 -0500
@@ -97,7 +97,7 @@ class SrvDomain(SrvDir):
     def op_pincpu(self, _, req):
         fn = FormFn(self.xd.domain_pincpu,
                     [['dom', 'int'],
-                     ['vcpu', 'int'],
+                     ['vcpu', 'str'],
                      ['cpumap', 'str']])
         val = fn(req.args, {'dom': self.dom.domid})
         return val
diff -r 734570be7e05 -r 556a93b6cca9 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Mon Aug 14 13:17:03 2006 -0500
+++ b/tools/python/xen/xm/main.py       Mon Aug 14 13:18:03 2006 -0500
@@ -613,7 +613,12 @@ def cpu_make_map(cpulist):
             for i in range(int(x),int(y)+1):
                 cpus.append(int(i))
         else:
-            cpus.append(int(c))
+            # remove this element from the list
+            if c[0] == '^':
+                cpus = [x for x in cpus if x != int(c[1:])]
+            else:
+                cpus.append(int(c))
+
     cpus.sort()
     return cpus
 
@@ -621,7 +626,7 @@ def xm_vcpu_pin(args):
     arg_check(args, "vcpu-pin", 3)
 
     dom  = args[0]
-    vcpu = int(args[1])
+    vcpu = args[1]
     cpumap = cpu_make_map(args[2])
     
     server.xend.domain.pincpu(dom, vcpu, cpumap)

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.