ia64/xen-unstable

changeset 9370:d77f0f6ebece

Protect cleanupDomain with the refresh_shutdown_lock. This stops the device
and watch teardown being run concurrently from multiple threads, silencing
the No such file or directory error when tearing down the control/shutdown
watch, and reducing load on the store.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Tue Mar 21 12:41:33 2006 +0100 (2006-03-21)
parents 045bee6e1ebd
children 1294c5d6ff32
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Mar 21 12:26:38 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Mar 21 12:41:33 2006 +0100
     1.3 @@ -24,6 +24,7 @@ Author: Mike Wray <mike.wray@hp.com>
     1.4  
     1.5  """
     1.6  
     1.7 +import errno
     1.8  import logging
     1.9  import string
    1.10  import time
    1.11 @@ -893,7 +894,7 @@ class XendDomainInfo:
    1.12                  self.domid, timeout)
    1.13              threading.Timer(timeout, self.refreshShutdown).start()
    1.14  
    1.15 -        return 1
    1.16 +        return True
    1.17  
    1.18  
    1.19      def shutdown(self, reason):
    1.20 @@ -1246,30 +1247,34 @@ class XendDomainInfo:
    1.21          """Cleanup domain resources; release devices.  Idempotent.  Nothrow
    1.22          guarantee."""
    1.23  
    1.24 -        self.unwatchShutdown()
    1.25 -
    1.26 -        self.release_devices()
    1.27 -
    1.28 -        if self.image:
    1.29 -            try:
    1.30 -                self.image.destroy()
    1.31 -            except:
    1.32 -                log.exception(
    1.33 -                    "XendDomainInfo.cleanup: image.destroy() failed.")
    1.34 -            self.image = None
    1.35 +        self.refresh_shutdown_lock.acquire()
    1.36 +        try:
    1.37 +            self.unwatchShutdown()
    1.38  
    1.39 -        try:
    1.40 -            self.removeDom()
    1.41 -        except:
    1.42 -            log.exception("Removing domain path failed.")
    1.43 +            self.release_devices()
    1.44  
    1.45 -        try:
    1.46 -            if not self.info['name'].startswith(ZOMBIE_PREFIX):
    1.47 -                self.info['name'] = ZOMBIE_PREFIX + self.info['name']
    1.48 -        except:
    1.49 -            log.exception("Renaming Zombie failed.")
    1.50 +            if self.image:
    1.51 +                try:
    1.52 +                    self.image.destroy()
    1.53 +                except:
    1.54 +                    log.exception(
    1.55 +                        "XendDomainInfo.cleanup: image.destroy() failed.")
    1.56 +                self.image = None
    1.57  
    1.58 -        self.state_set(STATE_DOM_SHUTDOWN)
    1.59 +            try:
    1.60 +                self.removeDom()
    1.61 +            except:
    1.62 +                log.exception("Removing domain path failed.")
    1.63 +
    1.64 +            try:
    1.65 +                if not self.info['name'].startswith(ZOMBIE_PREFIX):
    1.66 +                    self.info['name'] = ZOMBIE_PREFIX + self.info['name']
    1.67 +            except:
    1.68 +                log.exception("Renaming Zombie failed.")
    1.69 +
    1.70 +            self.state_set(STATE_DOM_SHUTDOWN)
    1.71 +        finally:
    1.72 +            self.refresh_shutdown_lock.release()
    1.73  
    1.74  
    1.75      def cleanupVm(self):
    1.76 @@ -1301,7 +1306,8 @@ class XendDomainInfo:
    1.77  
    1.78      def unwatchShutdown(self):
    1.79          """Remove the watch on the domain's control/shutdown node, if any.
    1.80 -        Idempotent.  Nothrow guarantee."""
    1.81 +        Idempotent.  Nothrow guarantee.  Expects to be protected by the
    1.82 +        refresh_shutdown_lock."""
    1.83  
    1.84          try:
    1.85              try: