ia64/xen-unstable

changeset 12315:69d8263d5f85

Don't complain about name non-uniqueness if one domain is dying. This happens
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>
author Ewan Mellor <ewan@xensource.com>
date Wed Nov 08 12:56:45 2006 +0000 (2006-11-08)
parents 40e586047ead
children b86fe3d23f05
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Wed Nov 08 12:26:34 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Wed Nov 08 12:56:45 2006 +0000
     1.3 @@ -357,27 +357,29 @@ class XendDomain:
     1.4          either xenstore has changed or when a method requires
     1.5          up to date information (like uptime, cputime stats).
     1.6  
     1.7 +        Expects to be protected by the domains_lock.
     1.8 +
     1.9          @rtype: None
    1.10          """
    1.11 -        self.domains_lock.acquire()
    1.12 -        try:
    1.13 -            # update information for all running domains
    1.14 -            # - like cpu_time, status, dying, etc.
    1.15 -            running = self._running_domains()
    1.16 -            for dom in running:
    1.17 -                domid = dom['domid']
    1.18 -                if domid in self.domains:
    1.19 -                    self.domains[domid].update(dom)
    1.20 +
    1.21 +        # update information for all running domains
    1.22 +        # - like cpu_time, status, dying, etc.
    1.23 +        running = self._running_domains()
    1.24 +        for dom in running:
    1.25 +            domid = dom['domid']
    1.26 +            if domid in self.domains:
    1.27 +                self.domains[domid].update(dom)
    1.28  
    1.29 -            # remove domains that are not running from active
    1.30 -            # domain list
    1.31 -            running_domids = [d['domid'] for d in running]
    1.32 -            for domid, dom in self.domains.items():
    1.33 -                if domid not in running_domids and domid != DOM0_ID:
    1.34 -                    self._remove_domain(dom, domid)
    1.35 -                    
    1.36 -        finally:
    1.37 -            self.domains_lock.release()
    1.38 +        # remove domains that are not running from active domain list.
    1.39 +        # The list might have changed by now, because the update call may
    1.40 +        # cause new domains to be added, if the domain has rebooted.  We get
    1.41 +        # the list again.
    1.42 +        running = self._running_domains()
    1.43 +        running_domids = [d['domid'] for d in running]
    1.44 +        for domid, dom in self.domains.items():
    1.45 +            if domid not in running_domids and domid != DOM0_ID:
    1.46 +                self._remove_domain(dom, domid)
    1.47 +
    1.48  
    1.49      def _add_domain(self, info):
    1.50          """Add the given domain entry to this instance's internal cache.
    1.51 @@ -1228,8 +1230,12 @@ class XendDomain:
    1.52              elif cap < 0 or cap > dominfo.getVCpuCount() * 100:
    1.53                  raise XendError("cap is out of range")
    1.54  
    1.55 +            assert type(weight) == int
    1.56 +            assert type(cap) == int
    1.57 +
    1.58              return xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap)
    1.59          except Exception, ex:
    1.60 +            log.exception(ex)
    1.61              raise XendError(str(ex))
    1.62  
    1.63      def domain_maxmem_set(self, domid, mem):
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Nov 08 12:26:34 2006 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Nov 08 12:56:45 2006 +0000
     2.3 @@ -1353,8 +1353,6 @@ class XendDomainInfo:
     2.4              except:
     2.5                  log.exception("Removing domain path failed.")
     2.6  
     2.7 -            self.info['dying'] = 0
     2.8 -            self.info['shutdown'] = 0
     2.9              self._stateSet(DOM_STATE_HALTED)
    2.10          finally:
    2.11              self.refresh_shutdown_lock.release()
    2.12 @@ -1626,7 +1624,7 @@ class XendDomainInfo:
    2.13              raise VmError('Invalid VM Name')
    2.14  
    2.15          dom =  XendDomain.instance().domain_lookup_nr(name)
    2.16 -        if dom and dom != self:
    2.17 +        if dom and dom != self and not dom.info['dying']:
    2.18              raise VmError("VM name '%s' already exists" % name)
    2.19          
    2.20