I'm using Debian Jessie as a virtual machine host using libvirt/qemu/kvm.

I've set some of the guest virtual machines to automatically start when the host OS boots up, this is working fine.

For maintenance purposes, I'm running "service libvirt-guests stop" to shut all the guests down (but not the host).

Once I've done my maintenance, I want to easily boot all the guests up again (without rebooting the host).

Is there a single command that will start all the guest VMs up again? I'm interested in knowing about both:

  1. a command to start all the autostart-marked guests up again

  2. a command to start all the guests up again that were running before I ran "service libvirt-guests stop"

Rebooting the host OS would achieve #1, but I don't want to reboot the host.

I tried, "service libvirt-guests start" but it doesn't seem to do it.

6 Answers 6


Like @jason-harris solution. But simpler and start only marked for autostart.

for i in $(virsh list --name --autostart --inactive); do virsh start "$i"; done

UPD: I tested it on libvirt 3.2.0 (CentOS 7.4.1708) UPD: Add --inactive thanks to @lpaseen comment

  • 1
    Even simpler one, use xargs also add "--inactive" or it wont' do much since then only already running ones are listed virsh list --name --autostart --inactive | xargs -rn1 virsh start
    – lpaseen
    Commented Sep 17, 2023 at 0:48
#! /bin/bash

xmlfiles=( $(find /etc/libvirt/qemu/autostart/ -name '*.xml') )

for f in "${xmlfiles[@]}" ; do
  domain=$(xml2 < $f | awk -F= '$1 == "/domain/name" {print $2}')

  # only start domain if it's not already running
  if ! virsh list | grep -q " ${domain} .*running" ; then
    virsh start "$domain"
    # optionally reboot domain otherwise
    #virsh reboot "$domain"


This script requires the xml2 utility (in package xml2 in debian and probably ubuntu too).

It uses xml2 to extract the domain name(s) from all XML files in libvirt's qemu autostart directory, and runs virsh start on them if they're not already running.

Save it somewhere in your PATH, as something like virsh-autostart.sh (or whatever makes sense to you) and make it executable with chmod.


I don't believe there is a simple command to do that (but it would be great!).

I do this fairly often and it is usually just a quick script / one line command using a for loop and some awk.

Keep in mind that if your hypervisor is connected to other hypervisors, you might want to sever that link temporarily so you don't inadvertently interfere with other VMs on other hypervisors. I haven't seen many people actually utilize this though, but I wanted to point that out.

For instance, you could type the following to achieve the result you want, assuming you want to turn everything back on. This assumes you are root:

for i in `virsh list --all|awk '{print $2}'|grep -v Name`; do virsh start $i; done

The command breaks down like this:

virsh list --all

Shows all of the virtual machines, whether they are on or not.

awk '{print $2}'|grep -v Name

We are taking out the unneeded columns and only printing the column with the virtual machine names. Then we take out the header row with grep since it isn't actually a virtual machine.

virsh start $i

Turns on the virtual machine.

And this is all wrapped around a general for loop.


I use systemctl restart libvirtd.service. Works without a flaw in CentOS 7 (host).


On Debian Stretch:

systemctl restart libvirtd

didn't do the job. Libvirt actually restarted its service but all qemu processes and the OS's inside kept running.

This worked:

systemctl stop libvirt-guests   # stops VMs
systemctl restart libvirtd      # starts VMs agains

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.

NOTE: Although KVM_AutoBoot does not answer what you want exactly in the way that you want, it can be used to automatically boot KVM's virtual machines defined in a list at server boot or when you you start (systemctl start kvm_autoboot.service) it.

Thanks! =D

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .