[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 31/41] migration: final handshake for the resume
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 31/41] migration: final handshake for the resume |
Date: |
Wed, 9 May 2018 13:23:56 +0200 |
From: Peter Xu <address@hidden>
Finish the last step to do the final handshake for the recovery.
First source sends one MIG_CMD_RESUME to dst, telling that source is
ready to resume.
Then, dest replies with MIG_RP_MSG_RESUME_ACK to source, telling that
dest is ready to resume (after switch to postcopy-active state).
When source received the RESUME_ACK, it switches its state to
postcopy-active, and finally the recovery is completed.
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
migration/migration.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 19ef8b05b1..240960d951 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1924,7 +1924,8 @@ static int migrate_handle_rp_resume_ack(MigrationState
*s, uint32_t value)
migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER,
MIGRATION_STATUS_POSTCOPY_ACTIVE);
- /* TODO: notify send thread that time to continue send pages */
+ /* Notify send thread that time to continue send pages */
+ qemu_sem_post(&s->rp_state.rp_sem);
return 0;
}
@@ -2451,6 +2452,21 @@ typedef enum MigThrError {
MIG_THR_ERR_FATAL = 2,
} MigThrError;
+static int postcopy_resume_handshake(MigrationState *s)
+{
+ qemu_savevm_send_postcopy_resume(s->to_dst_file);
+
+ while (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER) {
+ qemu_sem_wait(&s->rp_state.rp_sem);
+ }
+
+ if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) {
+ return 0;
+ }
+
+ return -1;
+}
+
/* Return zero if success, or <0 for error */
static int postcopy_do_resume(MigrationState *s)
{
@@ -2468,10 +2484,14 @@ static int postcopy_do_resume(MigrationState *s)
}
/*
- * TODO: handshake with dest using MIG_CMD_RESUME,
- * MIG_RP_MSG_RESUME_ACK, then switch source state to
- * "postcopy-active"
+ * Last handshake with destination on the resume (destination will
+ * switch to postcopy-active afterwards)
*/
+ ret = postcopy_resume_handshake(s);
+ if (ret) {
+ error_report("%s: handshake failed: %d", __func__, ret);
+ return ret;
+ }
return 0;
}
--
2.17.0
- [Qemu-devel] [PULL 24/41] migration: new cmd MIG_CMD_RECV_BITMAP, (continued)
- [Qemu-devel] [PULL 24/41] migration: new cmd MIG_CMD_RECV_BITMAP, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 22/41] migration: new state "postcopy-recover", Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 26/41] migration: new cmd MIG_CMD_POSTCOPY_RESUME, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 25/41] migration: new message MIG_RP_MSG_RECV_BITMAP, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 28/41] migration: introduce SaveVMHandlers.resume_prepare, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 29/41] migration: synchronize dirty bitmap for resume, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 30/41] migration: setup ramstate for resume, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 27/41] migration: new message MIG_RP_MSG_RESUME_ACK, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 32/41] migration: init dst in migration_object_init too, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 31/41] migration: final handshake for the resume,
Juan Quintela <=
- [Qemu-devel] [PULL 34/41] hmp/migration: add migrate_recover command, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 35/41] migration: introduce lock for to_dst_file, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 33/41] qmp/migration: new command migrate-recover, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 36/41] migration/qmp: add command migrate-pause, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 37/41] migration/hmp: add migrate_pause command, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 39/41] migration: update index field when delete or qsort RDMALocalBlock, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 40/41] migration: Textual fixups for blocktime, Juan Quintela, 2018/05/09
- [Qemu-devel] [PULL 41/41] Migration+TLS: Fix crash due to double cleanup, Juan Quintela, 2018/05/09