Autostart is set, yet the VM is shut off after the reboot. libvirtd's journal has the reason: the disk does not exist at boot time.
Symptom
virsh list --all sudo journalctl -b -u libvirtd --no-pager | grep -i autostart Id Name State ------------------------ 2 notes running - db shut off - web1 shut off - web2 shut off - web3 shut off … libvirtd[869]: internal error: Failed to autostart VM 'db': Cannot access storage file '/dev/vgkvm/db-daten': No such file or directory
notes (disk as a file) runs, db (disk in the LVM pool vgkvm) does not.
Diagnosis
Check that the loop device exists once the unit is in place.
losetup -a /dev/loop0: []: (/var/lib/kvm-lvm.img)
Causes
/dev/vgkvm/…Volume group on a loop device
In the lab the volume group vgkvm lives in a file attached as a block device with losetup. Nobody recreates that loop device after a reboot.
Pool inactivePool and VM start into nothing
Without the loop device there is no volume group, the pool vgkvm stays inactive, and the disk /dev/vgkvm/db-daten is missing at autostart.
Fix
sudo systemctl daemon-reload sudo systemctl enable --now kvm-lvm-loop.service losetup -a Created symlink /etc/systemd/system/multi-user.target.wants/kvm-lvm-loop.service → /etc/systemd/system/kvm-lvm-loop.service. /dev/loop0: []: (/var/lib/kvm-lvm.img) virsh pool-start vgkvm virsh pool-autostart vgkvm virsh start db Pool vgkvm started Pool vgkvm marked as autostarted Domain 'db' started
Don't: Only check autostart while the host is running. A real reboot is the only proof that it works.
KVM hands-on, Day 8: life cycle, snapshots and backups – autostart tested with a real host reboot.
Go to day 8 →
FAQ
How do I see which VMs have autostart?
virsh list --all --autostart shows only the domains with autostart set.
Do I need the unit with a real disk too?
No. With a real partition or disk as physical volume, LVM activates the volume group at boot by itself.