Previously the reparent happened before the actual snapshot deletion.
This change moves the code closer to the rest of the code handling
snapshot metadata when deletion happens. This makes the metadate
deletion happen after the data files are deleted.
Following patch will extract it into separate function
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_snapshot.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 3eb0ec2998..e7893f285a 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2323,6 +2323,25 @@ qemuSnapshotDiscard(virQEMUDriver *driver,
}
}
+ if (update_parent) {
+ 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);
+ }
+ }
+
snapFile = g_strdup_printf("%s/%s/%s.xml", cfg->snapshotDir,
vm->def->name,
snap->def->name);
@@ -2382,24 +2401,6 @@ qemuSnapshotDeleteSingle(virDomainObj *vm,
{
qemuDomainObjPrivate *priv = vm->privateData;
virQEMUDriver *driver = priv->driver;
- 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 qemuSnapshotDiscard(driver, vm, snap, true, metadata_only);
}
--
2.39.0