## # To create a snapshot of a qcow2 disk image using 'virsh' ## 1/ Shutdown your guest. (*ensure* it is shut-off) ############## $ virsh shutdown cs81test ############## 2/ If you have a RAW disk image, convert your RAW image to qcow2 (with preallocation) (NOTE: RAW format doesn't support snapshotting yet) ############## $ qemu-img convert -f raw -O qcow2 -o preallocation=metadata /var/lib/libvirt/images/cs81test.img /var/lib/libvirt/images/cs81test.qcow2 $ ############## 3/ Ensure your guest's libvirt xml file(path: /etc/libvirt/qemu/cs81test.xml) reflects the qcow2 disk image ############## . .
############## 4/ (Re-)Define the xml file ############## $ virsh define /etc/libvirt/qemu/cs81test.xml Domain cs81test defined from /etc/libvirt/qemu/cs81test.xml ############## 5/ Snapshotting: Create a simple file like below for snapshotting of the guest. ############## $cat /etc/libvirt/qemu/snapshot-cs81test.xml cs81-inst-aug11 up2date cs81 packages installed. As of Aug-11 ############## 6/ Create snapshot. ############## root@~ $virsh snapshot-create cs81test /etc/libvirt/qemu/snapshot-cs81test.xml Domain snapshot cs81-inst-aug11 created from '/etc/libvirt/qemu/snapshot-cs81test.xml' ############## 7/ List the snapshot ############## root@~ $virsh snapshot-list cs81test Name Creation Time State --------------------------------------------------- cs81-inst-aug11 2011-08-11 18:43:24 +0530 shutoff root@~ $ ############## Optional: 8/ To revert to the snapshot just created above (and then change the state of the VM to 'running') ############## root@~ $ snapshot-revert cs81test cs81-inst-aug11 --running ##############