Do decisions based on the configuration of the job rather than the data
stored with the disk.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_driver.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 739cbc5ed3..fa9e3c2bfc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16982,17 +16982,26 @@ 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_PULL:
+ case QEMU_BLOCKJOB_TYPE_COMMIT:
+ case QEMU_BLOCKJOB_TYPE_INTERNAL:
+ case QEMU_BLOCKJOB_TYPE_LAST:
virReportError(VIR_ERR_OPERATION_INVALID,
- _("pivot of disk '%s' requires an active copy
job"),
- disk->dst);
+ _("job type '%s' does not support pivot"),
+ NULLSTR(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;
}
@@ -17017,7 +17026,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;
--
2.21.0