ia64/xen-unstable

changeset 12330:023aa2926e79

[XEND] Fix domain_lookup_nr to check managed_domains too.

Bug introduced when moving managed domains out of self.domains caused
domain_lookup_nr ignoring managed domains.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Nov 09 12:38:12 2006 +0000 (2006-11-09)
parents 33ae8ae8693c
children a14732833603
files tools/python/xen/xend/XendDomain.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Nov 09 12:36:20 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Nov 09 12:38:12 2006 +0000
     1.3 @@ -57,10 +57,10 @@ DOM0_ID   = 0
     1.4  class XendDomain:
     1.5      """Index of all domains. Singleton.
     1.6  
     1.7 -    @ivar domains: map of domains indexed by UUID Strings
     1.8 +    @ivar domains: map of domains indexed by domid
     1.9      @type domains: dict of XendDomainInfo
    1.10 -    @ivar managed_domains: uuid of domains that are managed by Xend
    1.11 -    @type managed_domains: list of (uuids, dom_name)
    1.12 +    @ivar managed_domains: domains that are not running and managed by Xend
    1.13 +    @type managed_domains: dict of XendDomainInfo indexed by uuid
    1.14      @ivar domains_lock: lock that must be held when manipulating self.domains
    1.15      @type domains_lock: threaading.RLock
    1.16      @ivar _allow_new_domains: Flag to set that allows creating of new domains.
    1.17 @@ -484,6 +484,11 @@ class XendDomain:
    1.18              if match:
    1.19                  return match[0]
    1.20  
    1.21 +            match = [dom for dom in self.managed_domains.values() \
    1.22 +                     if dom.getName() == domid]
    1.23 +            if match:
    1.24 +                return match[0]
    1.25 +
    1.26              # lookup by id
    1.27              try:
    1.28                  if int(domid) in self.domains:
    1.29 @@ -491,6 +496,16 @@ class XendDomain:
    1.30              except ValueError:
    1.31                  pass
    1.32  
    1.33 +            # lookup by uuid for running domains
    1.34 +            match = [dom for dom in self.domains.values() \
    1.35 +                     if dom.get_uuid() == domid]
    1.36 +            if match:
    1.37 +                return match[0]
    1.38 +
    1.39 +            # lookup by uuid for inactive managed domains 
    1.40 +            if domid in self.managed_domains:
    1.41 +                return self.managed_domains[domid]
    1.42 +
    1.43              return None
    1.44          finally:
    1.45              self.domains_lock.release()