From: Ian Campbell Date: Wed, 21 Dec 2011 10:47:30 +0000 (+0000) Subject: libxl: report failure to reboot/shutdown due to lackof PV interfaces to caller X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8528d14fd1ecf448af44d1b47c20a31ee1e4f337;p=xen.git 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 Committed-by: Ian Jackson Acked-by: Ian Jackson --- diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 index 72196ee28b..17789b4766 100644 --- a/docs/man/xl.pod.1 +++ b/docs/man/xl.pod.1 @@ -360,7 +360,11 @@ Reboot a domain. This acts just as if the domain had the B 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 +subcommand to trigger a power button press. The behavior of what happens to a domain when it reboots is set by the B parameter of the domain configuration file when the @@ -412,9 +416,15 @@ Leave domain running after creating the snapshot. 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 +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 parameter of the domain configuration file when the diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 1407e98e84..2b8f8f4ab6 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -603,11 +603,8 @@ static int libxl__domain_pvcontrol(libxl__gc *gc, uint32_t domid, if (ret < 0) return ret; - if (!ret) { - LIBXL__LOG(CTX, LIBXL__LOG_ERROR, - "PV control interface not available\n"); - return ERROR_FAIL; - } + if (!ret) + return ERROR_NOPARAVIRT; return libxl__domain_pvcontrol_write(gc, XBT_NULL, domid, cmd); } diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 5344cd07a1..723eac2ca1 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -222,6 +222,7 @@ enum { ERROR_BADFAIL = -7, ERROR_GUEST_TIMEDOUT = -8, ERROR_TIMEDOUT = -9, + ERROR_NOPARAVIRT = -10, }; #define LIBXL_VERSION 0 diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index f81b6bb4ac..8270f34245 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2266,7 +2266,15 @@ static void shutdown_domain(const char *p, int wait) 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 power\" or" + " \"xl destroy \".\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 power\" or" + " \"xl destroy \".\n"); + } + fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); } } static void list_domains_details(const libxl_dominfo *info, int nb_domain)