Automatically Start VM Created by Virt-Manager – How to Configure

kvm-virtualizationvirtualization

I have created a virtual machine with virt-manager that runs on kvm/qemu. The machine works well when started through virt-manager. However, I would like to be able to start and stop the VM through a script in init.d, so that it comes up and down along with the host. I need to have virt-manager show that the machine is running, and to be able to connect to its console through there.

When I use the command line that is produced by running ps -eaf | grep kvm after starting the vm through virt-manager, I get some console messages about redirected character devices, but the machine does start and runs properly. However, I do not get any indication from virt-manager that it has started. How can I modify the command line to get virt-manager to pick up the running VM? Is there anything else about the command line that should change when starting outside of virt-manager?

Command line is (slightly reformatted for readability):

/usr/bin/kvm -S -M pc-0.12 -enable-kvm -m 512 -smp 1 -name BORON \
-uuid fa7e5fbd-7d8e-43c4-ebd9-1504a4383eb1 \
-chardev socket,id=monitor,path=/var/lib/libvirt/qemu/BORON.monitor,server,nowait \
-monitor chardev:monitor -localtime -boot c \
-drive file=/dev/FS1/BORON,if=ide,index=0,boot=on,format=raw \
-net nic,macaddr=52:54:00:20:0b:fd,vlan=0,name=nic.0 \
-net tap,fd=41,vlan=0,name=tap.0 -chardev pty,id=serial0 -serial chardev:serial0 \
-parallel none -usb -usbdevice tablet -vnc 127.0.0.1:1 -k en-us -vga cirrus

Best Answer

As far as automatically starting/stopping and you're using virsh you can do that like this (as a privileged user)

virsh autostart Domain

I'm not sure why virt manager isn't giving you any output. It does have a connection to the machine hosting machine right? It should show a list of domains if it's connected.