diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 2b37145d54..8f76952e64 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -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): diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 64d22fbb7a..1231db6dc8 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -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)