mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu: blockjob: Refactor qemuBlockJobEventProcessConcludedTransition
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
bac02e396d
commit
0b82b13adc
@ -1252,48 +1252,23 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr job,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainAsyncJob asyncJob)
|
||||
{
|
||||
switch ((qemuBlockjobState) job->newstate) {
|
||||
case QEMU_BLOCKJOB_STATE_COMPLETED:
|
||||
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;
|
||||
|
||||
case QEMU_BLOCKJOB_TYPE_COMMIT:
|
||||
if (success)
|
||||
qemuBlockJobProcessEventCompletedCommit(driver, vm, job, asyncJob);
|
||||
break;
|
||||
|
||||
case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
|
||||
if (success)
|
||||
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:
|
||||
qemuBlockJobProcessEventFailedActiveCommit(driver, vm, job);
|
||||
break;
|
||||
|
||||
@ -1302,6 +1277,9 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr job,
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
@ -1311,19 +1289,6 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr job,
|
||||
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:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
qemuBlockJobEmitEvents(driver, vm, job->disk, job->type, job->newstate);
|
||||
job->state = job->newstate;
|
||||
|
Loading…
x
Reference in New Issue
Block a user