[libvirt] snapshots and LVM

Hi. I've just tested the snapshot function, which seems to work, but for now, is limited to qcow2 images. Are there any plans to add LVM based snapshots ? I know LVM would have some limitations, but, with recent distribs (F13, RHEL6 at least), as snapshots can be merged back into the original LV, I think we could have at least some snapshots function. Basically, the domain could be paused, then, the memory can be dumped in a separated file (as a virsh save do), then, all LVM based disks (and qcow2 based) could be snapshoted, then, the domain could be reloaded from the saved state. (or even just resumed, if the save function don't destroy it like a virsh save does) LVM gives some (a lot of ?) performance improvements over qcow2, and I think snapshots would be a lot faster (on my tests, it takes 4 or 5 minutes to snapshot a simple ubuntu guest on qcow2, and even longer to revert). There would still be some limitations, like: - check if lvconvert support merging before we create the snapshots - size of snapshots are fixed, should libvirt monitor the % used, and auto-grow when needed ? - there would be no support for snapshot of snapshot Any thoughts ? Regards, Daniel -- Daniel Berteaud FIREWALL-SERVICES SARL. Société de Services en Logiciels Libres Technopôle Montesquieu 33650 MARTILLAC Tel : 05 56 64 15 32 Fax : 05 56 64 15 32 Mail: daniel@firewall-services.com Web : http://www.firewall-services.com

On 05/11/2010 01:31 PM, Daniel Berteaud wrote:
Hi.
I've just tested the snapshot function, which seems to work, but for now, is limited to qcow2 images.
Are there any plans to add LVM based snapshots ?
I know LVM would have some limitations, but, with recent distribs (F13, RHEL6 at least), as snapshots can be merged back into the original LV, I think we could have at least some snapshots function.
Basically, the domain could be paused, then, the memory can be dumped in a separated file (as a virsh save do), then, all LVM based disks (and qcow2 based) could be snapshoted, then, the domain could be reloaded from the saved state. (or even just resumed, if the save function don't destroy it like a virsh save does)
LVM gives some (a lot of ?) performance improvements over qcow2, and I think snapshots would be a lot faster (on my tests, it takes 4 or 5 minutes to snapshot a simple ubuntu guest on qcow2, and even longer to revert).
There would still be some limitations, like: - check if lvconvert support merging before we create the snapshots - size of snapshots are fixed, should libvirt monitor the % used, and auto-grow when needed ? - there would be no support for snapshot of snapshot
Any thoughts ?
It's certainly something that would be nice to see. I even have FIXME comments in the code about supporting LVM snapshots; I just haven't had time to take any look at it. If you have time/interest, I'd be happy to review patches doing it! -- Chris Lalancette

Le mardi 11 mai 2010 à 13:39 -0400, Chris Lalancette a écrit :
It's certainly something that would be nice to see. I even have FIXME comments in the code about supporting LVM snapshots; I just haven't had time to take any look at it. If you have time/interest, I'd be happy to review patches doing it!
I saw your comments in the snapshot code, I was just waiting for snapshot merging to be available to start talking about LVM snapshot support (because, without merging, snapshots are not very useful ;)) I'm really interested in this support, because until now, on only use LVM backends for my guests (mainly for performances, but also because I find it easier to take live backups). Unfortunately, my C skills are near 0, so I may help with design and tests, but not coding. Regards, Daniel -- Daniel Berteaud FIREWALL-SERVICES SARL. Société de Services en Logiciels Libres Technopôle Montesquieu 33650 MARTILLAC Tel : 05 56 64 15 32 Fax : 05 56 64 15 32 Mail: daniel@firewall-services.com Web : http://www.firewall-services.com

