thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-migration-Maybe-VM-is-paused-when-migration-is-cance.patch

ddf19c
From 3c4f6f0c2bf5562f2aa26f964848ae53e6ac4790 Mon Sep 17 00:00:00 2001
ddf19c
From: Juan Quintela <quintela@redhat.com>
ddf19c
Date: Tue, 3 Mar 2020 14:51:43 +0000
ddf19c
Subject: [PATCH 11/18] migration: Maybe VM is paused when migration is
ddf19c
 cancelled
ddf19c
ddf19c
RH-Author: Juan Quintela <quintela@redhat.com>
ddf19c
Message-id: <20200303145143.149290-11-quintela@redhat.com>
ddf19c
Patchwork-id: 94120
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 10/10] migration: Maybe VM is paused when migration is cancelled
ddf19c
Bugzilla: 1738451
ddf19c
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ddf19c
RH-Acked-by: Peter Xu <peterx@redhat.com>
ddf19c
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
ddf19c
From: Zhimin Feng <fengzhimin1@huawei.com>
ddf19c
ddf19c
If the migration is cancelled when it is in the completion phase,
ddf19c
the migration state is set to MIGRATION_STATUS_CANCELLING.
ddf19c
The VM maybe wait for the 'pause_sem' semaphore in migration_maybe_pause
ddf19c
function, so that VM always is paused.
ddf19c
ddf19c
Reported-by: Euler Robot <euler.robot@huawei.com>
ddf19c
Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>
ddf19c
Reviewed-by: Juan Quintela <quintela@redhat.com>
ddf19c
Signed-off-by: Juan Quintela <quintela@redhat.com>
ddf19c
(cherry picked from commit 8958338b10abcb346b54a8038a491fda2db1c853)
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 migration/migration.c | 24 ++++++++++++++++--------
ddf19c
 1 file changed, 16 insertions(+), 8 deletions(-)
ddf19c
ddf19c
diff --git a/migration/migration.c b/migration/migration.c
ddf19c
index eb50d77..ed18c59 100644
ddf19c
--- a/migration/migration.c
ddf19c
+++ b/migration/migration.c
ddf19c
@@ -2786,14 +2786,22 @@ static int migration_maybe_pause(MigrationState *s,
ddf19c
         /* This block intentionally left blank */
ddf19c
     }
ddf19c
 
ddf19c
-    qemu_mutex_unlock_iothread();
ddf19c
-    migrate_set_state(&s->state, *current_active_state,
ddf19c
-                      MIGRATION_STATUS_PRE_SWITCHOVER);
ddf19c
-    qemu_sem_wait(&s->pause_sem);
ddf19c
-    migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
ddf19c
-                      new_state);
ddf19c
-    *current_active_state = new_state;
ddf19c
-    qemu_mutex_lock_iothread();
ddf19c
+    /*
ddf19c
+     * If the migration is cancelled when it is in the completion phase,
ddf19c
+     * the migration state is set to MIGRATION_STATUS_CANCELLING.
ddf19c
+     * So we don't need to wait a semaphore, otherwise we would always
ddf19c
+     * wait for the 'pause_sem' semaphore.
ddf19c
+     */
ddf19c
+    if (s->state != MIGRATION_STATUS_CANCELLING) {
ddf19c
+        qemu_mutex_unlock_iothread();
ddf19c
+        migrate_set_state(&s->state, *current_active_state,
ddf19c
+                          MIGRATION_STATUS_PRE_SWITCHOVER);
ddf19c
+        qemu_sem_wait(&s->pause_sem);
ddf19c
+        migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
ddf19c
+                          new_state);
ddf19c
+        *current_active_state = new_state;
ddf19c
+        qemu_mutex_lock_iothread();
ddf19c
+    }
ddf19c
 
ddf19c
     return s->state == new_state ? 0 : -EINVAL;
ddf19c
 }
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c