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] Protocol change of suspending through xenbus

To: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>, Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Protocol change of suspending through xenbus
From: Frank Pan <frankpzh@xxxxxxxxx>
Date: Wed, 30 Mar 2011 21:35:38 +0800
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 30 Mar 2011 06:38:27 -0700
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:cc :content-type:content-transfer-encoding; bh=q/Riv0ILrIGcpoQ36dbUXgA5D5Lm5NpEG0ONkKCZoIU=; b=UqQhsh9QO5e1+6xHDjNvxYpYjA5dQFg4lzhhUXIetlP2ub6piUdFuNAEaxVP9rAKhk oLplKn9oKuhFhXd5DstJXDd5ynssNAlb90XYtmq7e8siPNxzqakaXVK8DzVHhIfpdtCV Id0GDgLNJ86n6yu3yKyfttnVHIFeGMn2Q52E8=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; b=dlCilr+0sX59GOUG45aE90M0Wd3W0Fgd29beKQfF50wr1OXoKUYqQHyBA5ZPj3vByj 3+jA2u+JQKQeehONo7wnkaIcYlPa+doAaQVw7DoayAIyjdOapu/kxtKgO1fjMmcorupc bILy+wig2UwesQqTTf0yUeCfdHBf0bPi9R0OI=
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
Xend/libxl uses polling on suspending PV/PV-on-HVM guests.
They simply check whether the guest has been suspended again
and again. Guest has no chance to report errors to Xend/libxl.

The following patch is for libxl. It creates a key in the xenbus:
control/shutdown-error. Guest can post any error string into this
key, and also libxl can return this error to the user/administrator
asap.

Signed-off-by: Frank Pan <frankpzh@xxxxxxxxx>
---
 tools/libxl/libxl_create.c |    3 ++-
 tools/libxl/libxl_dom.c    |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index d94480e..95795e0 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -287,7 +287,8 @@ int libxl__domain_make(libxl_ctx *ctx,
libxl_domain_create_info *info,
     libxl__gc gc = LIBXL_INIT_GC(ctx); /* fixme: should be done by caller */
     int flags, ret, i, rc;
     char *uuid_string;
-    char *rw_paths[] = { "control/shutdown", "device",
"device/suspend/event-channel" , "data"};
+    char *rw_paths[] = { "control/shutdown", "control/shutdown-error",
+                         "device", "device/suspend/event-channel" , "data"};
     char *ro_paths[] = { "cpu", "memory", "device", "error", "drivers",
                          "control", "attr", "messages" };
     char *dom_path, *vm_path;
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index c702cf7..42c5e79 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -438,9 +438,35 @@ static int
libxl__domain_suspend_common_callback(void *data)
     LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "wait for the guest to suspend");
     watchdog = 60;
     while (watchdog > 0) {
+        char *err_path, *err_msg;
         xc_domaininfo_t info;

         usleep(100000);
+
+        /*
+         * Check if guest returns an error.
+         */
+        err_path = libxl__sprintf(si->gc, "%s/control/shutdown-error",
+                                  libxl__xs_get_dompath(si->gc, si->domid));
+      retry_transaction1:
+        t = xs_transaction_start(ctx->xsh);
+
+        err_msg = libxl__xs_read(si->gc, t, err_path);
+
+        if (strlen(err_msg))
+            libxl__xs_write(si->gc, t, err_path, "");
+
+        if (!xs_transaction_end(ctx->xsh, t, 0))
+            if (errno == EAGAIN)
+                goto retry_transaction1;
+
+        if (strlen(err_msg)) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                       "guest returns error on suspending: %s,
request cancelled",
+                       err_msg);
+            return 0;
+        }
+
         ret = xc_domain_getinfolist(ctx->xch, si->domid, 1, &info);
         if (ret == 1 && info.domain == si->domid && info.flags &
XEN_DOMINF_shutdown) {
             int shutdown_reason;
-- 
1.7.0.4

-- 
潘震皓, Frank Pan

Computer Science and Technology
Tsinghua University

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

<Prev in Thread] Current Thread [Next in Thread>