On 05/11/2010 02:01 PM, Daniel Berteaud wrote:
Le mardi 11 mai 2010 à 13:39 -0400, Chris Lalancette a écrit :
It's certainly something that would be nice to see. I even have FIXME comments in the code about supporting LVM snapshots; I just haven't had time to take any look at it. If you have time/interest, I'd be happy to review patches doing it!
I saw your comments in the snapshot code, I was just waiting for snapshot merging to be available to start talking about LVM snapshot support (because, without merging, snapshots are not very useful ;))
Well, it does support merging, to a degree, though it's an implicit feature in the way the other snapshot mechanisms work. That is, if you do something like: Base Image -> snap1 -> snap2 -> snap3 And now delete snap2, the changes from snap2 are automatically merged into snap3 to keep snap3 a viable snapshot. I think we'll have to explicitly do this for LVM (though I'm not sure; my experience with LVM snapshotting is 0). Besides this implicit merging action, do you want/need the ability to manually merge snapshots? What's your use-case, so I can understand it better? -- Chris Lalancette

Le mardi 11 mai 2010 à 14:14 -0400, Chris Lalancette a écrit :
Well, it does support merging, to a degree,
Merging a LVM snapshot back into the original LV is only available since kernel 2.6.32 (or .33, don't remember), and with some recent version of device-mapper and lvm2
though it's an implicit feature in the way the other snapshot mechanisms work. That is, if you do something like: Base Image -> snap1 -> snap2 -> snap3
That's not possible, LVM doesn't support snpshot of snapshot, but you can have Base image -> snap1 -> snap2 -> snap3 each snapshot can only be based on the original LV. The idea with LVM would be to always run the guest on the original LV for this reason (so we can take a snapshot when we want). If we want to revert a guest to a snapshot, we have to merge it back into the original LV. Merging a LVM snapshot back into the original LV should be almost instantaneous, and preserve all the other snapshots.
And now delete snap2, the changes from snap2 are automatically merged into snap3 to keep snap3 a viable snapshot.
I think we'll have to explicitly do this for LVM (though I'm not sure; my experience with LVM snapshotting is 0).
Besides this implicit merging action, do you want/need the ability to manually merge snapshots? What's your use-case, so I can understand it better?
When I talk about merging a snapshot in LVM (or "rollback"), it's equivalent to revert in libvirt snapshot terminology. Regards -- Daniel Berteaud FIREWALL-SERVICES SARL. Société de Services en Logiciels Libres Technopôle Montesquieu 33650 MARTILLAC Tel : 05 56 64 15 32 Fax : 05 56 64 15 32 Mail: daniel@firewall-services.com Web : http://www.firewall-services.com

On Tue, May 11, 2010 at 2:46 PM, Daniel Berteaud < daniel@firewall-services.com> wrote:
Le mardi 11 mai 2010 à 14:14 -0400, Chris Lalancette a écrit :
Well, it does support merging, to a degree,
Merging a LVM snapshot back into the original LV is only available since kernel 2.6.32 (or .33, don't remember), and with some recent version of device-mapper and lvm2
though it's an implicit feature in the way the other snapshot mechanisms work. That is, if you do something like: Base Image -> snap1 -> snap2 -> snap3
That's not possible, LVM doesn't support snpshot of snapshot, but you can have
Base image -> snap1 -> snap2 -> snap3
each snapshot can only be based on the original LV. The idea with LVM would be to always run the guest on the original LV for this reason (so we can take a snapshot when we want).
If we want to revert a guest to a snapshot, we have to merge it back into the original LV. Merging a LVM snapshot back into the original LV should be almost instantaneous, and preserve all the other snapshots.
This new feature sounds cool. I just had a try, found a problem, when merging a LVM snapshot: lvconvert says: Can't merge over open origin volume Merging of snapshot snap0 will start next activation. The origin volume is open by QEMU, although the VM is already stoped(by Issuing 'stop' command in QEMU monitor) LVM merging feature doesn't support merge when the origin volume is opened? What's the mean of next activation? From the patch ( http://people.redhat.com/msnitzer/patches/snapshot-merge/lvm2/LVM2-2.02.55/l...), looks like "lvchange --refresh orig_lvm" will active it? I did it, but no way...
And now delete snap2, the changes from snap2 are automatically merged into snap3 to keep snap3 a viable snapshot.
I think we'll have to explicitly do this for LVM (though I'm not sure; my experience with LVM snapshotting is 0).
Besides this implicit merging action, do you want/need the ability to manually merge snapshots? What's your use-case, so I can understand it better?
When I talk about merging a snapshot in LVM (or "rollback"), it's equivalent to revert in libvirt snapshot terminology.
Regards
-- Daniel Berteaud FIREWALL-SERVICES SARL. Société de Services en Logiciels Libres Technopôle Montesquieu 33650 MARTILLAC Tel : 05 56 64 15 32 Fax : 05 56 64 15 32 Mail: daniel@firewall-services.com Web : http://www.firewall-services.com
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Le mardi 11 mai 2010 à 19:06 -0400, edison a écrit :
This new feature sounds cool. I just had a try, found a problem, when merging a LVM snapshot: lvconvert says: Can't merge over open origin volume Merging of snapshot snap0 will start next activation.
The origin volume is open by QEMU, although the VM is already stoped(by Issuing 'stop' command in QEMU monitor)
Of course, you cannot do this while a VM is running (even stopped). To revert to a snapshot, you need to destroy the domain, start the snapshot merge with lvconvert (there's also the possibility to tag several snapshot, and to revert all of them with a simple lvconvert --merge @tag). Now, you need to de-activate/re-activate the LV, so the merge can start (with lvchange -an vg/lv, lvchange -ay vg/lv). Then, libvirt could restore the state of the domain, associated with the snapshot if the domain was active at the time it was taken. Regards
LVM merging feature doesn't support merge when the origin volume is opened? What's the mean of next activation? From the patch (http://people.redhat.com/msnitzer/patches/snapshot-merge/lvm2/LVM2-2.02.55/l...), looks like "lvchange --refresh orig_lvm" will active it? I did it, but no way...
-- Daniel Berteaud FIREWALL-SERVICES SARL. Société de Services en Logiciels Libres Technopôle Montesquieu 33650 MARTILLAC Tel : 05 56 64 15 32 Fax : 05 56 64 15 32 Mail: daniel@firewall-services.com Web : http://www.firewall-services.com
participants (3)
-
Chris Lalancette
-
Daniel Berteaud
-
edison