Take the 2-minute tour ×

Currently I manually poweroff each KVM guest before rebooting the host. However, this is getting old and now I am up to about 20 guest machines.

Can I trust Ubuntu Server 12.04 to do the Right Thing and hold off on completing a shutdown until the last KVM client is off?

Alternatively is there an easier way to shut all the guests off gracefully?

share|improve this question
Something to think about: a shutdown script that would send some sort of "shutdown all VMs" signal to KVM. The idea needs some fleshing out, but if KVM supports command-line control, it wouldn't be too hard to create a simple shutdown script to do that. –  JamesTheAwesomeDude Mar 16 '13 at 5:16
Yes - this could be done via the virsh command, I'm looking for something more out-of-the-box. According to this launchpad bug, it may already Just Work: bugs.launchpad.net/ubuntu/+source/kvm/+bug/350936 –  HDave Mar 25 '13 at 5:38
On RedHat they have a script called libvirt-guests which takes care of this automatically, but for whatever reason, Ubuntu doesn't include this script in their package. launchpad.net/ubuntu/+source/libvirt/0.9.8-2ubuntu1 –  HDave Mar 25 '13 at 5:47
ok - looking /etc/init/libvirt-bin it appears that the necessary code is in there to do this. I just completed a test run and it did work, but I needed to increase the timeout that was in that file from 30 seconds to 2 minutes. –  HDave Mar 25 '13 at 6:17
As a system admin I'm shocked to see the timeout in /etc/init/libvirt-bin.conf is ONLY 30 seconds. Checking the code I see this isn't even per VM, it is total. I've seen a physical (non-VM) production server that take 15min to shutdown on new fast hardware after a fresh install and databases restored. My Work's current main VM server takes nearly 10mins to shutdown due to the 30VMs with multiple databases etc. –  BeowulfNode42 Feb 4 at 7:54

2 Answers 2

Try -watchdog-action
Set the guest OS to shutdown when an acpi signal shutdown is received. Send acpi signal using -watchdog-action

Usage: -watchdog-action action The action controls what QEMU will do when the watchdog timer expires. The default is "reset" (forcefully reset the guest). Other possible actions are: "shutdown" (attempt to gracefully shutdown the guest), "poweroff" (forcefully poweroff the guest), "pause" (pause the guest), "debug" (print a debug message and continue), or "none" (do nothing).

       Note that the "shutdown" action requires that the guest responds to
       ACPI signals, which it may not be able to do in the sort of
       situations where the watchdog would have expired, and thus
       "-watchdog-action shutdown" is not recommended for production use.


share|improve this answer

Your Answer


