thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-migration-failover-continue-to-wait-card-unplug-on-e.patch

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