[libvirt] [PATCH 4/7] qemu: Unite error handling in qemuMigrationRun

Jiri Denemark jdenemar at redhat.com
Fri Oct 20 07:14:48 UTC 2017


On Thu, Oct 19, 2017 at 15:56:29 +0200, Jiri Denemark wrote:
> Merge cancel and cancelPostCopy sections with the generic error section,
> where we can easily decide whether canceling the ongoing migration is
> required.
...
> @@ -3843,13 +3844,18 @@ qemuMigrationRun(virQEMUDriverPtr driver,
>      rc = qemuMigrationWaitForCompletion(driver, vm,
>                                          QEMU_ASYNC_JOB_MIGRATION_OUT,
>                                          dconn, waitFlags);
> -    if (rc == -2)
> -        goto cancel;
> -    else if (rc == -1)
> +    if (rc == -2) {
>          goto error;
> +    } else if (rc == -1) {
> +        /* QEMU reported failed migration, nothing to cancel anymore */
> +        cancel = false;
> +        goto error;
> +    }
>  
> -    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY)
> -        inPostCopy = true;
> +    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED) {
> +        /* QEMU finished migration, nothing to cancel anymore */
> +        cancel = false;
> +    }
>  
>      /* When migration completed, QEMU will have paused the CPUs for us.
>       * Wait for the STOP event to be processed or explicitly stop CPUs

Please, consider the following small patch squashed in:

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index bc57f757a..626b4e3ee 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3855,11 +3855,6 @@ qemuMigrationRun(virQEMUDriverPtr driver,
         goto error;
     }
 
-    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED) {
-        /* QEMU finished migration, nothing to cancel anymore */
-        cancel = false;
-    }
-
     /* When migration completed, QEMU will have paused the CPUs for us.
      * Wait for the STOP event to be processed or explicitly stop CPUs
      * (for old QEMU which does not send events) to release the lock state.
@@ -3931,6 +3926,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
     orig_err = virSaveLastError();
 
     if (cancel &&
+        priv->job.current->status != QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED &&
         virDomainObjIsActive(vm) &&
         qemuDomainObjEnterMonitorAsync(driver, vm,
                                        QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) {




More information about the libvir-list mailing list