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

[Xen-devel] [PATCH] Make explicit message when guest failed to suspend



Recent xen uses xenbus to suspend PV-on-HVM guest domain. The related
code in the xen-unstable tree will fall into infinite loop when guest
domain failed on suspending one or more devices.

The patch attached changes the logic, and raises an XendError after 1
minute waiting. The patch also makes use of "control/shutdown" entry
in xenstore, allows guest kernel report the failure of the suspending.

Any suggestions?
---
 linux-2.6-xen/drivers/xen/manage.c      |    8 ++++++++
 tools/python/xen/xend/XendDomainInfo.py |   27 ++++++++++++++++++---------
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/linux-2.6-xen/drivers/xen/manage.c
b/linux-2.6-xen/drivers/xen/manage.c
index 0b50906..5b9c132 100644
--- a/linux-2.6-xen/drivers/xen/manage.c
+++ b/linux-2.6-xen/drivers/xen/manage.c
@@ -165,6 +165,8 @@ out_destroy_sm:
        stop_machine_destroy();

 out:
+       if (cancelled)
+               xenbus_write(XBT_NIL, "control", "shutdown", "failed");
        shutting_down = SHUTDOWN_INVALID;
 }
 #endif /* CONFIG_PM_SLEEP */
@@ -190,6 +192,11 @@ static void shutdown_handler(struct xenbus_watch *watch,
                xenbus_transaction_end(xbt, 1);
                return;
        }
+       /* Ignore failed message, posted by self */
+       if (strcmp(str, "failed") == 0) {
+               xenbus_transaction_end(xbt, 1);
+               return;
+       }

        xenbus_write(xbt, "control", "shutdown", "");

@@ -212,6 +219,7 @@ static void shutdown_handler(struct xenbus_watch *watch,
 #endif
        } else {
                printk(KERN_INFO "Ignoring shutdown request: %s\n", str);
+               xenbus_write(XBT_NIL, "control", "shutdown", "failed");
                shutting_down = SHUTDOWN_INVALID;
        }

diff --git a/tools/python/xen/xend/XendDomainInfo.py
b/tools/python/xen/xend/XendDomainInfo.py
index d5e92be..c652939 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -1882,7 +1882,7 @@ class XendDomainInfo:

         reason = self.readDom('control/shutdown')

-        if reason and reason != 'suspend':
+        if reason and reason != 'suspend' and reason != 'failed':
             sst = self.readDom('xend/shutdown_start_time')
             now = time.time()
             if sst:
@@ -2990,14 +2990,23 @@ class XendDomainInfo:
         try:
             while self._stateGet() in (DOM_STATE_RUNNING,DOM_STATE_PAUSED):
                 self.state_updated.wait(1.0)
-                if state == "suspend":
-                    if nr_tries == 0:
-                        msg = ('Timeout waiting for domain %s to suspend'
-                            % self.domid)
-                        self._writeDom('control/shutdown', '')
-                        raise XendError(msg)
-                    state = self.readDom('control/shutdown')
-                    nr_tries -= 1
+
+                state = self.readDom('control/shutdown')
+
+                if state == 'failed':
+                    msg = ('Domain %s suspend failed. '
+                           'Check kernel log of domain for detail.'
+                           % self.domid)
+                    self._writeDom('control/shutdown', '')
+                    raise XendError(msg)
+
+                if nr_tries == 0:
+                    msg = ('Timeout waiting for domain %s to suspend'
+                           % self.domid)
+                    self._writeDom('control/shutdown', '')
+                    raise XendError(msg)
+                nr_tries -= 1
+
         finally:
             self.state_updated.release()

-- 
1.7.1


-- 
Frank Pan

Computer Science and Technology
Tsinghua University

Attachment: 0001-Make-explicit-message-when-guest-failed-to-suspend.patch
Description: Text Data

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

 


Rackspace

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