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

[Xen-devel] [PATCH 3 of 3] libxl: report failure to reboot/shutdown due to lackof PV interfaces to caller



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1323793457 0
# Node ID 47606788dec2f110aecf5b356b250d65343070ac
# Parent  e0f020d3d812e00aeb0c271a9627206279da3964
libxl: report failure to reboot/shutdown due to lackof PV interfaces to caller

This allow the caller to react as they think is appropriate. xl now prints a
message much like the library did previously, although hopefully somewhat more
informative.

Update the xl(1) man page to be similarly more informative.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r e0f020d3d812 -r 47606788dec2 docs/man/xl.pod.1
--- a/docs/man/xl.pod.1 Tue Dec 13 16:24:04 2011 +0000
+++ b/docs/man/xl.pod.1 Tue Dec 13 16:24:17 2011 +0000
@@ -368,7 +368,11 @@ Reboot a domain.  This acts just as if t
 command run from the console.  The command returns as soon as it has
 executed the reboot action, which may be significantly before the
 domain actually reboots.
-It requires PV drivers installed in your guest OS.
+
+For HVM domains this requires PV drivers to be installed in your guest
+OS. If PV drivers are not present but you have configured the guest OS
+to behave appropriately you may be able to use the I<button-press>
+subcommand to trigger a power button press.
 
 The behavior of what happens to a domain when it reboots is set by the
 B<on_reboot> parameter of the domain configuration file when the
@@ -424,9 +428,15 @@ Leave domain running after creating the 
 Gracefully shuts down a domain.  This coordinates with the domain OS
 to perform graceful shutdown, so there is no guarantee that it will
 succeed, and may take a variable length of time depending on what
-services must be shutdown in the domain.  The command returns
-immediately after signally the domain unless that B<-w> flag is used.
-For HVM domains it requires PV drivers to be installed in your guest OS.
+services must be shutdown in the domain.
+
+For HVM domains this requires PV drivers to be installed in your guest
+OS. If PV drivers are not present but you have configured the guest OS
+to behave appropriately you may be able to use the I<button-press>
+subcommand to trigger a power button press.
+
+The command returns immediately after signally the domain unless that
+B<-w> flag is used.
 
 The behavior of what happens to a domain when it reboots is set by the
 B<on_shutdown> parameter of the domain configuration file when the
diff -r e0f020d3d812 -r 47606788dec2 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Tue Dec 13 16:24:04 2011 +0000
+++ b/tools/libxl/libxl.c       Tue Dec 13 16:24:17 2011 +0000
@@ -604,9 +604,7 @@ int libxl_domain_shutdown(libxl_ctx *ctx
         goto out;
 
     if (!ret) {
-        LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "PV control interface not available:"
-                   " graceful shutdown not possible, use destroy");
-        ret = ERROR_FAIL;
+        ret = ERROR_NOPARAVIRT;
         goto out;
     }
 
@@ -627,9 +625,7 @@ int libxl_domain_reboot(libxl_ctx *ctx, 
         goto out;
 
     if (!ret) {
-        LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "PV control interface not available:"
-                   " graceful reboot not possible, use destroy+create");
-        ret = ERROR_FAIL;
+        ret = ERROR_NOPARAVIRT;
         goto out;
     }
 
diff -r e0f020d3d812 -r 47606788dec2 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Tue Dec 13 16:24:04 2011 +0000
+++ b/tools/libxl/libxl.h       Tue Dec 13 16:24:17 2011 +0000
@@ -222,6 +222,7 @@ enum {
     ERROR_BADFAIL = -7,
     ERROR_GUEST_TIMEDOUT = -8,
     ERROR_TIMEDOUT = -9,
+    ERROR_NOPARAVIRT = -10,
 };
 
 #define LIBXL_VERSION 0
diff -r e0f020d3d812 -r 47606788dec2 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Tue Dec 13 16:24:04 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Tue Dec 13 16:24:17 2011 +0000
@@ -2266,7 +2266,15 @@ static void shutdown_domain(const char *
 
     find_domain(p);
     rc=libxl_domain_shutdown(ctx, domid);
-    if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1); }
+    if (rc) {
+        if (rc == ERROR_NOPARAVIRT) {
+            fprintf(stderr, "PV control interface not available:"
+                    " external graceful shutdown not possible.\n");
+            fprintf(stderr, "Use \"xl button-press <dom> power\" or"
+                    " \"xl destroy <dom>\".\n");
+        }
+        fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1);
+    }
 
     if (wait) {
         libxl_waiter waiter;
@@ -2308,7 +2316,14 @@ static void reboot_domain(const char *p)
     int rc;
     find_domain(p);
     rc=libxl_domain_reboot(ctx, domid);
-    if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); }
+    if (rc) {
+        if (rc == ERROR_NOPARAVIRT) {
+            fprintf(stderr, "PV control interface not available:"
+                    " external graceful reboot not possible.\n");
+            fprintf(stderr, "Use \"xl button-press <dom> power\" or"
+                    " \"xl destroy <dom>\".\n");
+        }
+        fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); }
 }
 
 static void list_domains_details(const libxl_dominfo *info, int nb_domain)

_______________________________________________
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®.