aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2012-01-31 16:34:39 +0000
committerIan Campbell <ian.campbell@citrix.com>2012-01-31 16:34:39 +0000
commit00f3b625052cc8933feab4e3010e169ad66fd538 (patch)
tree41e9fd7e40a985527a9c8b7a13ac1bfd1b54a868
parent6116cf8aef8c7f9365abb387b9f3949a133cf387 (diff)
downloadxen-00f3b625052cc8933feab4e3010e169ad66fd538.tar.gz
xen-00f3b625052cc8933feab4e3010e169ad66fd538.tar.bz2
xen-00f3b625052cc8933feab4e3010e169ad66fd538.zip
xl: allow enable automatic fallback to ACPI events if PV control not available.
Add a -F (fallbacks) option to xl destroy|reboot to cause an ACPI shutdown or reset event to be sent to the guest in the event that the guest does not support the PV control interface. This is not the default because the response to these triggers is an guest-internal configuration. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
-rw-r--r--docs/man/xl.pod.132
-rw-r--r--tools/libxl/xl_cmdimpl.c55
2 files changed, 67 insertions, 20 deletions
diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1
index 51948144a4..598c6ca0ed 100644
--- a/docs/man/xl.pod.1
+++ b/docs/man/xl.pod.1
@@ -365,13 +365,28 @@ domain actually reboots.
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.
+to behave appropriately you may be able to use the I<-F> option
+trigger a reset 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
domain was created.
+B<OPTIONS>
+
+=over 4
+
+=item B<-F>
+
+If the guest does not support PV reboot control then fallback to
+sending an ACPI power event (equivalent to the I<reset> option to
+I<trigger>.
+
+You should ensure that the guest is configured to behave as expected
+in response to this event.
+
+=back
+
=item B<restore> [I<OPTIONS>] [I<ConfigFile>] I<CheckpointFile>
Build a domain from an B<xl save> state file. See B<save> for more info.
@@ -435,8 +450,8 @@ 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.
+to behave appropriately you may be able to use the I<-F> option
+trigger a power button press.
The command returns immediately after signally the domain unless that
B<-w> flag is used.
@@ -453,6 +468,15 @@ B<OPTIONS>
Wait for the domain to complete shutdown before returning.
+=item B<-F>
+
+If the guest does not support PV shutdown control then fallback to
+sending an ACPI power event (equivalent to the I<power> option to
+I<trigger>.
+
+You should ensure that the guest is configured to behave as expected
+in response to this event.
+
=back
=item B<sysrq> I<domain-id> I<letter>
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index fc9a59c983..0b811b5b45 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2427,20 +2427,25 @@ static void destroy_domain(const char *p)
if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); }
}
-static void shutdown_domain(const char *p, int wait)
+static void shutdown_domain(const char *p, int wait, int fallback_trigger)
{
int rc;
libxl_event *event;
find_domain(p);
rc=libxl_domain_shutdown(ctx, domid);
- if (rc) {
- if (rc == ERROR_NOPARAVIRT) {
+ if (rc == ERROR_NOPARAVIRT) {
+ if (fallback_trigger) {
+ fprintf(stderr, "PV control interface not available:"
+ " sending ACPI power button event.\n");
+ rc = libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_POWER, 0);
+ } else {
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, "Use \"-F\" to fallback to ACPI power event.\n");
}
+ }
+ if (rc) {
fprintf(stderr,"shutdown failed (rc=%d)\n",rc);exit(-1);
}
@@ -2481,19 +2486,25 @@ static void shutdown_domain(const char *p, int wait)
}
}
-static void reboot_domain(const char *p)
+static void reboot_domain(const char *p, int fallback_trigger)
{
int rc;
find_domain(p);
rc=libxl_domain_reboot(ctx, domid);
- if (rc) {
- if (rc == ERROR_NOPARAVIRT) {
+ if (rc == ERROR_NOPARAVIRT) {
+ if (fallback_trigger) {
+ fprintf(stderr, "PV control interface not available:"
+ " sending ACPI reset button event.\n");
+ rc = libxl_send_trigger(ctx, domid, LIBXL_TRIGGER_RESET, 0);
+ } else {
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, "Use \"-F\" to fallback to ACPI reset event.\n");
}
- fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1); }
+ }
+ if (rc) {
+ fprintf(stderr,"reboot failed (rc=%d)\n",rc);exit(-1);
+ }
}
static void list_domains_details(const libxl_dominfo *info, int nb_domain)
@@ -3277,29 +3288,41 @@ int main_shutdown(int argc, char **argv)
{
int opt;
int wait = 0;
+ int fallback_trigger = 0;
- while ((opt = def_getopt(argc, argv, "w", "shutdown", 1)) != -1) {
+ while ((opt = def_getopt(argc, argv, "wF", "shutdown", 1)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
case 'w':
wait = 1;
break;
+ case 'F':
+ fallback_trigger = 1;
+ break;
}
}
- shutdown_domain(argv[optind], wait);
+ shutdown_domain(argv[optind], wait, fallback_trigger);
return 0;
}
int main_reboot(int argc, char **argv)
{
int opt;
+ int fallback_trigger = 0;
- if ((opt = def_getopt(argc, argv, "", "reboot", 1)) != -1)
- return opt;
+ while ((opt = def_getopt(argc, argv, "F", "reboot", 1)) != -1) {
+ switch (opt) {
+ case 0: case 2:
+ return opt;
+ case 'F':
+ fallback_trigger = 1;
+ break;
+ }
+ }
- reboot_domain(argv[optind]);
+ reboot_domain(argv[optind], fallback_trigger);
return 0;
}