ia64/xen-unstable

changeset 19331:db53046ca5f0

xend: Time-out if guest fails to suspend

If a guest fails to re-write control/shutdown node within a minute,
fail the suspend operation.

Signed-off-by: John Levon <john.levon@sun.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Mar 12 11:00:52 2009 +0000 (2009-03-12)
parents 8401a1f14759
children 99771e02b38a
files tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Thu Mar 12 10:59:53 2009 +0000
     1.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Thu Mar 12 11:00:52 2009 +0000
     1.3 @@ -114,7 +114,7 @@ def save(fd, dominfo, network, live, dst
     1.4              if line == "suspend":
     1.5                  log.debug("Suspending %d ...", dominfo.getDomid())
     1.6                  dominfo.shutdown('suspend')
     1.7 -                dominfo.waitForShutdown()
     1.8 +                dominfo.waitForSuspend()
     1.9              if line in ('suspend', 'suspended'):
    1.10                  dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2,
    1.11                                         domain_name)
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Mar 12 10:59:53 2009 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Mar 12 11:00:52 2009 +0000
     2.3 @@ -2544,6 +2544,31 @@ class XendDomainInfo:
     2.4          finally:
     2.5              self.state_updated.release()
     2.6  
     2.7 +    def waitForSuspend(self):
     2.8 +        """Wait for the guest to respond to a suspend request by
     2.9 +        shutting down.  If the guest hasn't re-written control/shutdown
    2.10 +        after a certain amount of time, it's obviously not listening and
    2.11 +        won't suspend, so we give up.  HVM guests with no PV drivers
    2.12 +        should already be shutdown.
    2.13 +        """
    2.14 +        state = "suspend"
    2.15 +        nr_tries = 60
    2.16 +
    2.17 +        self.state_updated.acquire()
    2.18 +        try:
    2.19 +            while self._stateGet() in (DOM_STATE_RUNNING,DOM_STATE_PAUSED):
    2.20 +                self.state_updated.wait(1.0)
    2.21 +                if state == "suspend":
    2.22 +                    if nr_tries == 0:
    2.23 +                        msg = ('Timeout waiting for domain %s to suspend'
    2.24 +                            % self.domid)
    2.25 +                        self._writeDom('control/shutdown', '')
    2.26 +                        raise XendError(msg)
    2.27 +                    state = self.readDom('control/shutdown')
    2.28 +                    nr_tries -= 1
    2.29 +        finally:
    2.30 +            self.state_updated.release()
    2.31 +
    2.32      #
    2.33      # TODO: recategorise - called from XendCheckpoint
    2.34      #