Safe KVM Snaphots With Valine

KVM (Kernel-based Virtual Machine) is a full virtualization solution for Linux on AMD64 and Intel 64 hardware that is built into recent Linux kernel. It can run multiple, unmodified Windows and Linux guest operating systems.
The KVM hypervisor in RedHat/CentOS Linux is managed with the libvirt API and tools built for libvirt (such as virsh, virt-install, virt-clone or virt-manager ).
Virtual Machines (VMs) are executed and run as multi-threaded Linux processes controlled by these tools.

If you have a KVM host configured which is running several VMs (aka KVM guests) over Logical Volume Manager (LVM), and unless you don’t administrate it, you’ll probably at some point perform sensitive operations within the VM that might break its configuration (Ex: kernel update and compilation of a new GFPS/Lustre client against it). To avoid having to reverse-engineering the performed operation to return to a stable config, it is advisable to test the sensible operation on top of a LVM snapshot of the disk image of the VM.

You can of course create them manually, yet easier the management of these snapshot, I discovered a very useful script named valine from Ryan Sawhill Aroha (ryan on Github) you will want to deploy on all of your KVM hosts.

KVM Snapshot creation

The workflow to setup a new screenshot would be as follows:

123

(host)$> valine # Check current status(host)$> valine <guest> new-snap [sname]# Create a new snaphot <sname> for the KVM guest <guest># By default, <guest>-snap0 is created, and guest <guest> is rebooted on top of it

Now you can connect to the guest VM <guest> to try all you sensitive operations (kernel upgrade, puppet receipts application etc.),

Revert back to the original image

Once you reach a procedure that seems to work and is ready for the real deployment, you can revert to the default LVM disk
image as follows: