[Libvir] [patch] qemu/kvm: use_system_powerdown instead of killing the vm hard

Guido Guenther agx at sigxcpu.org
Tue Jan 8 16:55:45 UTC 2008

On Tue, Jan 08, 2008 at 04:37:02PM +0000, Daniel P. Berrange wrote:
> On Tue, Jan 08, 2008 at 12:15:56PM +0100, Guido Guenther wrote:
> > Hi,
> > currently domainShutdown kills qemu/kvm instances hard which is not very
> > filesystem friendly. However recent kvm git acquired system_powerdown to
> > shutdown the system gracefully by simulating an acpi power button press.
> > We can now use this in libvirt: 
> Excellant, although we still need to use the 'kill' approach for any VMs
> which don't support the 'system_powerdown' monitor command. We should
> probably try 'system_powerdown' and if that gets rejected then fallback
> to just killing it. Figuring out if its rejected could be fun though;
> Would have to look at the returned 'info' for an error message - hopefully
> QEMU has one.
No, there's no error code or output since the drop in code in qemu is
(and was since ages):

#define qemu_system_powerdown() do{}while(0)

I don't think that's a problem though. As far as I understand things a
shutdown simply signals the VM to powerdown. We can't rely on the
machine actually stopping (say the machine hangs on unmounting something
or simply stops heaps of services or whatever). So any sane script or
cluster manager will have to do a domainDestroy() anyways after a
reasonable timeout (what's "reasonable" depends pretty much on the usage
case). Relying on domainShutdown() ever succeeding is probably wrong in
the first place.

If we want to be able to rely on the shutdown succeeding we have to do
the domainDestroy ourselfes after a timeout.
 -- Guido

More information about the libvir-list mailing list