mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
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: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
afece20513
commit
9dde58e1c3
@ -15513,3 +15513,24 @@ qemuDomainDefHasManagedPR(virDomainObjPtr vm)
|
|||||||
|
|
||||||
return jobPR;
|
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
|
int
|
||||||
qemuDomainValidateActualNetDef(const virDomainNetDef *net,
|
qemuDomainValidateActualNetDef(const virDomainNetDef *net,
|
||||||
virQEMUCapsPtr qemuCaps);
|
virQEMUCapsPtr qemuCaps);
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm)
|
||||||
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
@ -15836,11 +15836,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
if (virDomainSnapshotCreateXMLEnsureACL(domain->conn, vm->def, flags) < 0)
|
if (virDomainSnapshotCreateXMLEnsureACL(domain->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainListCheckpoints(vm->checkpoints, NULL, domain, NULL, 0) > 0) {
|
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
||||||
_("cannot create snapshot while checkpoint exists"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -18364,11 +18361,8 @@ qemuDomainBlockRebase(virDomainPtr dom, const char *path, const char *base,
|
|||||||
if (virDomainBlockRebaseEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainBlockRebaseEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0) {
|
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
||||||
_("cannot perform block rebase while checkpoint exists"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* For normal rebase (enhanced blockpull), the common code handles
|
/* For normal rebase (enhanced blockpull), the common code handles
|
||||||
* everything, including vm cleanup. */
|
* everything, including vm cleanup. */
|
||||||
@ -18454,11 +18448,8 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *disk, const char *destxml,
|
|||||||
if (virDomainBlockCopyEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainBlockCopyEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0) {
|
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
||||||
_("cannot perform block copy while checkpoint exists"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < nparams; i++) {
|
for (i = 0; i < nparams; i++) {
|
||||||
virTypedParameterPtr param = ¶ms[i];
|
virTypedParameterPtr param = ¶ms[i];
|
||||||
@ -18522,11 +18513,8 @@ qemuDomainBlockPull(virDomainPtr dom, const char *path, unsigned long bandwidth,
|
|||||||
if (virDomainBlockPullEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainBlockPullEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0) {
|
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
||||||
_("cannot perform block pull while checkpoint exists"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
ret = qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags);
|
ret = qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags);
|
||||||
|
|
||||||
@ -18581,11 +18569,8 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|||||||
if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0) {
|
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
||||||
_("cannot perform block commit while checkpoint exists"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user