Don't complain about name non-uniqueness if one domain is dying. This happens
authorEwan Mellor <ewan@xensource.com>
Wed, 8 Nov 2006 12:56:45 +0000 (12:56 +0000)
committerEwan Mellor <ewan@xensource.com>
Wed, 8 Nov 2006 12:56:45 +0000 (12:56 +0000)
across a reboot regularly.  Inside _refresh, there is the occasion for new
domains to appear, if an existing domain reboots itself.  In this case, we
need to get the list of running domains from Xen again.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/XendDomainInfo.py

index 2b37145d54e136ba8ab93c8b1a64eb6354b0446b..8f76952e64823d8a8c70cd77b3ee51b82664319a 100644 (file)
@@ -357,27 +357,29 @@ class XendDomain:
         either xenstore has changed or when a method requires
         up to date information (like uptime, cputime stats).
 
+        Expects to be protected by the domains_lock.
+
         @rtype: None
         """
-        self.domains_lock.acquire()
-        try:
-            # update information for all running domains
-            # - like cpu_time, status, dying, etc.
-            running = self._running_domains()
-            for dom in running:
-                domid = dom['domid']
-                if domid in self.domains:
-                    self.domains[domid].update(dom)
 
-            # remove domains that are not running from active
-            # domain list
-            running_domids = [d['domid'] for d in running]
-            for domid, dom in self.domains.items():
-                if domid not in running_domids and domid != DOM0_ID:
-                    self._remove_domain(dom, domid)
-                    
-        finally:
-            self.domains_lock.release()
+        # update information for all running domains
+        # - like cpu_time, status, dying, etc.
+        running = self._running_domains()
+        for dom in running:
+            domid = dom['domid']
+            if domid in self.domains:
+                self.domains[domid].update(dom)
+
+        # remove domains that are not running from active domain list.
+        # The list might have changed by now, because the update call may
+        # cause new domains to be added, if the domain has rebooted.  We get
+        # the list again.
+        running = self._running_domains()
+        running_domids = [d['domid'] for d in running]
+        for domid, dom in self.domains.items():
+            if domid not in running_domids and domid != DOM0_ID:
+                self._remove_domain(dom, domid)
+
 
     def _add_domain(self, info):
         """Add the given domain entry to this instance's internal cache.
@@ -1228,8 +1230,12 @@ class XendDomain:
             elif cap < 0 or cap > dominfo.getVCpuCount() * 100:
                 raise XendError("cap is out of range")
 
+            assert type(weight) == int
+            assert type(cap) == int
+
             return xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap)
         except Exception, ex:
+            log.exception(ex)
             raise XendError(str(ex))
 
     def domain_maxmem_set(self, domid, mem):
index 64d22fbb7a6af2e94e767b4164749c4137a91949..1231db6dc88db5eec946e86338ca786da9f6702c 100644 (file)
@@ -1353,8 +1353,6 @@ class XendDomainInfo:
             except:
                 log.exception("Removing domain path failed.")
 
-            self.info['dying'] = 0
-            self.info['shutdown'] = 0
             self._stateSet(DOM_STATE_HALTED)
         finally:
             self.refresh_shutdown_lock.release()
@@ -1626,7 +1624,7 @@ class XendDomainInfo:
             raise VmError('Invalid VM Name')
 
         dom =  XendDomain.instance().domain_lookup_nr(name)
-        if dom and dom != self:
+        if dom and dom != self and not dom.info['dying']:
             raise VmError("VM name '%s' already exists" % name)