How do I configure KVM to suspend/restore virtual machines when the host is rebooted?

To suspend a VM on host shutdown you will need to configure the following file

vi /etc/sysconfig/libvirt-guests

Set the following options (which are located throughout the configuration file).

ON_BOOT=start
START_DELAY=5
ON_SHUTDOWN=suspend

You might not want to use START_DELAY=5, but I would rather the virtual machines start up with a little staggering rather than concurrently.

The libvirt-guests service also needs to be enabled and started.

systemctl start libvirt-guests
systemctl enable libvirt-guests

You will now be able to reboot the host machine to install updates etc. and the virtual machines will be suspended and restored rather than shutdown interrupting their jobs.

You cannot comment on this entry