If we are certain that the checkpoint creation failed we remove the
metadata from the list. To allow reusing this in the backup code add a
new helper and export it.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_checkpoint.c | 22 ++++++++++++++++++++--
src/qemu/qemu_checkpoint.h | 4 ++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
index 97bc97bb8e..2fa5c1ae00 100644
--- a/src/qemu/qemu_checkpoint.c
+++ b/src/qemu/qemu_checkpoint.c
@@ -400,6 +400,24 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver,
}
+/**
+ * qemuCheckpointRollbackMetadata:
+ * @vm: domain object
+ * @chk: checkpoint object
+ *
+ * If @chk is not null remove the @chk object from the list of checkpoints of @vm.
+ */
+void
+qemuCheckpointRollbackMetadata(virDomainObjPtr vm,
+ virDomainMomentObjPtr chk)
+{
+ if (!chk)
+ return;
+
+ virDomainCheckpointObjListRemove(vm->checkpoints, chk);
+}
+
+
static virDomainMomentObjPtr
qemuCheckpointCreate(virQEMUDriverPtr driver,
virDomainObjPtr vm,
@@ -415,7 +433,7 @@ qemuCheckpointCreate(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorTransaction(qemuDomainGetMonitor(vm), &actions);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) {
- virDomainCheckpointObjListRemove(vm->checkpoints, chk);
+ qemuCheckpointRollbackMetadata(vm, chk);
return NULL;
}
@@ -441,7 +459,7 @@ qemuCheckpointCreateFinalize(virQEMUDriverPtr driver,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to save metadata for checkpoint %s"),
chk->def->name);
- virDomainCheckpointObjListRemove(vm->checkpoints, chk);
+ qemuCheckpointRollbackMetadata(vm, chk);
return -1;
}
diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h
index 00548beec9..eb85611ea6 100644
--- a/src/qemu/qemu_checkpoint.h
+++ b/src/qemu/qemu_checkpoint.h
@@ -67,3 +67,7 @@ qemuCheckpointCreateFinalize(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg,
virDomainMomentObjPtr chk,
bool update_current);
+
+void
+qemuCheckpointRollbackMetadata(virDomainObjPtr vm,
+ virDomainMomentObjPtr chk);
--
2.24.1