[libvirt-users] some problem with snapshot by libvirt

Hi,all,i am using libvirt to manage my vm,in these days i am testing the libvirt snapshot ,but meet some problem: the snapshot was created from this command: snapshot-create-as win7 --disk-only --diskspec vda,snapshot=external --diskspec hda,snapshot=no but when i tried to revert from the snapshot which created from the above command ,i got error below: virsh # snapshot-revert win7 1338041515 --force error: unsupported configuration: revert to external disk snapshot not supported yet version: virsh # version Compiled against library: libvir 0.9.4 Using library: libvir 0.9.4 Using API: QEMU 0.9.4 Running hypervisor: QEMU 1.0.93

On 05/27/2012 06:39 PM, xingxing gao wrote:
Hi,all,i am using libvirt to manage my vm,in these days i am testing the libvirt snapshot ,but meet some problem:
the snapshot was created from this command: snapshot-create-as win7 --disk-only --diskspec vda,snapshot=external --diskspec hda,snapshot=no
but when i tried to revert from the snapshot which created from the above command ,i got error below:
virsh # snapshot-revert win7 1338041515 --force error: unsupported configuration: revert to external disk snapshot not supported yet
Yep. You've run into a case where I haven't yet been able to code things. The problem is that reverting to a disk image has a question - you are starting with two files (the snapshot backing file and the new qcow2 wrapper), but the moment you reload the backing file for modification, you invalidate the qcow2 wrapper. There are two sane options - create yet another qcow2 wrapper around the same backing file, or delete the qcow2 wrapper as part of reverting to the snapshot, but we would probably need two new flags to the virDomainRevertToSnapshot API to select one of these two behaviors. In the meantime, the only way to revert to a disk-only snapshot is to manually edit the domain XML to match what you want to do, possibly with manual qemu-img operations as well. Help in writing the patches to improve the functionality would be welcome. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

to create snapshot ,I did step below: virsh snapshot-create-as centos snap1 --disk-only --atomic --no-metadata virsh snapshot-create-as centos snap2 --disk-only ...... ........................ virsh snapshot-creates-as centos snap10 ..... then i got 10 snapshot of a vm, to revert, i just did the follow step: 1 destroy centos 2 editor="sed -i 's/centosdisk.snap10/centosdisk.snap1/g'" virsh edit centos 3 rm -f centos.snap{2,3,4,5,6.....} 4 start centos is these steps correct? and another question is ,when i revert to a snapshot,some files of the vm's system missing,does this have any relation with the disk cache mode (writeback,writethrough,none,etc.)???how could i avoid that happen?? thanks.

to create snapshot ,I did step below: virsh snapshot-create-as centos snap1 --disk-only --atomic --no-metadata virsh snapshot-create-as centos snap2 --disk-only ...... ........................ virsh snapshot-creates-as centos snap10 ..... then i got 10 snapshot of a vm, to revert, i just did the follow step: 1 destroy centos 2 editor="sed -i 's/centosdisk.snap10/centosdisk.snap1/g'" virsh edit centos 3 rm -f centos.snap{2,3,4,5,6.....} 4 start centos is these steps correct? and another question is ,when i revert to a snapshot,some files of the vm's system missing,does this have any relation with the disk cache mode (writeback,writethrough,none,etc.)???how could i avoid that happen?? thanks.

thanks , does qemu-ga support centos6.2 and windows server 2008 vm system? how could i get it in a convenient way?build it from code by end user? 2012/5/30 xingxing gao <itxx00@gmail.com>:
to create snapshot ,I did step below: virsh snapshot-create-as centos snap1 --disk-only --atomic --no-metadata virsh snapshot-create-as centos snap2 --disk-only ...... ........................ virsh snapshot-creates-as centos snap10 ..... then i got 10 snapshot of a vm, to revert, i just did the follow step: 1 destroy centos 2 editor="sed -i 's/centosdisk.snap10/centosdisk.snap1/g'" virsh edit centos 3 rm -f centos.snap{2,3,4,5,6.....} 4 start centos is these steps correct? and another question is ,when i revert to a snapshot,some files of the vm's system missing,does this have any relation with the disk cache mode (writeback,writethrough,none,etc.)???how could i avoid that happen?? thanks.

On 05/29/2012 10:22 AM, xingxing gao wrote:
to create snapshot ,I did step below: virsh snapshot-create-as centos snap1 --disk-only --atomic --no-metadata virsh snapshot-create-as centos snap2 --disk-only ...... ........................ virsh snapshot-creates-as centos snap10 ..... then i got 10 snapshot of a vm, to revert, i just did the follow step: 1 destroy centos 2 editor="sed -i 's/centosdisk.snap10/centosdisk.snap1/g'" virsh edit centos 3 rm -f centos.snap{2,3,4,5,6.....}
Yes, that will be sufficient to revert to the state of the first disk snapshot, and on booting the 'centos' VM, your domain will have to run fsck in order to recover to the fact that the file system was not in a clean state at the time of the snapshot (basically, booting from your disk snapshot is the same as booting as if you had yanked the power cord).
4 start centos is these steps correct? and another question is ,when i revert to a snapshot,some files of the vm's system missing,does this have any relation with the disk cache mode (writeback,writethrough,none,etc.)???how could i avoid that happen??
You can install the qemu-ga guest agent in the guest, wire it up in the host XML describing that guest, and add the --quiesce option to your snapshot-create-as command in an effort to have the guest freeze file systems before taking the snapshot. The end result will be that the file system is in a sane state (as if you had cleanly shut down), rather than in an incomplete state (as if you had yanked the power cord). I know that qemu-ga is available as part of the latest Fedora package, and that it was designed to be compiled for older Linux and also for Windows guests, although I don't personally have a good pointer for where to get the best version of qemu-ga for your specific guests. Maybe others can chime in here. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

