ia64/xen-unstable

changeset 19157:1b2fdbb33716

xend: Delay before SIGKILL qemu

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 04 12:01:05 2009 +0000 (2009-02-04)
parents 6058887e55d7
children 97ca3400d17c
files tools/python/xen/xend/image.py
line diff
     1.1 --- a/tools/python/xen/xend/image.py	Wed Feb 04 12:00:06 2009 +0000
     1.2 +++ b/tools/python/xen/xend/image.py	Wed Feb 04 12:01:05 2009 +0000
     1.3 @@ -558,24 +558,30 @@ class ImageHandler:
     1.4                      os.kill(self.pid, signal.SIGHUP)
     1.5                  except OSError, exn:
     1.6                      log.exception(exn)
     1.7 -                try:
     1.8 -                    # Try to reap the child every 100ms for 10s. Then SIGKILL it.
     1.9 -                    for i in xrange(100):
    1.10 +                # Try to reap the child every 100ms for 10s. Then SIGKILL it.
    1.11 +                for i in xrange(100):
    1.12 +                    try:
    1.13                          (p, rv) = os.waitpid(self.pid, os.WNOHANG)
    1.14                          if p == self.pid:
    1.15                              break
    1.16 -                        time.sleep(0.1)
    1.17 -                    else:
    1.18 -                        log.warning("DeviceModel %d took more than 10s "
    1.19 -                                    "to terminate: sending SIGKILL" % self.pid)
    1.20 +                    except OSError:
    1.21 +                        # This is expected if Xend has been restarted within
    1.22 +                        # the life of this domain.  In this case, we can kill
    1.23 +                        # the process, but we can't wait for it because it's
    1.24 +                        # not our child. We continue this loop, and after it is
    1.25 +                        # terminated make really sure the process is going away
    1.26 +                        # (SIGKILL).
    1.27 +                        pass
    1.28 +                    time.sleep(0.1)
    1.29 +                else:
    1.30 +                    log.warning("DeviceModel %d took more than 10s "
    1.31 +                                "to terminate: sending SIGKILL" % self.pid)
    1.32 +                    try:
    1.33                          os.kill(self.pid, signal.SIGKILL)
    1.34                          os.waitpid(self.pid, 0)
    1.35 -                except OSError, exn:
    1.36 -                    # This is expected if Xend has been restarted within the
    1.37 -                    # life of this domain.  In this case, we can kill the process,
    1.38 -                    # but we can't wait for it because it's not our child.
    1.39 -                    # We just make really sure it's going away (SIGKILL) first.
    1.40 -                    os.kill(self.pid, signal.SIGKILL)
    1.41 +                    except OSError:
    1.42 +                        # This happens if the process doesn't exist.
    1.43 +                        pass
    1.44                  state = xstransact.Remove("/local/domain/0/device-model/%i"
    1.45                                            % self.vm.getDomid())
    1.46              finally: