ia64/xen-unstable

changeset 7675:eafd932231ae

Rearrange restart logic so that a failure to restart a domain does not cause
cascading secondary errors. Fixes bug #384.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Tue Nov 08 03:07:57 2005 +0100 (2005-11-08)
parents f2202af64023
children 7e3faea076ec
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Nov 08 02:51:34 2005 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Nov 08 03:07:57 2005 +0100
     1.3 @@ -90,6 +90,8 @@ ZOMBIE_PREFIX = 'Zombie-'
     1.4  """Minimum time between domain restarts in seconds."""
     1.5  MINIMUM_RESTART_TIME = 20
     1.6  
     1.7 +RESTART_IN_PROGRESS = 'xend/restart_in_progress'
     1.8 +
     1.9  
    1.10  xc = xen.lowlevel.xc.new()
    1.11  xroot = XendRoot.instance()
    1.12 @@ -1269,14 +1271,14 @@ class XendDomainInfo:
    1.13  
    1.14          config = self.sxpr()
    1.15  
    1.16 -        if self.readVm('xend/restart_in_progress'):
    1.17 +        if self.readVm(RESTART_IN_PROGRESS):
    1.18              log.error('Xend failed during restart of domain %d.  '
    1.19                        'Refusing to restart to avoid loops.',
    1.20                        self.domid)
    1.21              self.destroy()
    1.22              return
    1.23  
    1.24 -        self.writeVm('xend/restart_in_progress', 'True')
    1.25 +        self.writeVm(RESTART_IN_PROGRESS, 'True')
    1.26  
    1.27          now = time.time()
    1.28          rst = self.readVm('xend/previous_restart_time')
    1.29 @@ -1298,26 +1300,28 @@ class XendDomainInfo:
    1.30                  self.preserveForRestart()
    1.31              else:
    1.32                  self.destroyDomain()
    1.33 -                
    1.34 +
    1.35 +            # new_dom's VM will be the same as this domain's VM, except where
    1.36 +            # the rename flag has instructed us to call preserveForRestart.
    1.37 +            # In that case, it is important that we remove the
    1.38 +            # RESTART_IN_PROGRESS node from the new domain, not the old one,
    1.39 +            # once the new one is available.
    1.40 +
    1.41 +            new_dom = None
    1.42              try:
    1.43                  xd = get_component('xen.xend.XendDomain')
    1.44                  new_dom = xd.domain_create(config)
    1.45 -                try:
    1.46 -                    new_dom.unpause()
    1.47 -                except:
    1.48 -                    new_dom.destroy()
    1.49 -                    raise
    1.50 +                new_dom.unpause()
    1.51 +                new_dom.removeVm(RESTART_IN_PROGRESS)
    1.52              except:
    1.53 -                log.exception('Failed to restart domain %d.', self.domid)
    1.54 -        finally:
    1.55 -            # new_dom's VM will be the same as this domain's VM, except where
    1.56 -            # the rename flag has instructed us to call preserveForRestart.
    1.57 -            # In that case, it is important that we use new_dom.removeVm, not
    1.58 -            # self.removeVm.
    1.59 -            new_dom.removeVm('xend/restart_in_progress')
    1.60 -            
    1.61 -        # self.configure_bootloader()
    1.62 -        #        self.exportToDB()
    1.63 +                if new_dom:
    1.64 +                    new_dom.removeVm(RESTART_IN_PROGRESS)
    1.65 +                    new_dom.destroy()
    1.66 +                else:
    1.67 +                    self.removeVm(RESTART_IN_PROGRESS)
    1.68 +                raise
    1.69 +        except:
    1.70 +            log.exception('Failed to restart domain %d.', self.domid)
    1.71  
    1.72  
    1.73      def preserveForRestart(self):