thanks,i'll keep looking for it and share with others. 2012/5/30 Eric Blake <eblake@redhat.com>:
On 05/29/2012 10:22 AM, xingxing gao wrote:
to create snapshot ,I did step below: virsh snapshot-create-as centos snap1 --disk-only --atomic --no-metadata virsh snapshot-create-as centos snap2 --disk-only ...... ........................ virsh snapshot-creates-as centos snap10 ..... then i got 10 snapshot of a vm, to revert, i just did the follow step: 1 destroy centos 2 editor="sed -i 's/centosdisk.snap10/centosdisk.snap1/g'" virsh edit centos 3 rm -f centos.snap{2,3,4,5,6.....}
Yes, that will be sufficient to revert to the state of the first disk snapshot, and on booting the 'centos' VM, your domain will have to run fsck in order to recover to the fact that the file system was not in a clean state at the time of the snapshot (basically, booting from your disk snapshot is the same as booting as if you had yanked the power cord).
4 start centos is these steps correct? and another question is ,when i revert to a snapshot,some files of the vm's system missing,does this have any relation with the disk cache mode (writeback,writethrough,none,etc.)???how could i avoid that happen??
You can install the qemu-ga guest agent in the guest, wire it up in the host XML describing that guest, and add the --quiesce option to your snapshot-create-as command in an effort to have the guest freeze file systems before taking the snapshot. The end result will be that the file system is in a sane state (as if you had cleanly shut down), rather than in an incomplete state (as if you had yanked the power cord).
I know that qemu-ga is available as part of the latest Fedora package, and that it was designed to be compiled for older Linux and also for Windows guests, although I don't personally have a good pointer for where to get the best version of qemu-ga for your specific guests. Maybe others can chime in here.
-- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Eric Blake <eblake@...> writes:
On 05/27/2012 06:39 PM, xingxing gao wrote:
Hi,all,i am using libvirt to manage my vm,in these days i am testing the libvirt snapshot ,but meet some problem:
the snapshot was created from this command: snapshot-create-as win7 --disk-only --diskspec vda,snapshot=external --diskspec hda,snapshot=no
but when i tried to revert from the snapshot which created from the above command ,i got error below:
virsh # snapshot-revert win7 1338041515 --force error: unsupported configuration: revert to external disk snapshot not supported yet
Yep. You've run into a case where I haven't yet been able to code things. The problem is that reverting to a disk image has a question - you are starting with two files (the snapshot backing file and the new qcow2 wrapper), but the moment you reload the backing file for modification, you invalidate the qcow2 wrapper. There are two sane options - create yet another qcow2 wrapper around the same backing file, or delete the qcow2 wrapper as part of reverting to the snapshot, but we would probably need two new flags to the virDomainRevertToSnapshot API to select one of these two behaviors. In the meantime, the only way to revert to a disk-only snapshot is to manually edit the domain XML to match what you want to do, possibly with manual qemu-img operations as well.
Help in writing the patches to improve the functionality would be welcome.
Has the issue ( revert to external disk snapshot ) been solved in later versions of libvirt? I am using: Compiled against library: libvirt 1.2.2 Using library: libvirt 1.2.2 Using API: QEMU 1.2.2 Running hypervisor: QEMU 2.1.92 On trying to revert to an external snapshot, Getting the error: revert to external disk snapshot not supported yet If not is there any alternate.

On Fri, Nov 21, 2014 at 07:51:33PM +0000, Payes wrote:
Eric Blake <eblake@...> writes:
[. . .]
Yep. You've run into a case where I haven't yet been able to code things. The problem is that reverting to a disk image has a question - you are starting with two files (the snapshot backing file and the new qcow2 wrapper), but the moment you reload the backing file for modification, you invalidate the qcow2 wrapper. There are two sane options - create yet another qcow2 wrapper around the same backing file, or delete the qcow2 wrapper as part of reverting to the snapshot, but we would probably need two new flags to the virDomainRevertToSnapshot API to select one of these two behaviors. In the meantime, the only way to revert to a disk-only snapshot is to manually edit the domain XML to match what you want to do, possibly with manual qemu-img operations as well.
Help in writing the patches to improve the functionality would be welcome.
Has the issue ( revert to external disk snapshot ) been solved in later versions of libvirt?
It's not merely an "issue". As Eric stated above, it's tricky and care needs to be taken when dealing with external snapshots, where you have multiple files in play.
I am using: Compiled against library: libvirt 1.2.2 Using library: libvirt 1.2.2
If it's possible in your environment, you might want to move to the latest release libvirt-1.2.10
Using API: QEMU 1.2.2 Running hypervisor: QEMU 2.1.92
On trying to revert to an external snapshot, Getting the error: revert to external disk snapshot not supported yet
If not is there any alternate.
There is more information in the below wikis on methods to deal with external snapshots, ways to shorten disk image chains etc with some possible scenarios http://wiki.libvirt.org/page/I_created_an_external_snapshot,_but_libvirt_won... http://wiki.libvirt.org/page/Live-merge-an-entire-disk-image-chain-including... -- /kashyap
participants (4)
-
Eric Blake
-
Kashyap Chamarthy
-
Payes
-
xingxing gao