]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Always restore post-copy migration job on reconnect
authorJiri Denemark <jdenemar@redhat.com>
Fri, 18 Nov 2022 15:19:16 +0000 (16:19 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 21 Nov 2022 17:17:44 +0000 (18:17 +0100)
We need the restored job even in case the migration already finished
even though we will stop it just a few lines below as the functions we
call in between require an existing migration job.

This fixes a crash on reconnect when post-copy migration finished while
the daemon was not running.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_process.c

index 0769f30d74dd995b7429487b1dd6d8b4f5970e79..e1c18dde903f74d3cc276800f72bea2bc7e2c50b 100644 (file)
@@ -3635,11 +3635,14 @@ qemuProcessRecoverMigration(virQEMUDriver *driver,
 
     if (rc > 0) {
         job->phase = QEMU_MIGRATION_PHASE_POSTCOPY_FAILED;
+        /* Even though we restore the migration async job here, the APIs below
+         * use VIR_ASYNC_JOB_NONE because we're already in a MODIFY job started
+         * before we reconnected to the domain. */
+        qemuProcessRestoreMigrationJob(vm, job);
 
         if (migStatus == VIR_DOMAIN_JOB_STATUS_POSTCOPY) {
             VIR_DEBUG("Post-copy migration of domain %s still running, it will be handled as unattended",
                       vm->def->name);
-            qemuProcessRestoreMigrationJob(vm, job);
             return 0;
         }
 
@@ -3648,17 +3651,19 @@ qemuProcessRecoverMigration(virQEMUDriver *driver,
                 qemuMigrationSrcPostcopyFailed(vm);
             else
                 qemuMigrationDstPostcopyFailed(vm);
-
-            qemuProcessRestoreMigrationJob(vm, job);
             return 0;
         }
 
         VIR_DEBUG("Post-copy migration of domain %s already finished",
                   vm->def->name);
-        if (job->asyncJob == VIR_ASYNC_JOB_MIGRATION_OUT)
+        if (job->asyncJob == VIR_ASYNC_JOB_MIGRATION_OUT) {
             qemuMigrationSrcComplete(driver, vm, VIR_ASYNC_JOB_NONE);
-        else
+            /* No need to stop the restored job as the domain has just been
+             * destroyed. */
+        } else {
             qemuMigrationDstComplete(driver, vm, true, VIR_ASYNC_JOB_NONE, job);
+            virDomainObjEndAsyncJob(vm);
+        }
         return 0;
     }