mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 = ¶ms[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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user