[XEND] Cleanup HVM image shutdown watch and move readDom call away
authorAlastair Tse <atse@xensource.com>
Fri, 3 Nov 2006 15:47:05 +0000 (15:47 +0000)
committerAlastair Tse <atse@xensource.com>
Fri, 3 Nov 2006 15:47:05 +0000 (15:47 +0000)
from image.py

Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xend/image.py

index 8e6f462ea07a5a875a703476027e5f2ab77ad209..ec0f8e8c2fd114f44d4b9cbce1c4b23f559a7ade 100644 (file)
@@ -797,12 +797,13 @@ class XendDomainInfo:
     def getDomainPath(self):
         return self.dompath
 
+    def getShutdownReason(self):
+        return self._readDom('control/shutdown')
 
     def getStorePort(self):
         """For use only by image.py and XendCheckpoint.py."""
         return self.store_port
 
-
     def getConsolePort(self):
         """For use only by image.py and XendCheckpoint.py"""
         return self.console_port
index c264fb669e22e561b46feadd45273ad73a711471..c70c94fc00954a6d16901d409fcfbcfabbbc19ce 100644 (file)
@@ -24,7 +24,7 @@ import signal
 
 import xen.lowlevel.xc
 from xen.xend import sxp
-from xen.xend.XendError import VmError
+from xen.xend.XendError import VmError, XendError
 from xen.xend.XendLogging import log
 from xen.xend.server.netif import randomMAC
 from xen.xend.xenstore.xswatch import xswatch
@@ -456,9 +456,13 @@ class HVMImageHandler(ImageHandler):
         """
         from xen.xend.XendConstants import DOMAIN_SHUTDOWN_REASONS
         xd = xen.xend.XendDomain.instance()
-        vm = xd.domain_lookup( self.vm.getDomid() )
+        try:
+            vm = xd.domain_lookup( self.vm.getDomid() )
+        except XendError:
+            # domain isn't registered, no need to clean it up.
+            return
 
-        reason = vm._readDom('control/shutdown')
+        reason = vm.getShutdownReason()
         log.debug("hvm_shutdown fired, shutdown reason=%s", reason)
         for x in DOMAIN_SHUTDOWN_REASONS.keys():
             if DOMAIN_SHUTDOWN_REASONS[x] == reason: