qemu: Introduce qemuProcessCleanupMigrationJob

The function can be used as a callback for qemuDomainCleanupAdd to
automatically clean up a migration job when a domain is destroyed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Jiri Denemark 2022-05-10 15:20:25 +02:00
parent 83ccd3a3d1
commit 7c1840fa37
2 changed files with 28 additions and 0 deletions

View File

@ -3360,6 +3360,31 @@ qemuProcessUpdateState(virQEMUDriver *driver, virDomainObj *vm)
return 0;
}
void
qemuProcessCleanupMigrationJob(virQEMUDriver *driver,
virDomainObj *vm)
{
qemuDomainObjPrivate *priv = vm->privateData;
virDomainState state;
int reason;
state = virDomainObjGetState(vm, &reason);
VIR_DEBUG("driver=%p, vm=%s, asyncJob=%s, state=%s, reason=%s",
driver, vm->def->name,
virDomainAsyncJobTypeToString(priv->job.asyncJob),
virDomainStateTypeToString(state),
virDomainStateReasonToString(state, reason));
if (priv->job.asyncJob != VIR_ASYNC_JOB_MIGRATION_IN &&
priv->job.asyncJob != VIR_ASYNC_JOB_MIGRATION_OUT)
return;
qemuDomainObjDiscardAsyncJob(vm);
}
static int
qemuProcessRecoverMigrationIn(virQEMUDriver *driver,
virDomainObj *vm,

View File

@ -241,3 +241,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuProcessQMP, qemuProcessQMPFree);
int qemuProcessQMPStart(qemuProcessQMP *proc);
bool qemuProcessRebootAllowed(const virDomainDef *def);
void qemuProcessCleanupMigrationJob(virQEMUDriver *driver,
virDomainObj *vm);