[PATCH 15/68] qemu: Reset all migration parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Restore the original values of all migration parameters we store in
qemuDomainJobObj instead of explicitly resting only a limited set of
them.

The result is not strictly equivalent to the previous code wrt reseting
TLS state because the previous code would only reset it if we changed it
before while the new code will reset it always if QEMU supports TLS
migration. This is not a problem for the parameters themselves, but it
can cause spurious errors about missing TLS objects being logged at the
end of non-TLS migration. This issue will be fixed ~50 patches later.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c        | 20 +++++++++----
 src/qemu/qemu_migration_params.c | 48 +++++++++++---------------------
 src/qemu/qemu_migration_params.h |  3 +-
 src/qemu/qemu_process.c          |  4 +--
 4 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 7fd85bc6c5..3c25e0e27f 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1834,7 +1834,8 @@ qemuMigrationSrcCleanup(virDomainObjPtr vm,
         VIR_WARN("Migration of domain %s finished but we don't know if the"
                  " domain was successfully started on destination or not",
                  vm->def->name);
-        qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT);
+        qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
+                                 priv->job.migParams);
         /* clear the job and let higher levels decide what to do */
         qemuDomainObjDiscardAsyncJob(driver, vm);
         break;
@@ -2596,7 +2597,8 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
     return ret;
 
  stopjob:
-    qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN);
+    qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
+                             priv->job.migParams);
 
     if (stopProcess) {
         unsigned int stopFlags = VIR_QEMU_PROCESS_STOP_MIGRATED;
@@ -2972,7 +2974,8 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr driver,
             qemuDomainEventQueue(driver, event);
         }
 
-        qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT);
+        qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
+                                 priv->job.migParams);
 
         if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
             VIR_WARN("Failed to save status on vm %s", vm->def->name);
@@ -4584,6 +4587,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
     int ret = -1;
     virErrorPtr orig_err = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    qemuDomainObjPrivatePtr priv = vm->privateData;
 
     if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
         goto cleanup;
@@ -4644,7 +4648,8 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
      * here
      */
     if (!v3proto && ret < 0)
-        qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT);
+        qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
+                                 priv->job.migParams);
 
     if (qemuMigrationSrcRestoreDomainState(driver, vm)) {
         event = virDomainEventLifecycleNewFromObj(vm,
@@ -4694,6 +4699,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
                              unsigned long flags,
                              unsigned long resource)
 {
+    qemuDomainObjPrivatePtr priv = vm->privateData;
     virObjectEventPtr event = NULL;
     int ret = -1;
 
@@ -4734,7 +4740,8 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
 
  endjob:
     if (ret < 0) {
-        qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT);
+        qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
+                                 priv->job.migParams);
         qemuMigrationJobFinish(driver, vm);
     } else {
         qemuMigrationJobContinue(vm);
@@ -5190,7 +5197,8 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver,
             VIR_FREE(priv->job.completed);
     }
 
-    qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN);
+    qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
+                             priv->job.migParams);
 
     qemuMigrationJobFinish(driver, vm);
     if (!virDomainObjIsActive(vm))
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 4defc62ae5..43098de904 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -378,30 +378,19 @@ qemuMigrationParamsSetCompression(virQEMUDriverPtr driver,
  *
  * Deconstruct all the setup possibly done for TLS - delete the TLS and
  * security objects, free the secinfo, and reset the migration params to "".
- *
- * Returns 0 on success, -1 on failure
  */
-static int
+static void
 qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
                             virDomainObjPtr vm,
-                            int asyncJob)
+                            int asyncJob,
+                            qemuMigrationParamsPtr origParams)
 {
-    qemuDomainObjPrivatePtr priv = vm->privateData;
     char *tlsAlias = NULL;
     char *secAlias = NULL;
-    qemuMigrationParamsPtr migParams = NULL;
-    int ret = -1;
 
-    if (qemuMigrationParamsCheckTLSCreds(driver, vm, asyncJob) < 0)
-        return -1;
-
-    /* If the tls-creds doesn't exist or if they're set to "" then there's
-     * nothing to do since we never set anything up */
-    if (!priv->migTLSAlias || !*priv->migTLSAlias)
-        return 0;
-
-    if (!(migParams = qemuMigrationParamsNew()))
-        goto cleanup;
+    /* If QEMU does not support TLS migration we didn't set the aliases. */
+    if (!origParams->params.tlsCreds)
+        return;
 
     /* NB: If either or both fail to allocate memory we can still proceed
      *     since the next time we migrate another deletion attempt will be
@@ -410,21 +399,10 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
     secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE, false);
 
     qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
-    qemuDomainSecretInfoFree(&priv->migSecinfo);
+    qemuDomainSecretInfoFree(&QEMU_DOMAIN_PRIVATE(vm)->migSecinfo);
 
-    if (VIR_STRDUP(migParams->params.tlsCreds, "") < 0 ||
-        VIR_STRDUP(migParams->params.tlsHostname, "") < 0 ||
-        qemuMigrationParamsSet(driver, vm, asyncJob, migParams) < 0)
-        goto cleanup;
-
-    ret = 0;
-
- cleanup:
     VIR_FREE(tlsAlias);
     VIR_FREE(secAlias);
-    qemuMigrationParamsFree(migParams);
-
-    return ret;
 }
 
 
@@ -475,16 +453,22 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver,
 void
 qemuMigrationParamsReset(virQEMUDriverPtr driver,
                          virDomainObjPtr vm,
-                         int asyncJob)
+                         int asyncJob,
+                         qemuMigrationParamsPtr origParams)
 {
     qemuMonitorMigrationCaps cap;
     virErrorPtr err = virSaveLastError();
 
+    VIR_DEBUG("Resetting migration parameters %p", origParams);
+
     if (!virDomainObjIsActive(vm))
         goto cleanup;
 
-    if (qemuMigrationParamsResetTLS(driver, vm, asyncJob) < 0)
-        goto cleanup;
+    if (origParams) {
+        if (qemuMigrationParamsSet(driver, vm, asyncJob, origParams) < 0)
+            goto cleanup;
+        qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams);
+    }
 
     for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) {
         if (qemuMigrationCapsGet(vm, cap) &&
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index a6125a6f3d..5e5e81ee07 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -108,6 +108,7 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver,
 void
 qemuMigrationParamsReset(virQEMUDriverPtr driver,
                          virDomainObjPtr vm,
-                         int asyncJob);
+                         int asyncJob,
+                         qemuMigrationParamsPtr origParams);
 
 #endif /* __QEMU_MIGRATION_PARAMS_H__ */
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 871f1143f2..c4d3f67d19 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3081,7 +3081,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriverPtr driver,
         break;
     }
 
-    qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_NONE);
+    qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_NONE, job->migParams);
     return 0;
 }
 
@@ -3175,7 +3175,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
         }
     }
 
-    qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_NONE);
+    qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_NONE, job->migParams);
     return 0;
 }
 
-- 
2.17.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux