Feb 04

Libvirt and QCow2 Snapshots

This article is for one specific use case I had.  There is a lot more written around snapshots, qemu and libvirt.  For my use case a qcow2 formatted image and KVM virtual machine.  I wanted a way to capture machine state before an OS upgrade.  So that I can roll back or revert in case something goes wrong.  So for my case I do not care about live snapshots.  I can shut the machine down before taking a consistent snapshot of the image.

Specifically I am using what is called an internal qcow2 snapshot.


# virsh snapshot-create-as debian1 pre-update
Domain snapshot pre-update created
# virsh snapshot-list debian1
 Name                 Creation Time             State
 pre-update           2015-02-04 09:22:18 -0600 shutoff

# virsh snapshot-current debian1
  <memory snapshot='no'/>
    <disk name='vda' snapshot='internal'/>
    <disk name='hda' snapshot='no'/>

Start VM and make some changes...and...Shutdown

# virsh snapshot-revert debian1 pre-update

Now start VM and changes should be gone.

** Note when I created the snapshots using virsh they did not show up in virt-manager. Probably needs a refresh in virt-manager. Appears like a bug. When I create a new snapshot in virt-manager I can see both(virsh created and virt-manager created). Or cwhen I ompletely quit virt-manager and re-open I see all.

Deletion of an old snapshot:

# virsh snapshot-delete debian1 pre-update
Domain snapshot pre-update deleted

Comments Off on Libvirt and QCow2 Snapshots