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>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
Reviewed-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Notes:
Version 2:
- no change
src/qemu/qemu_migration.c | 36 +++++++++++++-----------------------
1 file changed, 13 insertions(+), 23 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 57919b014d..79766b502e 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);
}
@@ -2388,8 +2390,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);
@@ -2826,8 +2827,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);
}
@@ -2902,8 +2902,6 @@ qemuMigrationSrcBegin(virConnectPtr conn,
if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn,
qemuMigrationAnyConnectionClosed) < 0)
goto endjob;
-
- qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob);
}
ret = g_steal_pointer(&xml);
@@ -2911,7 +2909,7 @@ qemuMigrationSrcBegin(virConnectPtr conn,
endjob:
if (flags & VIR_MIGRATE_CHANGE_PROTECTION) {
if (ret)
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
else
qemuMigrationJobFinish(vm);
} else {
@@ -3440,13 +3438,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;
@@ -3561,8 +3557,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;
}
@@ -4090,8 +4085,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);
}
@@ -5998,8 +5992,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
@@ -6067,8 +6060,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;
}
@@ -6141,8 +6133,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))
@@ -6671,7 +6662,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,
@@ -6765,7 +6755,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
if (finishJob)
qemuMigrationJobFinish(vm);
else
- qemuMigrationJobContinue(vm);
+ qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob);
}
cleanup:
--
2.35.1