提交 cbaee219 编写于 作者: P Peter Krempa

qemu: checkpoint: Extract finalizing steps of checkpoint creation

Extract the linking and saving bits of checkpoint creation into
qemuCheckpointCreateFinalize so that qemuCheckpointCreateXML is a bit
simpler and also makes it reusable in the backup code.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 0ebc74d3
...@@ -429,6 +429,34 @@ qemuCheckpointCreate(virQEMUDriverPtr driver, ...@@ -429,6 +429,34 @@ qemuCheckpointCreate(virQEMUDriverPtr driver,
} }
int
qemuCheckpointCreateFinalize(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virQEMUDriverConfigPtr cfg,
virDomainMomentObjPtr chk,
bool update_current)
{
if (update_current)
virDomainCheckpointSetCurrent(vm->checkpoints, chk);
if (qemuCheckpointWriteMetadata(vm, chk, driver->caps,
driver->xmlopt,
cfg->checkpointDir) < 0) {
/* if writing of metadata fails, error out rather than trying
* to silently carry on without completing the checkpoint */
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to save metadata for checkpoint %s"),
chk->def->name);
virDomainCheckpointObjListRemove(vm->checkpoints, chk);
return -1;
}
virDomainCheckpointLinkParent(vm->checkpoints, chk);
return 0;
}
virDomainCheckpointPtr virDomainCheckpointPtr
qemuCheckpointCreateXML(virDomainPtr domain, qemuCheckpointCreateXML(virDomainPtr domain,
virDomainObjPtr vm, virDomainObjPtr vm,
...@@ -486,22 +514,8 @@ qemuCheckpointCreateXML(virDomainPtr domain, ...@@ -486,22 +514,8 @@ qemuCheckpointCreateXML(virDomainPtr domain,
if (!chk) if (!chk)
goto endjob; goto endjob;
if (update_current) if (qemuCheckpointCreateFinalize(driver, vm, cfg, chk, update_current) < 0)
virDomainCheckpointSetCurrent(vm->checkpoints, chk);
if (qemuCheckpointWriteMetadata(vm, chk, driver->caps,
driver->xmlopt,
cfg->checkpointDir) < 0) {
/* if writing of metadata fails, error out rather than trying
* to silently carry on without completing the checkpoint */
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to save metadata for checkpoint %s"),
chk->def->name);
virDomainCheckpointObjListRemove(vm->checkpoints, chk);
goto endjob; goto endjob;
}
virDomainCheckpointLinkParent(vm->checkpoints, chk);
/* If we fail after this point, there's not a whole lot we can do; /* If we fail after this point, there's not a whole lot we can do;
* we've successfully created the checkpoint, so we have to go * we've successfully created the checkpoint, so we have to go
......
...@@ -61,3 +61,10 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver, ...@@ -61,3 +61,10 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver,
virDomainCheckpointDefPtr *def, virDomainCheckpointDefPtr *def,
virJSONValuePtr *actions, virJSONValuePtr *actions,
virDomainMomentObjPtr *chk); virDomainMomentObjPtr *chk);
int
qemuCheckpointCreateFinalize(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virQEMUDriverConfigPtr cfg,
virDomainMomentObjPtr chk,
bool update_current);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册