I start a QEMU/KVM Ubuntu 15.10 virtual machine on boot and let it run in the background (as webserver).
What happens now if I shut down the host (also 15.10)?
Will it kill the VM and result in a virtual power cut or even worse?
Or will it trigger a "power-button-pressed" event in the VM and wait for it to shut down cleanly?
The guest system is set up to shut down properly when such a "power-button-pressed" event occurs. It's off after less than 5-10 seconds usually.
If the default behaviour on host shutdown is to kill the VM, how can I change this to a clean shutdown of the guest and waiting until it's off?
Best Answer
With the help of @Serg's answer, I crafted this set of three scripts (Python 3 and Bash) which listens for Unity Shutdown/Logout dialogs, checks for running VMs, blocks the Unity dialog, displays a nice progress bar, waits until all VMs are off or the timeout is reached, asks if remaining VMs should be forcibly killed and finally displays a custom shutdown/logout dialog.
Here are the scripts. Place them in a location contained in the
$PATH
variable, like/usr/local/bin/
. Make sure they're owned by root and have all execution bits set (chmod +x
).vm-terminator
(in Bash, the GUI):shutdown-all-vms
(in Python 3, the core):shutdown-dialog-listener
(in Bash, the Unity shutdown/logout watchdog):All three scripts are directly callable, the core script
shutdown-all-vms
even has a nice command-line help:Additionally, you may place
shutdown-dialog-listener
into your user account's startup applications.