ia64/xen-unstable

changeset 19546:9e29ba71e169

xend: fix avoidance to restart domain on crash

If a qemu-dm dies immediately (probably by wrong setting),
xend repeats to restart a domain so many times.=20
That causes system overload.

There is already a logic to avoid too early restarting, however,
it might not work. Since xenstore entry 'xend/previous_restart_time'
is volatile. XendDomainInfo.destroy() which removes the entry from
xenstore is called in some places.

Also, this patch prevents too early restarting even at the first
domain creation.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 15 11:23:02 2009 +0100 (2009-04-15)
parents 34dca01addc9
children b2c43b0fba71
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Apr 15 08:40:12 2009 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Apr 15 11:23:02 2009 +0100
     1.3 @@ -514,7 +514,6 @@ class XendDomainInfo:
     1.4          
     1.5          if reason not in DOMAIN_SHUTDOWN_REASONS.values():
     1.6              raise XendError('Invalid reason: %s' % reason)
     1.7 -        self._removeVm('xend/previous_restart_time')
     1.8          self.storeDom("control/shutdown", reason)
     1.9  
    1.10          # HVM domain shuts itself down only if it has PV drivers
    1.11 @@ -2001,20 +2000,13 @@ class XendDomainInfo:
    1.12          old_domid = self.domid
    1.13          self._writeVm(RESTART_IN_PROGRESS, 'True')
    1.14  
    1.15 -        now = time.time()
    1.16 -        rst = self._readVm('xend/previous_restart_time')
    1.17 -        if rst:
    1.18 -            rst = float(rst)
    1.19 -            timeout = now - rst
    1.20 -            if timeout < MINIMUM_RESTART_TIME:
    1.21 -                log.error(
    1.22 -                    'VM %s restarting too fast (%f seconds since the last '
    1.23 -                    'restart).  Refusing to restart to avoid loops.',
    1.24 -                    self.info['name_label'], timeout)
    1.25 -                self.destroy()
    1.26 -                return
    1.27 -
    1.28 -        self._writeVm('xend/previous_restart_time', str(now))
    1.29 +        elapse = time.time() - self.info['start_time']
    1.30 +        if elapse < MINIMUM_RESTART_TIME:
    1.31 +            log.error('VM %s restarting too fast (Elapsed time: %f seconds). '
    1.32 +                      'Refusing to restart to avoid loops.',
    1.33 +                      self.info['name_label'], elapse)
    1.34 +            self.destroy()
    1.35 +            return
    1.36  
    1.37          prev_vm_xend = self._listRecursiveVm('xend')
    1.38          new_dom_info = self.info