Can KVM suspend or shutdown guests automatically on host shutdown?
Yes.
The virsh shutdown
command (or other implementations of "shutdown" using libvirt, as in virt-manager
) instructs the guest OS to shut down cleanly. From the man page:
shutdown domain-id
Gracefully shuts down a domain. This coordinates with the domain
OS to perform graceful shutdown, so there is no guarantee that it
will succeed, and may take a variable length of time depending on
what services must be shutdown in the domain.
The exact behavior of a domain when it shuts down is set by the
on_shutdown parameter in the domain’s XML definition.
With KVM, this should send an ACPI system_powerdown event.
In Fedora and RHEL 6, a libvirt-guests
init script comes out of the box configured to suspend all guests on system shutdown. It's not particularly magic, though, so one could copy this to CentOS 5 with little modification.
This is now a standard feature in recent Fedora and RHEL 6.