mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-29 20:11:16 +00:00
qemu: backup: roll-back checkpoint metadata if the checkpoint wasn't taken
We insert the checkpoint metadata into the list of checkpoints prior to actually creating the on-disk bits. If the 'transaction' or any other steps done between inserting the checkpoint and creating the on-disk data fail we'd end up with an unusable checkpoint that would vanish after libvirtd restart. Prevent this by rolling back the metadata if we didn't actually take and record the checkpoint. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
54dd75ec8d
commit
a4877192a1
@ -812,6 +812,8 @@ qemuBackupBegin(virDomainObjPtr vm,
|
|||||||
if (!(actions = virJSONValueNewArray()))
|
if (!(actions = virJSONValueNewArray()))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
|
/* The 'chk' checkpoint must be rolled back if the transaction command
|
||||||
|
* which creates it on disk is not executed or fails */
|
||||||
if (chkdef) {
|
if (chkdef) {
|
||||||
if (qemuCheckpointCreateCommon(priv->driver, vm, &chkdef,
|
if (qemuCheckpointCreateCommon(priv->driver, vm, &chkdef,
|
||||||
&actions, &chk) < 0)
|
&actions, &chk) < 0)
|
||||||
@ -857,9 +859,11 @@ qemuBackupBegin(virDomainObjPtr vm,
|
|||||||
job_started = true;
|
job_started = true;
|
||||||
qemuBackupDiskStarted(vm, dd, ndd);
|
qemuBackupDiskStarted(vm, dd, ndd);
|
||||||
|
|
||||||
if (chk &&
|
if (chk) {
|
||||||
qemuCheckpointCreateFinalize(priv->driver, vm, cfg, chk, true) < 0)
|
virDomainMomentObjPtr tmpchk = g_steal_pointer(&chk);
|
||||||
goto endjob;
|
if (qemuCheckpointCreateFinalize(priv->driver, vm, cfg, tmpchk, true) < 0)
|
||||||
|
goto endjob;
|
||||||
|
}
|
||||||
|
|
||||||
if (pull) {
|
if (pull) {
|
||||||
if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, QEMU_ASYNC_JOB_BACKUP) < 0)
|
if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, QEMU_ASYNC_JOB_BACKUP) < 0)
|
||||||
@ -880,6 +884,10 @@ qemuBackupBegin(virDomainObjPtr vm,
|
|||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
qemuBackupDiskDataCleanup(vm, dd, ndd);
|
qemuBackupDiskDataCleanup(vm, dd, ndd);
|
||||||
|
|
||||||
|
/* if 'chk' is non-NULL here it's a failure and it must be rolled back */
|
||||||
|
qemuCheckpointRollbackMetadata(vm, chk);
|
||||||
|
|
||||||
if (!job_started && nbd_running &&
|
if (!job_started && nbd_running &&
|
||||||
qemuDomainObjEnterMonitorAsync(priv->driver, vm, QEMU_ASYNC_JOB_BACKUP) < 0) {
|
qemuDomainObjEnterMonitorAsync(priv->driver, vm, QEMU_ASYNC_JOB_BACKUP) < 0) {
|
||||||
ignore_value(qemuMonitorNBDServerStop(priv->mon));
|
ignore_value(qemuMonitorNBDServerStop(priv->mon));
|
||||||
|
Loading…
Reference in New Issue
Block a user