ia64/xen-unstable

changeset 11629:184884cfaa0b

Adds support for the keyword 'all' to the vcpu-pin operation.
Using 'all' in place of a specific vcpu will apply the cpumask
to all vcpus in the domain.
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Tue Sep 26 12:17:51 2006 +0100 (2006-09-26)
parents bdf3bddc97e7
children ef41783c664a
files docs/man/xm.pod.1 tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/docs/man/xm.pod.1	Tue Sep 26 08:36:39 2006 +0100
     1.2 +++ b/docs/man/xm.pod.1	Tue Sep 26 12:17:51 2006 +0100
     1.3 @@ -393,7 +393,9 @@ specified, VCPU information for all doma
     1.4  
     1.5  =item B<vcpu-pin> I<domain-id> I<vcpu> I<cpus>
     1.6  
     1.7 -Pins the the VCPU to only run on the specific CPUs.  
     1.8 +Pins the the VCPU to only run on the specific CPUs.  The keyword
     1.9 +I<all> can be used to apply the I<cpus> list to all VCPUs in the
    1.10 +domain.
    1.11  
    1.12  Normally VCPUs can float between available CPUs whenever Xen deems a
    1.13  different run state is appropriate.  Pinning can be used to restrict
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Sep 26 08:36:39 2006 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Sep 26 12:17:51 2006 +0100
     2.3 @@ -487,10 +487,19 @@ class XendDomain:
     2.4          if not dominfo:
     2.5              raise XendInvalidDomain(str(domid))
     2.6  
     2.7 -        try:
     2.8 -            return xc.vcpu_setaffinity(dominfo.getDomid(), vcpu, cpumap)
     2.9 -        except Exception, ex:
    2.10 -            raise XendError(str(ex))
    2.11 +        # if vcpu is keyword 'all', apply the cpumap to all vcpus
    2.12 +        vcpus = [ vcpu ]
    2.13 +        if str(vcpu).lower() == "all":
    2.14 +            vcpus = range(0, int(dominfo.getVCpuCount()))
    2.15 +       
    2.16 +        # set the same cpumask for all vcpus
    2.17 +        rc = 0
    2.18 +        for v in vcpus:
    2.19 +            try:
    2.20 +                rc = xc.vcpu_setaffinity(dominfo.getDomid(), int(v), cpumap)
    2.21 +            except Exception, ex:
    2.22 +                raise XendError(str(ex))
    2.23 +        return rc
    2.24  
    2.25      def domain_cpu_sedf_set(self, domid, period, slice_, latency, extratime,
    2.26                              weight):
     3.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Tue Sep 26 08:36:39 2006 +0100
     3.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Tue Sep 26 12:17:51 2006 +0100
     3.3 @@ -97,7 +97,7 @@ class SrvDomain(SrvDir):
     3.4      def op_pincpu(self, _, req):
     3.5          fn = FormFn(self.xd.domain_pincpu,
     3.6                      [['dom', 'int'],
     3.7 -                     ['vcpu', 'int'],
     3.8 +                     ['vcpu', 'str'],
     3.9                       ['cpumap', 'str']])
    3.10          val = fn(req.args, {'dom': self.dom.domid})
    3.11          return val
     4.1 --- a/tools/python/xen/xm/main.py	Tue Sep 26 08:36:39 2006 +0100
     4.2 +++ b/tools/python/xen/xm/main.py	Tue Sep 26 12:17:51 2006 +0100
     4.3 @@ -759,12 +759,16 @@ def xm_vcpu_pin(args):
     4.4                  for i in range(int(x),int(y)+1):
     4.5                      cpus.append(int(i))
     4.6              else:
     4.7 -                cpus.append(int(c))
     4.8 +                # remove this element from the list
     4.9 +                if c[0] == '^':
    4.10 +                    cpus = [x for x in cpus if x != int(c[1:])]
    4.11 +                else:
    4.12 +                    cpus.append(int(c))
    4.13          cpus.sort()
    4.14          return cpus
    4.15  
    4.16      dom  = args[0]
    4.17 -    vcpu = int(args[1])
    4.18 +    vcpu = args[1]
    4.19      cpumap = cpu_make_map(args[2])
    4.20      
    4.21      server.xend.domain.pincpu(dom, vcpu, cpumap)