WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx, Jeremy Fitzhardinge <Jeremy.Fitzhardinge@xxxxxxxxxx>, Ian Campbell <Ian.Campbell@xxxxxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Make explicit message when guest failed to suspend
From: Frank Pan <frankpzh@xxxxxxxxx>
Date: Thu, 3 Mar 2011 18:13:20 +0800
Cc:
Delivery-date: Thu, 03 Mar 2011 02:32:25 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=dI1R5IKeB7WJRApKIBN6p7PNn76csKFZCqFtsm4MpyI=; b=pmHVKK2G1GuuXWgEl3on+3RTBElSM38pTqd02AE/MmIV+BUiYMQNtr3gX7lmFrYpI9 onEDbAaIRI5G6vRRHvMoVzez51JTGr7koK6wjxnF2CGOZsyc3VJx+MZ8d0NnWScGuzsw VSrSFBvXpCH2wSJZgCndCRMXGLNkJjnnEOKYg=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=hY32TFXYWH8okqvkb5Eg0EPcAoCB+3eqP6JxHG0jXc7Q2muMyVVVJorqXg4qmczzpK ey2KRh9pXQ/sGXDw0Mt/XLQH/QB3qfQfpZzucCbicrzw7usBphH8Q+ynY57M7uLSiG23 m89otmh4aioeRuOKbQutcf3+aoOEfNb5N5Xb0=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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