Qcow2 snapshots – snapshot for disk vda unsupported for storage type raw

kvmsnapshotvirtualization

I am running a KVM server (Ubuntu 14.04) and would like to take snapshots of my guests. I was reading how about how to do that in this article. It seemed as if I should be able to take a snapshot of a guest by running the following command:

sudo virsh snapshot-create $GUEST_ID /path/to/snapshot/file.xml

When I tried that (and also tried without specifying a filepath), I got the following error message:

error: unsupported configuration: internal snapshot for disk vda unsupported for storage type raw

When I created my guests, I used the following command to pre-create the disk images:

qemu-img create -f qcow2 -o preallocation=metadata,lazy_refcounts=on $filepath 20G

When I used the command sudo virsh edit $GUEST_ID to see the definition of the guest, it clearly showed "raw" as shown below:

<disk type='file' device='disk'>
  <driver name='qemu' type='raw'/>
  <source file='/home/$USER/kvm/domain.name.img'/>
  <target dev='vda' bus='virtio'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</disk>

Is it possible that I am not actually running qcow2 disk images, or did I enter the command for a snapshot incorrectly? Is there a way I can test to make sure whether my disk images are in a raw or qcow2 format using the CLI only?

Best Answer

There is an error in your libvirt config file:

<driver name='qemu' type='raw'/>

This line must be:

<driver name='qemu' type='qcow2'/>

I just tested this conflict. If you create a qcow2 image file (which can be tested with qemu-img info /home/$USER/kvm/domain.name.img) and configure the libvirt domain for raw then I had expected to get an error message. Instead the qcow2 image file is overwritten by an raw image file.

So you have to shut down the VM, change the configuration, convert the image file (qemu-img convert -f raw -O qcow2 [input filename] [output filename]), and restart the VM.

Related Question