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