]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Fix xm vcpu-pin for inactive managed domains
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Mar 2008 16:45:06 +0000 (16:45 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Mar 2008 16:45:06 +0000 (16:45 +0000)
We cannot currently change cpu affinity definitions of inactive
managed domains by xm vcpu-pin command. 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.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
xen-unstable changeset:   17173:a142ddb40b1c77d6b8726a2b57ac324ab74c6d06
xen-unstable date:        Mon Mar 03 11:09:33 2008 +0000

tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/XendDomainInfo.py

index a1590527dbb06f51fe3df4c90d424057dd00f48a..1fc4bf923e27020e434a2cba2acec2844d38610e 100644 (file)
@@ -1300,13 +1300,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,
index ec7d0ff7a1222b11029437098e2da606b277b7eb..d0f683e5854870f283ffdc77dc120da35b763d58 100644 (file)
@@ -1094,6 +1094,12 @@ class XendDomainInfo:
     def getResume(self):
         return str(self._resume)
 
+    def getCpus(self):
+        return self.info['cpus']
+
+    def setCpus(self, cpumap):
+        self.info['cpus'] = cpumap
+
     def getCap(self):
         return self.info.get('cpu_cap', 0)