]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Avoid use of '-loadvm' commandline argument for internal snapshot reversion
authorPeter Krempa <pkrempa@redhat.com>
Thu, 7 Nov 2024 09:48:10 +0000 (10:48 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 18 Nov 2024 12:51:13 +0000 (13:51 +0100)
commitec8be9acebdae084e46ec91d67f37cf13a24609d
tree5cb2e70f2666619c1e841259f78cd1e421bfc54e
parent2da32ff468ac7936f190ed86fe3a7188a1972782
qemu: Avoid use of '-loadvm' commandline argument for internal snapshot reversion

The '-loadvm' commandline parameter has exactly the same semantics as
the HMP 'loadvm' command. This includes the selection of which block
device is considered to contain the 'vmstate' section.

Since libvirt recently switched to the new QMP commands which allow a
free selection of where the 'vmstate' is placed, snapshot reversion will
no longer work if libvirt's algorithm disagrees with qemu's. This is the
case when the VM has UEFI NVRAM image, in qcow2 format, present.

To solve this we'll use the QMP counterpart 'snapshot-load' to load the
snapshot instead of using '-loadvm'. We'll do this before resuming
processors after startup of qemu and thus the behaviour is identical to
what we had before.

The logic for selecting the images now checks both the snapshot metadata
and the VM definition. In case images not covered by the snapshot
definition do have the snapshot it's included in the reversion, but it's
fatal if the snapshot is not present in a disk covered in snapshot
metadata.

The vmstate is selected based on where it's present as libvirt doesn't
store this information.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_process.c
src/qemu/qemu_snapshot.c
src/qemu/qemu_snapshot.h