I have a QEMU/KVM virtual machine whose virtual disk is a qcow2 file. To create snapshots, I have been using
sudo virsh snapshot-create-as <vm_name> <snapshot_name>
and now I can display them using, for example,
virsh snapshot-list --tree:
$ sudo virsh snapshot-list --tree my_vm snapshot_001 | +- snapshot_002 | +- snapshot_003
I want to rename these snapshots (e.g. from
my_snapshot_00X), but there is no
virsh snapshot-rename command. Both of the possible workarounds I can think of seem to have serious pitfalls, and I would be glad to know if there is a better one.
I could do, for each snapshot that I want to rename:
sudo snapshot-edit <vm_name> <snapshot_name> --rename
and then edit contents of the
<name> element in the resulting XML.
man virsh seems to warn strongly against this (my emphasis):
Note that changing a snapshot name must be done with care, since the contents of some snapshots, such as internal snapshots within a single qcow2 file, are accessible only from the original name.
Because the snapshots, in my case are indeed internal snapshots within a single qcow2 file, it sounds as though using
virsh snapshot-edit could render them inaccessible.
I could, I suppose, use
qemu-img to convert the internal snapshots into external snapshots plus a backing file, and then rename them, and then recombine them into internal snapshots of a single qcow2 file.
But this is non-trivial, and would also require manually editing the VM to restore my ability to use commands like
virsh snapshot-revert (without which, the snapshots are effectively useless). I would be very surprised if there is not a better way.
Compared to the workarounds given above, is there a better way to rename a series of QEMU/KVM internal qcow2 snapshots that have been created with
virsh snapshot-create-as, without losing the ability to run them via