diff options
author | Emmanuel Ackaouy <ack@xensource.com> | 2006-09-26 12:17:51 +0100 |
---|---|---|
committer | Emmanuel Ackaouy <ack@xensource.com> | 2006-09-26 12:17:51 +0100 |
commit | 7ccdaed2edadf9984b520b192682c69daac04bc8 (patch) | |
tree | b03748d4f66b5d26a68acdaefa223d31819e109d | |
parent | 2d5c2b773d963abe359ca6151683b7e72684c9c2 (diff) | |
download | xen-7ccdaed2edadf9984b520b192682c69daac04bc8.tar.gz xen-7ccdaed2edadf9984b520b192682c69daac04bc8.tar.bz2 xen-7ccdaed2edadf9984b520b192682c69daac04bc8.zip |
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>
-rw-r--r-- | docs/man/xm.pod.1 | 4 | ||||
-rw-r--r-- | tools/python/xen/xend/XendDomain.py | 17 | ||||
-rw-r--r-- | tools/python/xen/xend/server/SrvDomain.py | 2 | ||||
-rw-r--r-- | tools/python/xen/xm/main.py | 8 |
4 files changed, 23 insertions, 8 deletions
diff --git a/docs/man/xm.pod.1 b/docs/man/xm.pod.1 index 352eefd158..e7dbbb90f6 100644 --- a/docs/man/xm.pod.1 +++ b/docs/man/xm.pod.1 @@ -393,7 +393,9 @@ specified, VCPU information for all domains will be provided. =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 --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index b434cb1186..0642b3a8cd 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -487,10 +487,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_sedf_set(self, domid, period, slice_, latency, extratime, weight): diff --git a/tools/python/xen/xend/server/SrvDomain.py b/tools/python/xen/xend/server/SrvDomain.py index d369aa68ad..52075340fd 100644 --- a/tools/python/xen/xend/server/SrvDomain.py +++ b/tools/python/xen/xend/server/SrvDomain.py @@ -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 --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index 3e1235091a..c3dba40f8e 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -759,12 +759,16 @@ def xm_vcpu_pin(args): 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 dom = args[0] - vcpu = int(args[1]) + vcpu = args[1] cpumap = cpu_make_map(args[2]) server.xend.domain.pincpu(dom, vcpu, cpumap) |