allow dom0 to power off machine using ACPI on shutdown.
RFC PATCH 1/1 allow dom0 to power off machine using ACPI on shutdown.
This is an evil little patch which allows my dom0 to power off the machine on shutdown successfully and doesn't break my domU shutdown behaviour.
The #if bits are ugly and are present because pm_power_off is declared above in the same #if context, maybe they are not necessary. I'm not sure about the solution for ia64.
This powers down the machine without bothering to tell the hypervisor.
I thought this kind of solution was better than trying to import a lot more ACPI cruft into Xen. Any thoughts?
Harry.
# HG changeset patch
# User [email protected]
# Node ID 5c85b5dd3f8eda21cbcf529941dc41c72a7c6e09
# Parent 67de34c062b5897d1e82995b171be081f976558e Allow a domain to call native pm_power_off if present. Fixes dom0 failure to power off on shutdown.
diff -r 67de34c062b5 -r 5c85b5dd3f8e linux-2.6-xen-sparse/drivers/xen/core/reboot.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c Thu Apr 6 11:03:53
2006
+++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c Thu Apr 6 18:25:23
2006
@@ -59,6 +59,10 @@
{
/* We really want to get pending console data out before we die. */ xencons_force_flush();
+#if defined(__i386__) || defined(__x86_64__)
+ if (pm_power_off)
+ pm_power_off();
+#endif
HYPERVISOR_shutdown(SHUTDOWN_poweroff);
}
# HG changeset patch
# User [email protected]
# Node ID 5c85b5dd3f8eda21cbcf529941dc41c72a7c6e09
# Parent 67de34c062b5897d1e82995b171be081f976558e
Allow a domain to call native pm_power_off if present. Fixes dom0 failure to power off on shutdown.
linux-2.6-xen-sparse/drivers/xen/core/reboot.c +4 -0
@@ -59,6 +59,10 @@ {/* We really want to get pending console data out before we die. */ xencons_force_flush (); +#if defined(__i386__) || defined(__x86_64__) +if (pm_power_off) +pm_power_off (); +#endif HYPERVISOR_shutdown (SHUTDOWN_poweroff); }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 10 lines · Harry Butterworth
This is an evil little patch which allows my dom0 to power off the machine on shutdown successfully and doesn't break my domU shutdown behaviour.
The #if bits are ugly and are present because
pm_power_offis declared above in the same #if context, maybe they are not necessary. I'm not sure about the solution for ia64.This powers down the machine without bothering to tell the hypervisor.
I wonder why we go to the hypervisor for shutdown at the moment. I don't see anything interesting being done for x86, and we could always have dom0 notifying Xen that it's going to shut down, and then shutting down whe the hypercall return.
Quoted 2 lines
I thought this kind of solution was better than trying to import a lot more ACPI cruft into Xen. Any thoughts?
I think you want kernel_power_off() here, which should do the right thing for all architectures.
Cheers,
Muli
Signature · 2 lines
Muli Ben-Yehuda http://www.mulix.org | http://mulix.livejournal.com/
Quoted 6 lines · Muli Ben-Yehuda
Quoted 4 lines · Harry Butterworth
This is an evil little patch which allows my dom0 to power off the machine on shutdown successfully and doesn't break my domU shutdown behaviour.
Quoted 8 lines
Quoted 6 lines
The #if bits are ugly and are present because
pm_power_offis declared above in the same #if context, maybe they are not necessary. I'm not sure about the solution for ia64.This powers down the machine without bothering to tell the hypervisor.
I wonder why we go to the hypervisor for shutdown at the moment.
The kernel is for both dom0 and domU. I think in the domU case the hypervisor call is the correct mechanism to power off the virtual machine.
Quoted 4 lines
I
don't see anything interesting being done for x86, and we could always have dom0 notifying Xen that it's going to shut down, and then shutting down whe the hypercall return.
This might be better for dom0 but currently I don't think the hypervisor returns from the call in the dom0 case. Not sure about that though.
Quoted 6 lines
Quoted 3 lines
I thought this kind of solution was better than trying to import a lot more ACPI cruft into Xen. Any thoughts?
I think you want
kernel_power_off()here, which should do the right thing for all architectures.
No. kernel_power_off is currently already being called and doesn't work because it calls machine_power_off which in current unstable calls the hypervisor which doesn't power off the hardware.
My patch modifies machine_power_off to call the native pm power off if present (i.e. if dom0) or the hypervisor if not (i.e. domU).
Quoted 3 lines
Cheers,
Muli
Quoted 3 lines · Harry Butterworth
The kernel is for both dom0 and domU. I think in the domU case the hypervisor call is the correct mechanism to power off the virtual machine.
I meant in the dom0 case, of course.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
I thought this kind of solution was better than trying to import a lot more ACPI cruft into Xen. Any thoughts?
I think you want
kernel_power_off()here, which should do the right thing for all architectures.
Quoted 6 lines
No.
kernel_power_offis currently already being called and doesn't work because it callsmachine_power_offwhich in current unstable calls the hypervisor which doesn't power off the hardware.My patch modifies
machine_power_offto call the native pm power off if present (i.e. if dom0) or the hypervisor if not (i.e. domU).
I see... Xen provides its own machine_power_off() in drivers/xen/core/reboot.c. If we go with dom0 shutting the machine down, the right fix would be to get rid of it and / or make it call the arch specific machine_power_off().
Cheers,
Muli
Signature · 2 lines
Muli Ben-Yehuda http://www.mulix.org | http://mulix.livejournal.com/
Quoted 18 lines · Muli Ben-Yehuda
Quoted 3 lines · Harry Butterworth
The kernel is for both dom0 and domU. I think in the domU case the hypervisor call is the correct mechanism to power off the virtual machine.
I meant in the dom0 case, of course.
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
I thought this kind of solution was better than trying to import a lot more ACPI cruft into Xen. Any thoughts?
I think you want
kernel_power_off()here, which should do the right thing for all architectures.No.
kernel_power_offis currently already being called and doesn't work because it callsmachine_power_offwhich in current unstable calls the hypervisor which doesn't power off the hardware.
Quoted 6 lines
Quoted 2 lines
My patch modifies
machine_power_offto call the native pm power off if present (i.e. if dom0) or the hypervisor if not (i.e. domU).I see... Xen provides its own
machine_power_off()indrivers/xen/core/reboot.c. If we go with dom0 shutting the machine down, the right fix would be to get rid of it
...can't get rid of the hypervisor call entirely because we want the domU case to call the hypervisor to power off...
Quoted 2 lines
and / or make it call
the arch specificmachine_power_off().
...and I think it xen/core/reboot.c replaced the arch specific machine_power_off which is no longer there to be called.
It might be better to install the hypervisor call in pm_power_off and let it get replaced by the acpi_power_off call if ACPI is detected. That would seem to fit in better with the way the x86 arch handles multiple power off strategies.
I haven't looked to see how the other architectures do power off yet.
Was hoping for some comment about whether to do power off in xen or in domU and whether the hypervisor needed notification.
Signature · 1 line
Harry Butterworth <[email protected]>
Quoted 9 lines · Harry Butterworth
It might be better to install the hypervisor call in
pm_power_offand let it get replaced by theacpi_power_offcall if ACPI is detected. That would seem to fit in better with the way the x86 arch handles multiple power off strategies.I haven't looked to see how the other architectures do power off yet.
Was hoping for some comment about whether to do power off in xen or in domU and whether the hypervisor needed notification.
I think your patch looked okay for now, actually. Alternatively our machine_restart() could be moved into arch-specific code files. Doing the power off in dom0 is fine -- as you say, Xen doesn't do anyhting special before shutdown.
-- Keir
Quoted 2 lines · Keir Fraser
I think your patch looked okay for now, actually. Alternatively our
machine_restart()could be moved into arch-specific code files.
The patch might be ok as a short term stopgap measure, but if we consider mainstream inclusion, it has to make use of the arch specific machine_power_off, not have ifdefs in core code. There's just no way such a thing will be accepted. I think it's better to get it right now rather than have one more thing to go back and fix when we submit it.
Cheers,
Muli
Signature · 2 lines
Muli Ben-Yehuda http://www.mulix.org | http://mulix.livejournal.com/
Quoted 7 lines · Harry Butterworth
This is an evil little patch which allows my dom0 to power off the machine on shutdown successfully and doesn't break my domU shutdown behaviour.
The #if bits are ugly and are present because
pm_power_offis declared above in the same #if context, maybe they are not necessary. I'm not sure about the solution for ia64.
On ia64, we don't xen/core/reboot.c.
The hypervisor is able to power off the machine. The reason is simple: there is a call for that in EFI.
Tristan.