qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] migration: Maybe VM is paused when migration is cancelled
@ 2020-01-14  9:43 Zhimin Feng
  2020-02-13  9:45 ` Juan Quintela
  0 siblings, 1 reply; 2+ messages in thread
From: Zhimin Feng @ 2020-01-14  9:43 UTC (permalink / raw)
  To: quintela, dgilbert
  Cc: Euler Robot, Zhimin Feng, qemu-devel, zhang.zhanghailiang

If the migration is cancelled when it is in the completion phase,
the migration state is set to MIGRATION_STATUS_CANCELLING.
The VM maybe wait for the 'pause_sem' semaphore in migration_maybe_pause
function, so that VM always is paused.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>
---
 migration/migration.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 354ad07..82ee981 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2765,14 +2765,22 @@ static int migration_maybe_pause(MigrationState *s,
         /* This block intentionally left blank */
     }
 
-    qemu_mutex_unlock_iothread();
-    migrate_set_state(&s->state, *current_active_state,
-                      MIGRATION_STATUS_PRE_SWITCHOVER);
-    qemu_sem_wait(&s->pause_sem);
-    migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
-                      new_state);
-    *current_active_state = new_state;
-    qemu_mutex_lock_iothread();
+    /*
+     * If the migration is cancelled when it is in the completion phase,
+     * the migration state is set to MIGRATION_STATUS_CANCELLING.
+     * So we don't need to wait a semaphore, otherwise we would always
+     * wait for the 'pause_sem' semaphore.
+     */
+    if (s->state != MIGRATION_STATUS_CANCELLING) {
+        qemu_mutex_unlock_iothread();
+        migrate_set_state(&s->state, *current_active_state,
+                          MIGRATION_STATUS_PRE_SWITCHOVER);
+        qemu_sem_wait(&s->pause_sem);
+        migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
+                          new_state);
+        *current_active_state = new_state;
+        qemu_mutex_lock_iothread();
+    }
 
     return s->state == new_state ? 0 : -EINVAL;
 }
-- 
1.8.3.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] migration: Maybe VM is paused when migration is cancelled
  2020-01-14  9:43 [PATCH] migration: Maybe VM is paused when migration is cancelled Zhimin Feng
@ 2020-02-13  9:45 ` Juan Quintela
  0 siblings, 0 replies; 2+ messages in thread
From: Juan Quintela @ 2020-02-13  9:45 UTC (permalink / raw)
  To: Zhimin Feng; +Cc: zhang.zhanghailiang, Euler Robot, dgilbert, qemu-devel

Zhimin Feng <fengzhimin1@huawei.com> wrote:
> If the migration is cancelled when it is in the completion phase,
> the migration state is set to MIGRATION_STATUS_CANCELLING.
> The VM maybe wait for the 'pause_sem' semaphore in migration_maybe_pause
> function, so that VM always is paused.
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-13  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14  9:43 [PATCH] migration: Maybe VM is paused when migration is cancelled Zhimin Feng
2020-02-13  9:45 ` Juan Quintela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).