Every single call to qemuMigrationJobContinue needs to register a
cleanup callback in case the migrating domain dies between phases or
when migration is paused due to a failure in postcopy mode.
Let's integrate registering the callback in qemuMigrationJobContinue to
make sure the current thread does not release a migration job without
setting a cleanup callback.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_migration.c | 35 +++++++++++++----------------------
1 file changed, 13 insertions(+), 22 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 38a67f7e20..d7e8b9d1e4 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -183,8 +183,10 @@ qemuMigrationJobStartPhase(virDomainObj *vm,
static void ATTRIBUTE_NONNULL(1)
-qemuMigrationJobContinue(virDomainObj *vm)
+qemuMigrationJobContinue(virDomainObj *vm,
+ qemuDomainCleanupCallback cleanup)
{
+ qemuDomainCleanupAdd(vm, cleanup);
qemuDomainObjReleaseAsyncJob(vm);
}
@@ -2416,8 +2418,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm,
qemuMigrationSrcPostcopyFailed(vm);
else
qemuMigrationDstPostcopyFailed(vm);
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
} else {
qemuMigrationParamsReset(driver, vm, priv->job.asyncJob,
jobPriv->migParams, priv->job.apiFlags);
@@ -2862,8 +2863,7 @@ qemuMigrationSrcBeginResumePhase(virConnectPtr conn,
if (!xml)
ignore_value(qemuMigrationJobSetPhase(vm,
QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
return g_steal_pointer(&xml);
}
@@ -2939,8 +2939,7 @@ qemuMigrationSrcBegin(virConnectPtr conn,
VIR_FREE(xml);
goto endjob;
}
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
} else {
goto endjob;
}
@@ -3476,13 +3475,11 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver,
VIR_WARN("Unable to encode migration cookie");
}
- qemuDomainCleanupAdd(vm, qemuMigrationDstPrepareCleanup);
-
/* We keep the job active across API calls until the finish() call.
* This prevents any other APIs being invoked while incoming
* migration is taking place.
*/
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuMigrationDstPrepareCleanup);
if (autoPort)
priv->migrationPort = port;
@@ -3595,8 +3592,7 @@ qemuMigrationDstPrepareResume(virQEMUDriver *driver,
qemuProcessIncomingDefFree(incoming);
if (ret < 0)
ignore_value(qemuMigrationJobSetPhase(vm,
QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
virDomainObjEndAPI(&vm);
return ret;
}
@@ -4128,8 +4124,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver,
if (virDomainObjIsFailedPostcopy(vm)) {
ignore_value(qemuMigrationJobSetPhase(vm,
QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
} else {
qemuMigrationJobFinish(vm);
}
@@ -6041,8 +6036,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver,
if (virDomainObjIsFailedPostcopy(vm)) {
ignore_value(qemuMigrationJobSetPhase(vm,
QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
} else {
/* v2 proto has no confirm phase so we need to reset migration parameters
* here
@@ -6110,8 +6104,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver,
if (ret < 0)
ignore_value(qemuMigrationJobSetPhase(vm,
QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
return ret;
}
@@ -6184,8 +6177,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver,
} else {
if (ret < 0)
ignore_value(qemuMigrationJobSetPhase(vm,
QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
}
if (!virDomainObjIsActive(vm))
@@ -6714,7 +6706,6 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver,
if (virDomainObjIsFailedPostcopy(vm)) {
ignore_value(qemuMigrationJobSetPhase(vm,
QEMU_MIGRATION_PHASE_POSTCOPY_FAILED));
qemuProcessAutoDestroyRemove(driver, vm);
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
*finishJob = false;
} else {
qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN,
@@ -6805,7 +6796,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
flags, retcode, v3proto, timeReceived,
&orig_err, &finishJob);
if (!finishJob) {
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
goto cleanup;
}
}
--
2.35.1