On Tue, Aug 23, 2022 at 18:32:13 +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_snapshot.c | 46 ++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index c1c67ac445..b5e6a87566 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2281,6 +2281,35 @@ qemuSnapshotChildrenReparent(void *payload,
}
+static int
+qemuSnapshotDeleteSingle(virDomainObj *vm,
+ virDomainMomentObj *snap,
+ virQEMUDriver *driver,
+ bool metadata_only)
+{
'driver' can be extracted from the the private data of 'vm', removing
the need to pass it in. Doing that will also remove the need to pass it
in via 'struct qemuSnapshotDeleteAllData' in upcoming patch.
+ g_autoptr(virQEMUDriverConfig) cfg =
virQEMUDriverGetConfig(driver);
+
+ if (snap->nchildren) {
+ virQEMUMomentReparent rep;
+
+ rep.dir = cfg->snapshotDir;
+ rep.parent = snap->parent;
+ rep.vm = vm;
+ rep.err = 0;
+ rep.xmlopt = driver->xmlopt;
+ rep.writeMetadata = qemuDomainSnapshotWriteMetadata;
+ virDomainMomentForEachChild(snap,
+ qemuSnapshotChildrenReparent,
+ &rep);
+ if (rep.err < 0)
+ return -1;
+ virDomainMomentMoveChildren(snap, snap->parent);
+ }
+
+ return qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only);
You actually may be better off refactoring qemuDomainSnapshotDiscard
first to remove the argument.