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
|