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
This commit is contained in:
parent
9b6aa99e1f
commit
ca46f3289d
@ -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);
|
||||
}
|
||||
|
@ -56,13 +56,6 @@ xen_has_percpu_evtchn(void)
|
||||
return (!xen_hvm_domain() || xen_vector_callback_enabled);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
xen_pv_shutdown_handler(void)
|
||||
{
|
||||
|
||||
return (xen_pv_domain());
|
||||
}
|
||||
|
||||
static inline bool
|
||||
xen_pv_disks_disabled(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user