[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] This patch make xm reboot/shutdown work for vmx doamin.



# HG changeset patch
# User Ke Yu <ke.yu@xxxxxxxxx>
# Node ID 018e6dc18f97dc09a31c94e39b28dbb163e40a82
# Parent  a38c292e8390370ec9473a6444bd63be7e437afe
This patch make xm reboot/shutdown work for vmx doamin.

xm reboot fails due to two issues:
1. no mechanism to change XendDomainInfo.info to trigger domain reboot
2. ioemu blkif parameter is missing during reboot, thus device model recreation 
will fail.

This patch fix these issues by
1. introducing a xswatch to monitor the control/shutdown node. once fired, it 
will change the XendDomainInfo.info to trigger domain reboot
2. saving the ioemu blkif parameter in xen store just like DomU does.

Signed-off-by: Yu Ke <ke.yu@xxxxxxxxx>

diff -r a38c292e8390 -r 018e6dc18f97 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Tue Jan 24 16:54:34 2006
+++ b/tools/python/xen/xend/image.py    Tue Jan 24 16:58:43 2006
@@ -25,6 +25,7 @@
 from xen.xend.XendError import VmError
 from xen.xend.XendLogging import log
 from xen.xend.server.netif import randomMAC
+from xen.xend.xenstore.xswatch import xswatch
 
 
 xc = xen.lowlevel.xc.xc()
@@ -228,6 +229,8 @@
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
         log.debug("acpi           = %d", self.acpi)
         log.debug("apic           = %d", self.apic)
+
+        self.register_shutdown_watch()
 
         return xc.vmx_build(dom            = self.vm.getDomid(),
                             image          = self.kernel,
@@ -365,6 +368,7 @@
         return vncconnect
 
     def destroy(self):
+        self.unregister_shutdown_watch();
         import signal
         if not self.pid:
             return
@@ -398,6 +402,41 @@
         else:
             return 1 + ((mem_mb + 3) >> 2)
 
+    def register_shutdown_watch(self):
+        """ add xen store watch on control/shutdown """
+        self.shutdownWatch = xswatch(self.vm.dompath + "/control/shutdown", \
+                                    self.vmx_shutdown)
+        log.debug("vmx shutdown watch registered")
+
+    def unregister_shutdown_watch(self):
+        """Remove the watch on the control/shutdown, if any. Nothrow
+        guarantee."""
+
+        try:
+            if self.shutdownWatch:
+                self.shutdownWatch.unwatch()
+        except:
+            log.exception("Unwatching vmx shutdown watch failed.")
+        self.shutdownWatch = None
+        log.debug("vmx shutdown watch unregistered")
+
+    def vmx_shutdown(self, _):
+        """ watch call back on node control/shutdown,
+            if node changed, this function will be called
+        """
+        from xen.xend.XendDomainInfo import shutdown_reasons
+        xd = xen.xend.XendDomain.instance()
+        vm = xd.domain_lookup( self.vm.getDomid() )
+
+        reason = vm.readDom('control/shutdown')
+        log.debug("vmx_shutdown fired, shutdown reason=%s", reason)
+        for x in shutdown_reasons.keys():
+            if shutdown_reasons[x] == reason:
+                vm.info['shutdown'] = 1
+                vm.info['shutdown_reason'] = x
+                vm.refreshShutdown(vm.info)
+
+        return 1 # Keep watching
 
 """Table of image handler classes for virtual machine images.  Indexed by
 image type.
diff -r a38c292e8390 -r 018e6dc18f97 tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py     Tue Jan 24 16:54:34 2006
+++ b/tools/python/xen/xend/server/blkif.py     Tue Jan 24 16:58:43 2006
@@ -42,10 +42,6 @@
         """@see DevController.getDeviceDetails"""
 
         dev = sxp.child_value(config, 'dev')
-        if 'ioemu:' in dev:
-            return (None,{},{})
-
-        devid = blkif.blkdev_name_to_number(dev)
 
         (typ, params) = string.split(sxp.child_value(config, 'uname'), ':', 1)
         back = { 'dev'    : dev,
@@ -54,7 +50,13 @@
                  'mode'   : sxp.child_value(config, 'mode', 'r')
                  }
 
-        front = { 'virtual-device' : "%i" % devid }
+        if 'ioemu:' in dev:
+            (dummy, dev1) = string.split(dev, ':', 1)
+            devid = blkif.blkdev_name_to_number(dev1)
+            front = {}
+        else:
+            devid = blkif.blkdev_name_to_number(dev)
+            front = { 'virtual-device' : "%i" % devid }
 
         return (devid, back, front)
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.