ia64/xen-unstable

changeset 12708:2e9eb9980c41

Reinstate the reboot-feature code that was accidentally lost as part of the
merge in changeset 12189.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Thu Nov 30 17:28:51 2006 +0000 (2006-11-30)
parents c7e33053f59b
children dde9e37c0671
files tools/python/xen/xend/image.py
line diff
     1.1 --- a/tools/python/xen/xend/image.py	Thu Nov 30 17:53:59 2006 +0000
     1.2 +++ b/tools/python/xen/xend/image.py	Thu Nov 30 17:28:51 2006 +0000
     1.3 @@ -280,6 +280,7 @@ class HVMImageHandler(ImageHandler):
     1.4          log.debug("apic           = %d", self.apic)
     1.5  
     1.6          self.register_shutdown_watch()
     1.7 +        self.register_reboot_feature_watch()
     1.8  
     1.9          return xc.hvm_build(domid          = self.vm.getDomid(),
    1.10                              image          = self.kernel,
    1.11 @@ -420,6 +421,7 @@ class HVMImageHandler(ImageHandler):
    1.12  
    1.13      def destroy(self):
    1.14          self.unregister_shutdown_watch()
    1.15 +        self.unregister_reboot_feature_watch();
    1.16          if not self.pid:
    1.17              return
    1.18          try:
    1.19 @@ -470,6 +472,39 @@ class HVMImageHandler(ImageHandler):
    1.20  
    1.21          return 1 # Keep watching
    1.22  
    1.23 +    def register_reboot_feature_watch(self):
    1.24 +        """ add xen store watch on control/feature-reboot """
    1.25 +        self.rebootFeatureWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \
    1.26 +                                         self.hvm_reboot_feature)
    1.27 +        log.debug("hvm reboot feature watch registered")
    1.28 +
    1.29 +    def unregister_reboot_feature_watch(self):
    1.30 +        """Remove the watch on the control/feature-reboot, if any. Nothrow
    1.31 +        guarantee."""
    1.32 +
    1.33 +        try:
    1.34 +            if self.rebootFeatureWatch:
    1.35 +                self.rebootFeatureWatch.unwatch()
    1.36 +        except:
    1.37 +            log.exception("Unwatching hvm reboot feature watch failed.")
    1.38 +        self.rebootFeatureWatch = None
    1.39 +        log.debug("hvm reboot feature watch unregistered")
    1.40 +
    1.41 +    def hvm_reboot_feature(self, _):
    1.42 +        """ watch call back on node control/feature-reboot,
    1.43 +            if node changed, this function will be called
    1.44 +        """
    1.45 +        xd = xen.xend.XendDomain.instance()
    1.46 +        vm = xd.domain_lookup( self.vm.getDomid() )
    1.47 +
    1.48 +        status = vm.readDom('control/feature-reboot')
    1.49 +        log.debug("hvm_reboot_feature fired, module status=%s", status)
    1.50 +        if status == '1':
    1.51 +            self.unregister_shutdown_watch()
    1.52 +
    1.53 +        return 1 # Keep watching
    1.54 +
    1.55 +
    1.56  class IA64_HVM_ImageHandler(HVMImageHandler):
    1.57  
    1.58      ostype = "hvm"