I am using KVM, and use/manage my VMs with virt-manager. But I asked myself this question: how can create or revert some snapshot?
I'm giving examples for qcow2 disk images and commands are made with virsh.
Internal Disk Snapshots
You can list available VM with virsh in order to know their name:
$ virsh list
Then you can check if there already is existing shapshots for this VM:
$ virsh snapshot-list vmname
Next there is two possibilities to make a snapshot:
- create a XML snapshot description file to specify the name and description of the snapshot
- or let libvirt choose a name and no description
The XML snapshot description file must look like the following:
Make a snapshot with an XML file:
$ virsh snapshot-create vmname /path/to/description.xml
Or make a snapshot without description file:
$ virsh snapshot-create vmname
Note: this is much more faster to make a snapshot while the VM is stoped. But it's also possible to make a snapshot while the VM is running even if it's more slow.
If you want to see some informations about the VM and snapshots you can run:
$ qemu-img info /path/to/disk/image/vmname.qcow2
To revert the VM to a snapshot, for example run:
$ virsh snapshot-revert vmname vmname-snapshot1