KVM/QEMU/libvirt - how to use as immutable/temporary VM?

Posted by exquisitesunshine@reddit | linuxadmin | View on Reddit | 6 comments

I need to run bare minimum fresh install of a distro for testing. QEMU supports temporary snapshots but how do you use this with KVM/libvirt? Currently I use qemu-img to create a .qcow2 image and virt-install to use that image to install/run the VM.

I suppose I could create a snapshot of the image, run the VM, then delete the snapshot, but this seems more expensive than using QEMU's native way of doing this. Ideally the backing VM is on disk and I'm running the immutable VM on tmpfs so I can start a new VM frequently without wearing out my SSD.

Tools like Distrobox or cloud images are not suitable for me because they are already preinstalled.