The logic of saving metadata doesn't have to be in endjob section as
it will only happen if we have successfully created snapshot.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_snapshot.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index ac57d4e90e..46f65b8144 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -1815,10 +1815,10 @@ qemuSnapshotCreateXML(virDomainPtr domain,
* do; we've successfully taken the snapshot, and we are now running
* on it, so we have to go forward the best we can
*/
- snapshot = virGetDomainSnapshot(domain, snap->def->name);
+ if (!(snapshot = virGetDomainSnapshot(domain, snap->def->name)))
+ goto endjob;
- endjob:
- if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
+ if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
if (!redefine || (flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT))
qemuSnapshotSetCurrent(vm, snap);
@@ -1832,13 +1832,17 @@ qemuSnapshotCreateXML(virDomainPtr domain,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to save metadata for snapshot %s"),
snap->def->name);
- virDomainSnapshotObjListRemove(vm->snapshots, snap);
- } else {
- virDomainSnapshotLinkParent(vm->snapshots, snap);
+ goto endjob;
}
- } else if (snap) {
+
+ virDomainSnapshotLinkParent(vm->snapshots, snap);
+ snap = NULL;
+ }
+
+ endjob:
+
+ if (snap)
virDomainSnapshotObjListRemove(vm->snapshots, snap);
- }
qemuDomainObjEndAsyncJob(driver, vm);
--
2.31.1