From 4dd86f334bc3c9679865176f588597cf99375330 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Tue, 11 Oct 2022 14:00:13 +0200 Subject: [PATCH] qemu_migration: Properly wait for migration to be canceled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In my commit v8.7.0-57-g2d7b22b561 I attempted to make qemuMigrationSrcCancel synchronous, but failed. When we are canceling migration after some kind of error which is detected in in qemuMigrationSrcWaitForCompletion, jobData->status will be set to VIR_DOMAIN_JOB_STATUS_FAILED regardless on QEMU state. So instead of relying on the translated jobData->status in qemuMigrationSrcIsCanceled we need to check the migration status we get from QEMU MIGRATION event. Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko --- src/qemu/qemu_migration.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 33105cf07b..21c870334d 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4597,21 +4597,30 @@ static bool qemuMigrationSrcIsCanceled(virDomainObj *vm) { virDomainJobData *jobData = vm->job->current; + qemuDomainJobDataPrivate *priv = jobData->privateData; + qemuMonitorMigrationStatus status = priv->stats.mig.status; - qemuMigrationUpdateJobType(jobData); - switch (jobData->status) { - case VIR_DOMAIN_JOB_STATUS_FAILED: - case VIR_DOMAIN_JOB_STATUS_CANCELED: - case VIR_DOMAIN_JOB_STATUS_COMPLETED: - case VIR_DOMAIN_JOB_STATUS_NONE: + switch (status) { + case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED: + case QEMU_MONITOR_MIGRATION_STATUS_ERROR: + case QEMU_MONITOR_MIGRATION_STATUS_CANCELLED: + case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE: + VIR_DEBUG("QEMU migration status: %s; waiting finished", + qemuMonitorMigrationStatusTypeToString(status)); return true; - case VIR_DOMAIN_JOB_STATUS_MIGRATING: - case VIR_DOMAIN_JOB_STATUS_POSTCOPY: - case VIR_DOMAIN_JOB_STATUS_PAUSED: - case VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED: - case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED: - case VIR_DOMAIN_JOB_STATUS_ACTIVE: + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY: + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_RECOVER: + case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED: + case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER: + case QEMU_MONITOR_MIGRATION_STATUS_DEVICE: + case QEMU_MONITOR_MIGRATION_STATUS_SETUP: + case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE: + case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING: + case QEMU_MONITOR_MIGRATION_STATUS_WAIT_UNPLUG: + case QEMU_MONITOR_MIGRATION_STATUS_LAST: + VIR_DEBUG("QEMU migration status: %s; still waiting", + qemuMonitorMigrationStatusTypeToString(status)); break; }