提交 9dde58e1 编写于 作者: P Peter Krempa

qemu: Aggregate interlocking of blockjobs by checkpoints in one place

Rather than having to fix 5 places once we support the combination, add
a function called by all the blockjob/snapshot APIs.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 afece205
......@@ -15513,3 +15513,24 @@ qemuDomainDefHasManagedPR(virDomainObjPtr vm)
return jobPR;
}
/**
* qemuDomainSupportsCheckpointsBlockjobs:
* @vm: domain object
*
* Checks whether a block job is supported in possible combination with
* checkpoints (qcow2 bitmaps). Returns -1 if unsupported and reports an error
* 0 in case everything is supported.
*/
int
qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm)
{
if (virDomainListCheckpoints(vm->checkpoints, NULL, NULL, NULL, 0) > 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot perform block operations while checkpoint exists"));
return -1;
}
return 0;
}
......@@ -1217,3 +1217,7 @@ qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason);
int
qemuDomainValidateActualNetDef(const virDomainNetDef *net,
virQEMUCapsPtr qemuCaps);
int
qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm)
ATTRIBUTE_RETURN_CHECK;
......@@ -15836,11 +15836,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
if (virDomainSnapshotCreateXMLEnsureACL(domain->conn, vm->def, flags) < 0)
goto cleanup;
if (virDomainListCheckpoints(vm->checkpoints, NULL, domain, NULL, 0) > 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot create snapshot while checkpoint exists"));
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
goto cleanup;
}
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
......@@ -18364,11 +18361,8 @@ qemuDomainBlockRebase(virDomainPtr dom, const char *path, const char *base,
if (virDomainBlockRebaseEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot perform block rebase while checkpoint exists"));
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
goto cleanup;
}
/* For normal rebase (enhanced blockpull), the common code handles
* everything, including vm cleanup. */
......@@ -18454,11 +18448,8 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
if (virDomainBlockCopyEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot perform block copy while checkpoint exists"));
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
goto cleanup;
}
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = &params[i];
......@@ -18522,11 +18513,8 @@ qemuDomainBlockPull(virDomainPtr dom, const char *path, unsigned long bandwidth,
if (virDomainBlockPullEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot perform block pull while checkpoint exists"));
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
goto cleanup;
}
ret = qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags);
......@@ -18581,11 +18569,8 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot perform block commit while checkpoint exists"));
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
goto cleanup;
}
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册