From 0f41423f2bb57e77400cfec0683b7514c9798c55 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Wed, 4 Aug 2021 07:10:13 -0400 Subject: [PATCH 22/39] migration: failover: continue to wait card unplug on error RH-Author: Miroslav Rezanina RH-MergeRequest: 32: Synchronize with RHEL-AV 8.5 release 27 to RHEL 9 RH-Commit: [14/15] e3bfdeee808b2ecd5b141464193b6ee97a4bca3a (mrezanin/centos-src-qemu-kvm) RH-Bugzilla: 1957194 RH-Acked-by: Stefano Garzarella RH-Acked-by: Kevin Wolf RH-Acked-by: Igor Mammedov RH-Acked-by: Andrew Jones If the user cancels the migration in the unplug-wait state, QEMU will try to plug back the card and this fails because the card is partially unplugged. To avoid the problem, continue to wait the card unplug, but to allow the migration to be canceled if the card never finishes to unplug use a timeout. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1976852 Signed-off-by: Laurent Vivier Reviewed-by: Dr. David Alan Gilbert Message-Id: <20210629155007.629086-3-lvivier@redhat.com> Signed-off-by: Dr. David Alan Gilbert (cherry picked from commit 944bc528421aa848ca218ee535ea923a4147a525) Signed-off-by: Laurent Vivier Signed-off-by: Miroslav Rezanina --- migration/migration.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 58df1dac05..fc1d0db04a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3696,6 +3696,17 @@ static void qemu_savevm_wait_unplug(MigrationState *s, int old_state, qemu_savevm_state_guest_unplug_pending()) { qemu_sem_timedwait(&s->wait_unplug_sem, 250); } + if (s->state != MIGRATION_STATUS_WAIT_UNPLUG) { + int timeout = 120; /* 30 seconds */ + /* + * migration has been canceled + * but as we have started an unplug we must wait the end + * to be able to plug back the card + */ + while (timeout-- && qemu_savevm_state_guest_unplug_pending()) { + qemu_sem_timedwait(&s->wait_unplug_sem, 250); + } + } migrate_set_state(&s->state, MIGRATION_STATUS_WAIT_UNPLUG, new_state); } else { -- 2.27.0