ia64/xen-unstable

changeset 14824:95a9998ede92

HVM: Do not watch control/shutdown to force domain shutdowns when PV
drivers are not present. The feature-foo mechanism does not actually
work after save/restore since the fields do not get rewritten. And it
doesn't work when we actually need the guest to be shutdown through
Xen (e.g., on suspend). Since we can quite reasonably assume that the
only entity to screw with control/shutdown is xend, and since the one
place that does that now explicitly handles unenlightened HVM guests,
we can simply strip all this stuff out.

This has the nice benefit of making HVM save/restore with PV drivers
much more reliable.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Apr 12 12:12:56 2007 +0100 (2007-04-12)
parents 4c06bcd83c90
children 887fa548f650
files linux-2.6-xen-sparse/drivers/xen/core/reboot.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/image.py
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Thu Apr 12 12:09:58 2007 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Thu Apr 12 12:12:56 2007 +0100
     1.3 @@ -118,6 +118,7 @@ static void shutdown_handler(struct xenb
     1.4  	err = xenbus_transaction_start(&xbt);
     1.5  	if (err)
     1.6  		return;
     1.7 +
     1.8  	str = (char *)xenbus_read(xbt, "control", "shutdown", NULL);
     1.9  	/* Ignore read errors and empty reads. */
    1.10  	if (XENBUS_IS_ERR_READ(str)) {
    1.11 @@ -206,14 +207,12 @@ static int setup_shutdown_watcher(void)
    1.12  		printk(KERN_ERR "Failed to set shutdown watcher\n");
    1.13  		return err;
    1.14  	}
    1.15 -	xenbus_write(XBT_NIL, "control", "feature-reboot", "1");
    1.16  
    1.17  	err = register_xenbus_watch(&sysrq_watch);
    1.18  	if (err) {
    1.19  		printk(KERN_ERR "Failed to set sysrq watcher\n");
    1.20  		return err;
    1.21  	}
    1.22 -	xenbus_write(XBT_NIL, "control", "feature-sysrq", "1");
    1.23  
    1.24  	return 0;
    1.25  }
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Apr 12 12:09:58 2007 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Apr 12 12:12:56 2007 +0100
     2.3 @@ -1601,7 +1601,6 @@ class XendDomainInfo:
     2.4              self.image = image.create(self, self.info)
     2.5              if self.image:
     2.6                  self.image.createDeviceModel(True)
     2.7 -                self.image.register_shutdown_watch()
     2.8          self._storeDomDetails()
     2.9          self._registerWatches()
    2.10          self.refreshShutdown()
     3.1 --- a/tools/python/xen/xend/image.py	Thu Apr 12 12:09:58 2007 +0100
     3.2 +++ b/tools/python/xen/xend/image.py	Thu Apr 12 12:12:56 2007 +0100
     3.3 @@ -284,9 +284,6 @@ class HVMImageHandler(ImageHandler):
     3.4          log.debug("acpi           = %d", self.acpi)
     3.5          log.debug("apic           = %d", self.apic)
     3.6  
     3.7 -        self.register_shutdown_watch()
     3.8 -        self.register_reboot_feature_watch()
     3.9 -
    3.10          return xc.hvm_build(domid          = self.vm.getDomid(),
    3.11                              image          = self.kernel,
    3.12                              store_evtchn   = store_evtchn,
    3.13 @@ -448,13 +445,9 @@ class HVMImageHandler(ImageHandler):
    3.14          log.info("device model pid: %d", self.pid)
    3.15  
    3.16      def recreate(self):
    3.17 -        self.register_shutdown_watch()
    3.18 -        self.register_reboot_feature_watch()
    3.19          self.pid = self.vm.gatherDom(('image/device-model-pid', int))
    3.20  
    3.21      def destroy(self, suspend = False):
    3.22 -        self.unregister_shutdown_watch()
    3.23 -        self.unregister_reboot_feature_watch();
    3.24          if self.pid:
    3.25              try:
    3.26                  sig = signal.SIGKILL
    3.27 @@ -473,74 +466,6 @@ class HVMImageHandler(ImageHandler):
    3.28                  pass
    3.29              self.pid = None
    3.30  
    3.31 -    def register_shutdown_watch(self):
    3.32 -        """ add xen store watch on control/shutdown """
    3.33 -        self.shutdownWatch = xswatch(self.vm.dompath + "/control/shutdown",
    3.34 -                                     self.hvm_shutdown)
    3.35 -        log.debug("hvm shutdown watch registered")
    3.36 -
    3.37 -    def unregister_shutdown_watch(self):
    3.38 -        """Remove the watch on the control/shutdown, if any. Nothrow
    3.39 -        guarantee."""
    3.40 -
    3.41 -        try:
    3.42 -            if self.shutdownWatch:
    3.43 -                self.shutdownWatch.unwatch()
    3.44 -        except:
    3.45 -            log.exception("Unwatching hvm shutdown watch failed.")
    3.46 -        self.shutdownWatch = None
    3.47 -        log.debug("hvm shutdown watch unregistered")
    3.48 -
    3.49 -    def hvm_shutdown(self, _):
    3.50 -        """ watch call back on node control/shutdown,
    3.51 -            if node changed, this function will be called
    3.52 -        """
    3.53 -        xd = xen.xend.XendDomain.instance()
    3.54 -        try:
    3.55 -            vm = xd.domain_lookup( self.vm.getDomid() )
    3.56 -        except XendError:
    3.57 -            # domain isn't registered, no need to clean it up.
    3.58 -            return False
    3.59 -
    3.60 -        reason = vm.getShutdownReason()
    3.61 -        log.debug("hvm_shutdown fired, shutdown reason=%s", reason)
    3.62 -        if reason in REVERSE_DOMAIN_SHUTDOWN_REASONS:
    3.63 -            vm.info['shutdown'] = 1
    3.64 -            vm.info['shutdown_reason'] = \
    3.65 -                REVERSE_DOMAIN_SHUTDOWN_REASONS[reason]
    3.66 -            vm.refreshShutdown(vm.info)
    3.67 -
    3.68 -        return True # Keep watching
    3.69 -
    3.70 -    def register_reboot_feature_watch(self):
    3.71 -        """ add xen store watch on control/feature-reboot """
    3.72 -        self.rebootFeatureWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \
    3.73 -                                         self.hvm_reboot_feature)
    3.74 -        log.debug("hvm reboot feature watch registered")
    3.75 -
    3.76 -    def unregister_reboot_feature_watch(self):
    3.77 -        """Remove the watch on the control/feature-reboot, if any. Nothrow
    3.78 -        guarantee."""
    3.79 -
    3.80 -        try:
    3.81 -            if self.rebootFeatureWatch:
    3.82 -                self.rebootFeatureWatch.unwatch()
    3.83 -        except:
    3.84 -            log.exception("Unwatching hvm reboot feature watch failed.")
    3.85 -        self.rebootFeatureWatch = None
    3.86 -        log.debug("hvm reboot feature watch unregistered")
    3.87 -
    3.88 -    def hvm_reboot_feature(self, _):
    3.89 -        """ watch call back on node control/feature-reboot,
    3.90 -            if node changed, this function will be called
    3.91 -        """
    3.92 -        status = self.vm.readDom('control/feature-reboot')
    3.93 -        log.debug("hvm_reboot_feature fired, module status=%s", status)
    3.94 -        if status == '1':
    3.95 -            self.unregister_shutdown_watch()
    3.96 -
    3.97 -        return True # Keep watching
    3.98 -
    3.99  
   3.100  class IA64_HVM_ImageHandler(HVMImageHandler):
   3.101