Fix xm vcpu-pin for inactive managed domains
PATCH 1/1 Fix xm vcpu-pin for inactive managed domains
Hi,
We cannot currently change cpu affinity definitions of inactive managed domains by xm vcpu-pin command.
# xm vcpu-list vm1 Name ID VCPU CPU State Time(s) CPU Affinity vm1 0 0.0 any cpu vm1 1 0.0 any cpu # xm vcpu-pin vm1 all 2,3 Error: Cannot pin vcpu: 0 to cpu: [2, 3] - an integer is required Usage: xm vcpu-pin <Domain> <VCPU|all> <CPUs|all>
Set which CPUs a VCPU can use.
This patch enables changing cpu affinity definitions of inactive managed domains.
However, we cannot change cpu affinity definitions to each vcpu because we cannot currently define cpu affinity definitions to each vcpu to domain configuration definitions. Therefore, we need to specify 'all' to VCPU argument of xm vcpu-pin command.
# xm vcpu-list vm1 Name ID VCPU CPU State Time(s) CPU Affinity vm1 0 0.0 any cpu vm1 1 0.0 any cpu # xm vcpu-pin vm1 all 0,1 # xm vcpu-list vm1 Name ID VCPU CPU State Time(s) CPU Affinity vm1 0 0.0 0-1 vm1 1 0.0 0-1 # xm vcpu-pin vm1 all 2,3 # xm vcpu-list vm1 Name ID VCPU CPU State Time(s) CPU Affinity vm1 0 0.0 2-3 vm1 1 0.0 2-3 # xm vcpu-pin vm1 0 0,1 Error: Must specify 'all' to VCPU for inactive managed domains Usage: xm vcpu-pin <Domain> <VCPU|all> <CPUs|all>
Set which CPUs a VCPU can use.
Signed-off-by Masaki Kanno <[email protected]>
Best regards,
Kan
tools/python/xen/xend/XendDomain.py +17 -7
@@ -1364,13 +1364,23 @@ class XendDomain: # 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: - log.exception(ex) - raise XendError("Cannot pin vcpu: %s to cpu: %s - %s" % \ - (v, cpumap, str(ex))) + if dominfo._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED): + for v in vcpus: + try: + rc = xc.vcpu_setaffinity(dominfo.getDomid(), int(v), cpumap) + except Exception, ex: + log.exception(ex) + raise XendError("Cannot pin vcpu: %s to cpu: %s - %s" % \ + (v, cpumap, str(ex))) + else: + # FIXME: if we could define cpu affinity definitions to + # each vcpu, reprogram the following processing. + if str(vcpu).lower() != "all": + raise XendError("Must specify 'all' to VCPU " + "for inactive managed domains") + dominfo.setCpus(cpumap) + self.managed_config_save(dominfo) + return rc def domain_cpu_sedf_set(self, domid, period, slice_, latency, extratime,
tools/python/xen/xend/XendDomainInfo.py +6 -0
@@ -1394,6 +1394,12 @@ class XendDomainInfo: def setResume(self, isresume): self._resume = isresume + def getCpus(self): + return self.info['cpus'] + + def setCpus(self, cpumap): + self.info['cpus'] = cpumap + def getCap(self): return self.info['vcpus_params']['cap']
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel