Jumping back in the code is an anti-pattern that should be avoided if
possible.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_migration.c | 73 +++++++++++++++++++--------------------
1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index acbae36964..dcecee0ed5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -635,50 +635,49 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObj *vm,
size_t completed = 0;
bool failed = false;
- retry:
- for (i = 0; i < vm->def->ndisks; i++) {
- virDomainDiskDef *disk = vm->def->disks[i];
- qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
- qemuBlockJobData *job;
+ do {
+ active = 0;
+ completed = 0;
- if (!diskPriv->migrating)
- continue;
+ for (i = 0; i < vm->def->ndisks; i++) {
+ virDomainDiskDef *disk = vm->def->disks[i];
+ qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+ qemuBlockJobData *job;
- if (!(job = qemuBlockJobDiskGetJob(disk)))
- continue;
+ if (!diskPriv->migrating)
+ continue;
- qemuBlockJobUpdate(vm, job, asyncJob);
- switch (job->state) {
- case VIR_DOMAIN_BLOCK_JOB_FAILED:
- if (!abortMigration) {
- qemuMigrationNBDReportMirrorError(job, disk->dst);
- failed = true;
- }
- G_GNUC_FALLTHROUGH;
- case VIR_DOMAIN_BLOCK_JOB_CANCELED:
- case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
- diskPriv->migrating = false;
- break;
+ if (!(job = qemuBlockJobDiskGetJob(disk)))
+ continue;
- default:
- active++;
- }
+ qemuBlockJobUpdate(vm, job, asyncJob);
+ switch (job->state) {
+ case VIR_DOMAIN_BLOCK_JOB_FAILED:
+ if (!abortMigration) {
+ qemuMigrationNBDReportMirrorError(job, disk->dst);
+ failed = true;
+ }
+ G_GNUC_FALLTHROUGH;
+ case VIR_DOMAIN_BLOCK_JOB_CANCELED:
+ case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
+ diskPriv->migrating = false;
+ break;
- if (job->state == VIR_DOMAIN_BLOCK_JOB_COMPLETED)
- completed++;
+ default:
+ active++;
+ }
- virObjectUnref(job);
- }
+ if (job->state == VIR_DOMAIN_BLOCK_JOB_COMPLETED)
+ completed++;
- /* Updating completed block job drops the lock thus we have to recheck
- * block jobs for disks that reside before the disk(s) with completed
- * block job.
- */
- if (completed > 0) {
- completed = 0;
- active = 0;
- goto retry;
- }
+ virObjectUnref(job);
+ }
+
+ /* Updating completed block job drops the lock thus we have to recheck
+ * block jobs for disks that reside before the disk(s) with completed
+ * block job.
+ */
+ } while (completed > 0);
if (failed) {
if (active) {
--
2.30.2