Use only one switch case selecting job type and decide what's successful outcome on a case-by-case basis. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_blockjob.c | 81 ++++++++++++---------------------------- 1 file changed, 23 insertions(+), 58 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index f9b3bdaff4..127a04e840 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1254,75 +1254,40 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr job, virDomainObjPtr vm, qemuDomainAsyncJob asyncJob) { - switch ((qemuBlockjobState) job->newstate) { - case QEMU_BLOCKJOB_STATE_COMPLETED: - switch ((qemuBlockJobType) job->type) { - case QEMU_BLOCKJOB_TYPE_PULL: + bool success = job->newstate == QEMU_BLOCKJOB_STATE_COMPLETED; + + switch ((qemuBlockJobType) job->type) { + case QEMU_BLOCKJOB_TYPE_PULL: + if (success) qemuBlockJobProcessEventCompletedPull(driver, vm, job, asyncJob); - break; + break; - case QEMU_BLOCKJOB_TYPE_COMMIT: + case QEMU_BLOCKJOB_TYPE_COMMIT: + if (success) qemuBlockJobProcessEventCompletedCommit(driver, vm, job, asyncJob); - break; - - case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: - qemuBlockJobProcessEventCompletedActiveCommit(driver, vm, job, asyncJob); - break; - - case QEMU_BLOCKJOB_TYPE_CREATE: - qemuBlockJobProcessEventConcludedCreate(driver, vm, job, asyncJob); - break; - - case QEMU_BLOCKJOB_TYPE_COPY: - if (job->state == QEMU_BLOCKJOB_STATE_PIVOTING) - qemuBlockJobProcessEventConcludedCopyPivot(driver, vm, job, asyncJob); - else - qemuBlockJobProcessEventConcludedCopyAbort(driver, vm, job, asyncJob); - break; - - case QEMU_BLOCKJOB_TYPE_NONE: - case QEMU_BLOCKJOB_TYPE_INTERNAL: - case QEMU_BLOCKJOB_TYPE_LAST: - default: - break; - } break; - case QEMU_BLOCKJOB_STATE_FAILED: - case QEMU_BLOCKJOB_STATE_CANCELLED: - switch ((qemuBlockJobType) job->type) { - case QEMU_BLOCKJOB_TYPE_PULL: - case QEMU_BLOCKJOB_TYPE_COMMIT: - break; - - case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: + case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: + if (success) + qemuBlockJobProcessEventCompletedActiveCommit(driver, vm, job, asyncJob); + else qemuBlockJobProcessEventFailedActiveCommit(driver, vm, job); - break; + break; - case QEMU_BLOCKJOB_TYPE_CREATE: - qemuBlockJobProcessEventConcludedCreate(driver, vm, job, asyncJob); - break; + case QEMU_BLOCKJOB_TYPE_CREATE: + qemuBlockJobProcessEventConcludedCreate(driver, vm, job, asyncJob); + break; - case QEMU_BLOCKJOB_TYPE_COPY: + case QEMU_BLOCKJOB_TYPE_COPY: + if (job->state == QEMU_BLOCKJOB_STATE_PIVOTING && success) + qemuBlockJobProcessEventConcludedCopyPivot(driver, vm, job, asyncJob); + else qemuBlockJobProcessEventConcludedCopyAbort(driver, vm, job, asyncJob); - break; - - case QEMU_BLOCKJOB_TYPE_NONE: - case QEMU_BLOCKJOB_TYPE_INTERNAL: - case QEMU_BLOCKJOB_TYPE_LAST: - default: - break; - } break; - /* states below are impossible in this handler */ - case QEMU_BLOCKJOB_STATE_READY: - case QEMU_BLOCKJOB_STATE_NEW: - case QEMU_BLOCKJOB_STATE_RUNNING: - case QEMU_BLOCKJOB_STATE_CONCLUDED: - case QEMU_BLOCKJOB_STATE_ABORTING: - case QEMU_BLOCKJOB_STATE_PIVOTING: - case QEMU_BLOCKJOB_STATE_LAST: + case QEMU_BLOCKJOB_TYPE_NONE: + case QEMU_BLOCKJOB_TYPE_INTERNAL: + case QEMU_BLOCKJOB_TYPE_LAST: default: break; } -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list