]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use switch in qemuMigrationCompleted
authorJiri Denemark <jdenemar@redhat.com>
Tue, 17 Oct 2017 19:27:55 +0000 (21:27 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 23 Oct 2017 08:08:29 +0000 (10:08 +0200)
When adding a new job state it's useful to let the compiler complain
about places where we need to think about what to do with the new
state.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_migration.c

index e299b6b852922a97a169cb53fa7b1935015f473d..67d746c863defac16d6c3acf3e87578217317457 100644 (file)
@@ -1531,18 +1531,31 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
         return 0;
 
  error:
-    /* state can not be active or completed at this point */
-    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
-        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
+    switch (jobInfo->status) {
+    case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
+    case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
         /* The migration was aborted by us rather than QEMU itself. */
         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
         return -2;
-    } else if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED) {
+
+    case QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED:
+        /* Something failed after QEMU already finished the migration. */
         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
         return -1;
-    } else {
+
+    case QEMU_DOMAIN_JOB_STATUS_FAILED:
+    case QEMU_DOMAIN_JOB_STATUS_CANCELED:
+        /* QEMU aborted the migration. */
         return -1;
+
+    case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
+    case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
+    case QEMU_DOMAIN_JOB_STATUS_NONE:
+        /* Impossible. */
+        break;
     }
+
+    return -1;
 }