KVM – libvirt-guests – autostart / shutdown / pause

Some time ago while using XEN we had our own scripts we used during shutdown / start host machine. Those scripts were responsible for auto – saving and auto – resuming VMs. In KVM we no longer use our own scripts – we use libvirt-guests service instead. In RHEL/CentOS You’ll find init script for this service in  /etc/rc.d/init.d/libvirt-guests. If You want to do some changes in this service’s configuration do that in /etc/sysconfig/libvirt-guests instead of init script. If You installed KVM env using defaults You’ll be interested only in following params:

Using above config Your VMs would be auto – paused while system enters runlevel 0/6 (so shutdown or reboot). When host comes back (“back” means runlevels in which libvirt-guests is configured) Your VMs will be resumed.

Order of stopping / starting VMs is tricky – I found this discussion interesting: http://www.redhat.com/archives/libvir-list/2011-April/msg00819.html

  • Ralph Horque

    An easy way to make systems start up in order, sort of, is, set the GRUB_TIMEOUT to each machine differently. First server, 1 second. Second server, perhaps 30 seconds, etc. It’s crude, but works great for me.