From: Peter Krempa Date: Tue, 12 Feb 2019 12:29:46 +0000 (+0100) Subject: qemu: Make checks in qemuDomainBlockPivot depend on data of the job X-Git-Tag: v5.6.0-rc1~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd9dc7bfe1a79dce48a650ac160509b1fbe7707c;p=thirdparty%2Flibvirt.git qemu: Make checks in qemuDomainBlockPivot depend on data of the job Do decisions based on the configuration of the job rather than the data stored with the disk. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 49dd6f433e..87a05b8718 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16979,17 +16979,30 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; - if (!disk->mirror) { + switch ((qemuBlockJobType) job->type) { + case QEMU_BLOCKJOB_TYPE_NONE: + case QEMU_BLOCKJOB_TYPE_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid job type '%d'"), job->type); + goto cleanup; + + case QEMU_BLOCKJOB_TYPE_PULL: + case QEMU_BLOCKJOB_TYPE_COMMIT: + case QEMU_BLOCKJOB_TYPE_INTERNAL: virReportError(VIR_ERR_OPERATION_INVALID, - _("pivot of disk '%s' requires an active copy job"), - disk->dst); + _("job type '%s' does not support pivot"), + qemuBlockjobTypeToString(job->type)); goto cleanup; + + case QEMU_BLOCKJOB_TYPE_COPY: + case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: + break; } - if (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY) { + if (job->state != QEMU_BLOCKJOB_STATE_READY) { virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, - _("disk '%s' not ready for pivot yet"), - disk->dst); + _("block job '%s' not ready for pivot yet"), + job->name); goto cleanup; } @@ -17014,7 +17027,8 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, if (ret < 0) goto cleanup; - disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT; + if (disk && disk->mirror) + disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT; cleanup: return ret;