Apparently internal snapshots of a qcow2-based vm are problematic when the vm boots from UEFI. I found that out when my nightly snapshots stopped working after I upgraded a server from stretch to buster.

Testing the effective line of the script with actual values, I got this result:

  #virsh snapshot-create-as --domain server --name serverS0
  error: Operation not supported: internal snapshots of a VM with pflash based firmware are not supported

An internet search of the error message revealed that this problem has been going on for a long time. The new behaviour is to simply not allow the snapshot to take place rather than risk creating a corrupted one.

Fortunately there is a simple workaround. I simply replaced the virsh snapshots with qemu-img snapshots. In my script, this meant changing a few lines like this (VM is the name of the VM while DOW is the day of the week number (0-6) - I put an 'S' between them in naming the snapshot):

from: virsh snapshot-create-as --domain $VM --name ${VM}S$DOW
to: qemu-img snapshot -c ${VM}S$DOW $VM.qcow2

While virsh works with the xml "domain" definition, qemu-img works directly with the qcow2 file. This means the script also has to know where the qcow2 file is. This can be accomplished either by adding the full path to the VM name (which would prevent it from being used in the virsh command to shut down the VM) or cd'ing to the folder. I chose the latter as the simplest.

There's always more than one to do something. In this case, I'm glad qemu-img was there to overcome a bug in libvirt. The other option would be to switch to external snapshots which, apparently, are different enough to not be affected by the internal snapshot bug. However they operate a lot differently and I really don't want to get into them for this application.

Reply via email to