direct-io.hg

changeset 12317:a14732833603

[XEND] Fix bug with managed domains not having their state updated.

Also added some protection against corrupted sxp configuration files.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Nov 09 13:16:55 2006 +0000 (2006-11-09)
parents 023aa2926e79
children 0b8f79563bcd
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Nov 09 12:38:12 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Nov 09 13:16:55 2006 +0000
     1.3 @@ -167,10 +167,11 @@ class XendDomain:
     1.4  
     1.5              # add all managed domains as dormant domains.
     1.6              for dom in managed:
     1.7 -                dom_uuid = dom.get('uuid', uuid.createString())
     1.8 -                dom['uuid'] = dom_uuid
     1.9 +                dom_uuid = dom.get('uuid')
    1.10 +                if not dom_uuid:
    1.11 +                    continue
    1.12 +                
    1.13                  dom_name = dom.get('name', 'Domain-%s' % dom_uuid)
    1.14 -                
    1.15                  try:
    1.16                      running_dom = self.domain_lookup_nr(dom_name)
    1.17                      if not running_dom:
    1.18 @@ -304,6 +305,11 @@ class XendDomain:
    1.19              try:
    1.20                  cfg_file = self._managed_config_path(dom_uuid)
    1.21                  cfg = XendConfig(filename = cfg_file)
    1.22 +                if cfg.get('uuid') != dom_uuid:
    1.23 +                    # something is wrong with the SXP
    1.24 +                    log.error("UUID mismatch in stored configuration: %s" %
    1.25 +                              cfg_file)
    1.26 +                    continue
    1.27                  doms.append(cfg)
    1.28              except Exception:
    1.29                  log.exception('Unable to open or parse config.sxp: %s' % \
    1.30 @@ -387,7 +393,7 @@ class XendDomain:
    1.31  
    1.32  
    1.33      def _add_domain(self, info):
    1.34 -        """Add the given domain entry to this instance's internal cache.
    1.35 +        """Add a domain to the list of running domains
    1.36          
    1.37          @requires: Expects to be protected by the domains_lock.
    1.38          @param info: XendDomainInfo of a domain to be added.
    1.39 @@ -397,7 +403,7 @@ class XendDomain:
    1.40          self.domains[info.getDomid()] = info
    1.41  
    1.42      def _remove_domain(self, info, domid = None):
    1.43 -        """Remove the given domain from this instance's internal cache.
    1.44 +        """Remove the domain from the list of running domains
    1.45          
    1.46          @requires: Expects to be protected by the domains_lock.
    1.47          @param info: XendDomainInfo of a domain to be removed.
    1.48 @@ -849,7 +855,7 @@ class XendDomain:
    1.49                  raise XendError("Domain is already running")
    1.50              
    1.51              dominfo.start(is_managed = True)
    1.52 -
    1.53 +            self._add_domain(dominfo)
    1.54          finally:
    1.55              self.domains_lock.release()
    1.56          
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Nov 09 12:38:12 2006 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Nov 09 13:16:55 2006 +0000
     2.3 @@ -1667,7 +1667,12 @@ class XendDomainInfo:
     2.4      # ----------------------------------------------------------------
     2.5  
     2.6      def get_uuid(self):
     2.7 -        return self.info['uuid']
     2.8 +        dom_uuid = self.info.get('uuid')
     2.9 +        if not dom_uuid: # if it doesn't exist, make one up
    2.10 +            dom_uuid = uuid.createString()
    2.11 +            self.info['uuid'] = dom_uuid
    2.12 +        return dom_uuid
    2.13 +    
    2.14      def get_memory_static_max(self):
    2.15          return self.info['maxmem']
    2.16      def get_memory_static_min(self):