How To Enable Auto Start for KVM

Check Centos Version
Check Centos Version

I had one of my dedicated servers crash the other day and when I fixed it and booted it again, some of my virtual machines didn’t boot.

Turns out, it’s because they didn’t have the autostart enabled:

root@s3:~ # virsh dominfo m
Id: -
Name: m
UUID: f2f9b5aa-7086-89ef-a643-fddb55134ef0
OS Type: hvm
State: shut off
CPU(s): 4
Max memory: 4194304 KiB
Used memory: 4194304 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: none
Security DOI: 0

That’s how one can turn the autostart on so that next reboot this VM would start (last parameter is the name of the VM):

root@s3:~ # virsh autostart m     
Domain m marked as autostarted

And just to make sure this actually helped:

root@s3:~ # virsh dominfo m
Id: -
Name: m
UUID: f2f9b5aa-7086-89ef-a643-fddb55134ef0
OS Type: hvm
State: shut off
CPU(s): 4
Max memory: 4194304 KiB
Used memory: 4194304 KiB
Persistent: yes
Autostart: enable
Managed save: no
Security model: none
Security DOI: 0
unction(t){t.preventDefault();var n=e(this).parent(),o=n.index(),s=e(this).closest(".code-tabs"),i=s.find(".tab-pane").eq(o);s.find(".active").removeClass("active"),n.addClass("active"),i.addClass("active")}),e(".collapse").on("shown.bs.collapse",function(){e(this).parent().find(".ti-plus").removeClass("ti-plus").addClass("ti-minus")}).on("hidden.bs.collapse",function(){e(this).parent().find(".ti-minus").removeClass("ti-minus").addClass("ti-plus")})}(jQuery)