[libvirt-users] Spawn new domains from a snapshot.

NoxDaFox noxdafox at gmail.com
Sun May 27 12:31:11 UTC 2012

I made a couple of tests.

Image A.qcow2:
- 2 Gb file size (the image size is 10Gb)
- OS: Windows XP sp2 installed

I create the image B.qcow2 with A as backing store through 
- 160 Mb file size (image size alway 10Gb)
- OS in the same state as before.
I do some updates to the OS in image B like installing sp3 and I shut 
down the VE

I create the image C.qcow2 with B as backing store through 
- File size 230 Mb
- OS: Windows XP sp3 with all the changes made in image B.

This is extremely powerful in contexts as cloud VM provisioning or 
system tests.
For what I guessed (didn't look at the code yet) libvirt can already set 
up a hierarchy in a way that, given a complete disk image, can build 
several COW images and run a coherent VM merging deltas contained in 
these files.

So shouldn't be hard to do the same procedure with images created from 
As I said in: 
https://www.redhat.com/archives/libvirt-users/2012-May/msg00105.html I 
create an image from a snapshot through qemu-img, I obtain a qcow2 file 
valuable for inspections but not for running a new VE as it doesn't 
contain the whole disk of the original VM.
If I do the same without COW I succeed but I pass from a bunch of 
seconds to several minutes to complete the task as I basically clone the 
whole disk.

A nice solution could be giving the capability to specify in the volume 
XML the source as a snapshot name contained in the running domain.
The internal logic should be able to generate a new qcow2 file that 
knows which backing file has been used to generate the disk the snapshot 
refers to.

To be more clear running the image C I create the snapshot S, from S 
through virStorageVolCreateXML() I create the disk image S.qcow2 which 
contains deltas from C to the moment S has been taken. I can then use 
S.qcow2 to spawn a new VE with changes made from C to S (including 
changes made in B etc obviously).

This should allow, for example, to make so that while C is still running 
I can start other VEs from C disk snapshots; obtaining a dynamic VE 
branching system. Everything through libvirt API.

More information about the libvirt-users mailing list