At first I thought it would be stored in /var/lib/libvirt/images/ but as I created snapshots for the centos7 domain, nothing changed in this directory:

drwx--x--x 2 root         root       4096 Feb 29 21:28 .
drwxr-xr-x 7 root         root       4096 Feb 28 23:47 ..
-rw------- 1 libvirt-qemu kvm  5370216574 Feb 29 22:09 centos7-1.qcow2
-rw------- 2 libvirt-qemu kvm  5931597824 Feb 29 22:12 centos7.qcow2
-rw------- 1 root         root 1499267135 Feb 28 21:07 centos7-server.qcow2

Next I checked /var/lib/libvirt/qemu/snapshot/centos7 which showed these xml files:

client2.xml client.xml disks.xml

Which are the names I gave to my snapshots.

Can someone please tell me why snapshots are xml files and not disk images? What are these xml files storing and I'm guessing they need the original qcow2 image which is in my images directory to work and won't work with just any image - is that correct?

2 Answers 2


The xml files represents the snapshot metadata, if you open it you will see something like this (domain definition shortened for brevity):


OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh snapshot-edit
or other application using the libvirt API.

  <memory snapshot='no'/>
    <disk name='hda' snapshot='internal'/>
  <domain type='kvm'>

This file records the name of the snapshot, state of the domain when it was created, creation time, if memory was snapshot as well, and the disks, then the domain definition at that point as well.

This domain definition amounts to the same info you will get with virsh dumpxml your-domain. It's the configuration of your device, CPU, memory, etc. at the point of the snapshot. For example if after the snapshot you changed some device, memory size, etc. this allows you to go back to the exact setup you had back when the snapshot was taken.

Now on the disks section you can see which disk devices where actually snapshot. You expected a disk image to be created but with qcow2 files it works a bit differently.

qcow2 implements Copy-on-write images. On other Copy-on-write filesystems like btrfs this means that the files are not changed in place but rather when modified a copy of them with the changes will be stored somewhere else on the disk.

For qcow2 snapshots, the image is always modified in place but if a snapshot has been created, then within that qcow2 file whenever a file is modified after the snapshot, a copy before the modification is applied will be saved for the snapshot. This means that the image and the snapshots are both within the qcow2 file. (A more in-depth explanation of the qcow2 fileformat and how snapshots work can be found here.

You can list and interact with these disk snapshots (list, revert, create, delete) using the qemu-img command. For example you could list the snapshots like this:

# qemu-img snapshot -l /var/lib/libvirt/qemu/centos7-server.qcow2
Snapshot list:
ID        TAG                 VM SIZE                DATE       VM CLOCK
1         your-snapshot             0 2019-09-02 22:15:58   00:00:00.000

The TAG here should match the name of your snapshot XML files and the name entry inside the XML itself, this is how libvirt knows what snapshot within the qcow2 image it should revert to.

  • I like this explanation. Do you know if this applies for .img images as well? Basically same just different formats? qcow2 and img Because when I use the virsh commands it seems to have the same behaviours for xml, same storage location etc. so the snapshot is attached to the parent img file?
    – gstlouis
    Aug 4, 2021 at 13:31

I wrote a blog post https://www.lorenzobettini.it/2023/04/kvm-virtual-machine-manager-and-virtual-machines-on-external-drives/ about directories used by virt-manager, and how to deal with them in case you want to have machines, configurations, and snapshots stored in other directories or an external drive.

The important directories are /etc/libvirt/qemu and /var/lib/libvirt/qemu/.

You must log in to answer this question.

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