aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Pau Monné <royger@FreeBSD.org>2022-01-13 13:47:18 +0000
committerRoger Pau Monné <royger@FreeBSD.org>2022-01-13 15:54:30 +0000
commitca46f3289d9630a9b203379333b46f3f11363146 (patch)
tree59cdc7ee227e219fc7cf346d131988de1e1f4b69
parent9b6aa99e1f20577c361cd57e427a5a95013dbac1 (diff)
downloadsrc-ca46f3289d9630a9b203379333b46f3f11363146.tar.gz
src-ca46f3289d9630a9b203379333b46f3f11363146.zip
xen: use an hypercall for shutdown and reboot
When running as a Xen guest it's easier to use an hypercall in order to do power management operations (power off, power cycle). Do this for all supported guest types (HVM and PVH). Note that for HVM the power operation could also be done using ACPI, but there's no reason to differentiate between PVH and HVM. While there fix the shutdown handler to properly differentiate between power cycle and power off requests. Reported by: Freddy DISSAUX MFC: 1 week Sponsored by: Citrix Systems R&D
-rw-r--r--sys/dev/xen/control/control.c18
-rw-r--r--sys/x86/include/xen/xen-os.h7
2 files changed, 6 insertions, 19 deletions
diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c
index 426682a8f2d9..b42b52a62411 100644
--- a/sys/dev/xen/control/control.c
+++ b/sys/dev/xen/control/control.c
@@ -347,17 +347,12 @@ xctrl_crash()
}
static void
-xen_pv_shutdown_final(void *arg, int howto)
+shutdown_final(void *arg, int howto)
{
- /*
- * Inform the hypervisor that shutdown is complete.
- * This is not necessary in HVM domains since Xen
- * emulates ACPI in that mode and FreeBSD's ACPI
- * support will request this transition.
- */
- if (howto & (RB_HALT | RB_POWEROFF))
+ /* Inform the hypervisor that shutdown is complete. */
+ if (howto & RB_POWEROFF)
HYPERVISOR_shutdown(SHUTDOWN_poweroff);
- else
+ else if (howto & RB_POWERCYCLE)
HYPERVISOR_shutdown(SHUTDOWN_reboot);
}
@@ -453,9 +448,8 @@ xctrl_attach(device_t dev)
xctrl->xctrl_watch.max_pending = 1;
xs_register_watch(&xctrl->xctrl_watch);
- if (xen_pv_shutdown_handler())
- EVENTHANDLER_REGISTER(shutdown_final, xen_pv_shutdown_final, NULL,
- SHUTDOWN_PRI_LAST);
+ EVENTHANDLER_REGISTER(shutdown_final, shutdown_final, NULL,
+ SHUTDOWN_PRI_LAST);
return (0);
}
diff --git a/sys/x86/include/xen/xen-os.h b/sys/x86/include/xen/xen-os.h
index 9d0964c6631d..655961da22fd 100644
--- a/sys/x86/include/xen/xen-os.h
+++ b/sys/x86/include/xen/xen-os.h
@@ -57,13 +57,6 @@ xen_has_percpu_evtchn(void)
}
static inline bool
-xen_pv_shutdown_handler(void)
-{
-
- return (xen_pv_domain());
-}
-
-static inline bool
xen_pv_disks_disabled(void)
{