Is there any way to make KVM automatically restart any VMs that have been shut down due to power failure? Here is my scenario: I run a small VM tank, mostly with development VMs on it. I now have a VM that is set to autostart on system boot, which works. I have installed apcupsd on that VM, reading from the daemon on the host, and configured to shut down when battery reaches 75%. The host will shut down when the battery reaches 15%. My question is, if power returns during this window (i.e. the host stays up), can I restart the VM that was shut down? I know I could hard-code a call to 'virsh start [VM name]' but I am looking to start any VM flagged as 'autostart', somewhat like doing 'mount -a' to mount all defined filesystems. Is this possible?


On my RHEL6 and CentOS6 that is established by creating a symbolic link to VM XML description in /etc/libvirt/qemu/autostart/ :

ls -la /etc/libvirt/qemu/autostart/
total 4
drwxr-xr-x. 2 root root 4096 Dec 19  2012 .
drwx------. 4 root root 4096 Dec 21 08:50 ..
lrwxrwxrwx. 1 root root   29 Mar  3  2012 hosting2.xml -> ../hosting2.xml
lrwxrwxrwx. 1 root root   43 May 25  2011 hosting.xml -> /etc/libvirt/qemu/hosting.xml

If you want to avoid setting up links manually: virsh autostart <domain>

autostart [--disable] domain Configure a domain to be automatically started at boot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.