I've created a qcow2 image snapshot of a KVM guest image. I've modified the XML file for the image to use the new snapshot file but when I halt and restart the guest, and create a file on the guest the new snapshot file is not updated. Here are the details.

(1) Create the snapshot.

qemu-img create -f qcow2 -b /var/lib/libvirt/images/myguest.img /var/lib/libvirt/images/myguest.qcow2.snap

(2) Edit two lines in /etc/libvirt/qemu/myguest.xml

<driver name='qemu' type='qcow2' cache='none'/>
<source file='/var/lib/libvirt/images/myguest.qcow2.snap'/>

(3) ssh to myguest and halt it.

(4) Confirm with "virsh list" that the guest is indeed no longer running."

(5) Restart the guest.

virsh start myguest

myguest.qcow2.snap was indeed created by qemu-img with an expected small size of 197K but, even if I create files in myguest the .snap file is never written to.

2 Answers 2


After you modify the XML file you should

virsh define myguest.xml

That will cause libvirtd to detect the changes so that the next virsh start will start up with the new values.

  • 1
    That did it. Thanks! Time to go read the documentation.
    – Sol
    Commented Jul 22, 2016 at 0:28

Instead of editing /etc/libvirt/qemu/myguest.xml directly, use

virsh edit myguest

When you exit the editor, virsh will notify libvirtd that the file has been changed. The next guest restart will use the new values.

If virsh edit uses the "wrong" editor, remember you can set it like this

EDITOR=vi virsh edit myguest
  • 1
    +1. for some things, like adding an extra disk, you don't even have to restart the VM, BTW, another useful method is: virsh dumpxml myguest | xml-editing-tool-of-your-choice... | virsh define /dev/stdin. You could use xmlstarlet, xml2 | awk/sed/perl/etc | 2xml or a custom script in perl, python, whatever (e.g. I wrote a simple perl script to add <serial>...</serial> tags to raw disk devices that didn't already have them).
    – cas
    Commented Jul 23, 2016 at 6:35

You must log in to answer this question.

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