]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemuSnapshotForEachQcow2: Refactor
authorPeter Krempa <pkrempa@redhat.com>
Tue, 12 Nov 2024 07:47:29 +0000 (08:47 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 18 Nov 2024 12:51:13 +0000 (13:51 +0100)
commit5ca0552d3166b18f0fb0fee889482b366c865409
tree22424703e0f070c1cc07de531faea9f57cfe3b94
parent5dfd0a0ce8600ac10a44be94551b2c72153191f7
qemuSnapshotForEachQcow2: Refactor

Refactor the function to avoid recursive call to rollback and simplify
calling parameters.

To achieve that most of the fatal checks are extracted into a dedicated
loop that runs before modifying the disk state thus removing the need to
rollback altoghether. Since rollback is still necessary when creation of
the snapshot fails half-way through the rollback is extracted to handle
only that scenario.

Additionally callers would only pass the old 'try_all' argument as true
on all non-creation ("-c") modes. This means that we can infer it from
the operation instead of passing it as an extra argument.

This refactor will also make it much simpler to implement handling of
the NVRAM pflash backing file (in case it's qcow2) for internal
snapshots.

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