Trying to delete the non-existent TLS objects results in ugly error
messages in the log, which could easily confuse users. Let's avoid this
confusion by not trying to delete the objects if we were not asked to
enable TLS migration and thus we didn't created the objects anyway.
This patch restores the behavior to the state before "qemu: Reset all
migration parameters".
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_migration.c | 12 ++++++------
src/qemu/qemu_migration_params.c | 18 ++++++++++++------
src/qemu/qemu_migration_params.h | 3 ++-
src/qemu/qemu_process.c | 6 ++++--
4 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 808a6c147e..c7dcbf0788 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1771,7 +1771,7 @@ qemuMigrationSrcCleanup(virDomainObjPtr vm,
" domain was successfully started on destination or not",
vm->def->name);
qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
- priv->job.migParams);
+ priv->job.migParams, priv->job.apiFlags);
/* clear the job and let higher levels decide what to do */
qemuDomainObjDiscardAsyncJob(driver, vm);
break;
@@ -2496,7 +2496,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
stopjob:
qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
- priv->job.migParams);
+ priv->job.migParams, priv->job.apiFlags);
if (stopProcess) {
unsigned int stopFlags = VIR_QEMU_PROCESS_STOP_MIGRATED;
@@ -2866,7 +2866,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr driver,
}
qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
- priv->job.migParams);
+ priv->job.migParams, priv->job.apiFlags);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps)
< 0)
VIR_WARN("Failed to save status on vm %s", vm->def->name);
@@ -4490,7 +4490,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
*/
if (!v3proto && ret < 0)
qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
- priv->job.migParams);
+ priv->job.migParams, priv->job.apiFlags);
if (qemuMigrationSrcRestoreDomainState(driver, vm)) {
event = virDomainEventLifecycleNewFromObj(vm,
@@ -4579,7 +4579,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
endjob:
if (ret < 0) {
qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
- priv->job.migParams);
+ priv->job.migParams, priv->job.apiFlags);
qemuMigrationJobFinish(driver, vm);
} else {
qemuMigrationJobContinue(vm);
@@ -5035,7 +5035,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver,
}
qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
- priv->job.migParams);
+ priv->job.migParams, priv->job.apiFlags);
qemuMigrationJobFinish(driver, vm);
if (!virDomainObjIsActive(vm))
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
index 6634fae4f6..a9c0d90f00 100644
--- a/src/qemu/qemu_migration_params.c
+++ b/src/qemu/qemu_migration_params.c
@@ -803,6 +803,7 @@ qemuMigrationParamsDisableTLS(virDomainObjPtr vm,
* @driver: pointer to qemu driver
* @vm: domain object
* @asyncJob: migration job to join
+ * @apiFlags: API flags used to start the migration
*
* Deconstruct all the setup possibly done for TLS - delete the TLS and
* security objects, free the secinfo, and reset the migration params to "".
@@ -811,13 +812,16 @@ static void
qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
virDomainObjPtr vm,
int asyncJob,
- qemuMigrationParamsPtr origParams)
+ qemuMigrationParamsPtr origParams,
+ unsigned long apiFlags)
{
char *tlsAlias = NULL;
char *secAlias = NULL;
- /* If QEMU does not support TLS migration we didn't set the aliases. */
- if (!origParams->params[QEMU_MIGRATION_PARAM_TLS_CREDS].set)
+ /* There's nothing to do if QEMU does not support TLS migration or we were
+ * not asked to enable it. */
+ if (!origParams->params[QEMU_MIGRATION_PARAM_TLS_CREDS].set ||
+ !(apiFlags & VIR_MIGRATE_TLS))
return;
/* NB: If either or both fail to allocate memory we can still proceed
@@ -966,11 +970,13 @@ void
qemuMigrationParamsReset(virQEMUDriverPtr driver,
virDomainObjPtr vm,
int asyncJob,
- qemuMigrationParamsPtr origParams)
+ qemuMigrationParamsPtr origParams,
+ unsigned long apiFlags)
{
virErrorPtr err = virSaveLastError();
- VIR_DEBUG("Resetting migration parameters %p", origParams);
+ VIR_DEBUG("Resetting migration parameters %p, flags 0x%lx",
+ origParams, apiFlags);
if (!virDomainObjIsActive(vm) || !origParams)
goto cleanup;
@@ -978,7 +984,7 @@ qemuMigrationParamsReset(virQEMUDriverPtr driver,
if (qemuMigrationParamsApply(driver, vm, asyncJob, origParams) < 0)
goto cleanup;
- qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams);
+ qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
cleanup:
if (err) {
diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h
index 8116f3f59f..2e4cbcb315 100644
--- a/src/qemu/qemu_migration_params.h
+++ b/src/qemu/qemu_migration_params.h
@@ -116,7 +116,8 @@ void
qemuMigrationParamsReset(virQEMUDriverPtr driver,
virDomainObjPtr vm,
int asyncJob,
- qemuMigrationParamsPtr origParams);
+ qemuMigrationParamsPtr origParams,
+ unsigned long apiFlags);
void
qemuMigrationParamsFormat(virBufferPtr buf,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 89669c9765..095ce26031 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3081,7 +3081,8 @@ qemuProcessRecoverMigrationIn(virQEMUDriverPtr driver,
break;
}
- qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_NONE, job->migParams);
+ qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_NONE,
+ job->migParams, job->apiFlags);
return 0;
}
@@ -3175,7 +3176,8 @@ qemuProcessRecoverMigrationOut(virQEMUDriverPtr driver,
}
}
- qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_NONE, job->migParams);
+ qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_NONE,
+ job->migParams, job->apiFlags);
return 0;
}
--
2.17.0