In this simple recipe, we enabled the autostart feature of a libvirt controlled KVM instance.
In step 1, we enabled autostart and verified that it has been enabled in step 2.
Next, to simulate a server restart, we first stop the running instance in step 3 and the libvirt daemon in step 4.
In step 5, we started the libvirt daemon back and observe that it started the virtual machine as well, as seen in step 6.
Finally, in steps 7 and 8, we disable the autostart feature and ensure that it indeed has been disabled.