How to start a new instance of QEMU based on the same image and snapshot

kvm-virtualizationlibvirtqemu

I have a QEMU image (qcow2) with a snapshot stored in it. Right now I'm using libvirt to start it.

However, I want to be able to run more than one instance of the same image snapshot.

I guess I can do that by cloning the virtual-hd and installing/creating a new domain (virsh) and then running revert from snapshot. But I want to be able to do that pretty much "on-the-fly" with as little as possible latency from the time I decide I need to run another instance of image X to the time that instance is running from the stored snapshot. (I wan't to avoid writing to the hard-drive as possible)

Anyone did anything like that? I started thinking maybe libvirt is not low-level enough for this?

Best Answer

Libvirt supports this very well. Create one disk image that has everything you want to share between your domains. This will be your read-only backing file. When creating volumes for new domains, set backingStore to refer to it. The new volume you're creating for each domain will start out taking zero bytes but grow as you make changes.