I would like some of my domains to start automatically when my host starts (I'm using libvirt+KVM on ubuntu). I guess I could put some "virsh start..." statements in rc.local, but is there a way to configure this within libvirt/virsh?
Asked
Active
Viewed 3.0k times
3 Answers
16
Looking at the output of "help":
virsh # help autostart
NAME
autostart - autostart a domain
SYNOPSIS
autostart <domain> [--disable]
DESCRIPTION
Configure a domain to be automatically started at boot.
OPTIONS
[--domain] <string> domain name, id or uuid
--disable disable autostarting
This requires that you defined the domain from a file (i.e., that the domain is persistent rather than transient).
larsks
- 41,276
- 13
- 117
- 170
15
If you get the response:
virsh autostart domainname
"cannot set autostart for transient domain"
then
virsh shutdown domainname
virsh define xmlfile
virsh start domainname
virsh autostart domainname
In my experience on Ubuntu 12.04, this only happens if a virsh undefine has been run. Domains created with virsh create usually allow setting the autostart immediately after creation.
John P. Fisher
- 470
- 4
- 9
-
2This can also happen if you create a domain using an xml file (`virsh create
.xml`), without defining it (`virsh define – Faraj Farook Oct 29 '19 at 14:08.xm`l)
0
I've also seen this happen when you use "create" instead of "define" for a domain.
For example:
virsh --connect qemu:///system create mytest-vm-20130715.xml
virsh --connect qemu:///system autostart mytest-vm
error: Failed to mark domain mytest-vm as autostarted
error: Requested operation is not valid: cannot set autostart for transient domain
FlakRat
- 36
- 3