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 -k en-us -vga cirrus

6 Answers 6


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.


Open the VM display, click View->Details

enter image description here

Select Boot Options, and tick Start virtual machine on host boot up

enter image description here


The answer by Tim is the way to go, and virsh allows you to do many useful things besides that.

To set a virtual machine to be automatically started, you use:

# virsh autostart <domain-id>

The <domain-id> is either the virtual machine's number, UUID or a "friendly name" like "debian1", which you entered in virt-manager.

To get a list of virtual machines (numbers and names), use:

# virsh list --all

In my case I get:

 Id Name                 State
  1 other                running
  2 other-clone          running

So I've used:

# virsh autostart other

install virsh then

virsh list                    (this will print list of your VMs)
virsh dominfo your_vm_name    (get info about selected VM)
virsh autostart your_vm_name  (set autostart of selected VM)
  • if VM stuck at grub, virt-viewer your_vm_name, and boot up. After that, change /etc/default/grub, make sure that GRUB_TIMEOUT=0. then update-grub Jan 25, 2013 at 6:56

You can also place a symlink to the guest domxml in /etc/libvirt/qemu/autostart:

Will look like this for a VM named "test":
test.xml -> /etc/libvirt/qemu/test.xml


You can also use KVM_AutoBoot ( https://github.com/eduardolucioac/kvm_autoboot ) to start one or several virtual machines at server boot using KVM (libvirt). It is also possible to define an interval between the start of a virtual machine and the next one.

Thanks! =D

  • FWIW the link says "Currently KVM_AutoBoot is only compatible with CentOS 7, however adjusting it to work with other distros will be simple."
    – Sparhawk
    Apr 12 at 16:54

You must log in to answer this question.