[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 22/32] migration: final handshake for the resume
From: |
Peter Xu |
Subject: |
[Qemu-devel] [PATCH v3 22/32] migration: final handshake for the resume |
Date: |
Mon, 16 Oct 2017 14:52:06 +0800 |
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>
---
migration/migration.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 52f81c3add..edf7365b69 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1807,7 +1807,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;
}
@@ -2290,6 +2291,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)
{
@@ -2307,10 +2323,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.13.5
- [Qemu-devel] [PATCH v3 12/32] migration: rebuild channel on source, (continued)
- [Qemu-devel] [PATCH v3 12/32] migration: rebuild channel on source, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 13/32] migration: new state "postcopy-recover", Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 14/32] migration: wakeup dst ram-load-thread for recover, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 15/32] migration: new cmd MIG_CMD_RECV_BITMAP, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 16/32] migration: new message MIG_RP_MSG_RECV_BITMAP, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 17/32] migration: new cmd MIG_CMD_POSTCOPY_RESUME, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 18/32] migration: new message MIG_RP_MSG_RESUME_ACK, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 19/32] migration: introduce SaveVMHandlers.resume_prepare, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 20/32] migration: synchronize dirty bitmap for resume, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 21/32] migration: setup ramstate for resume, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 22/32] migration: final handshake for the resume,
Peter Xu <=
- [Qemu-devel] [PATCH v3 23/32] migration: free SocketAddress where allocated, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 24/32] migration: return incoming task tag for sockets, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 25/32] migration: return incoming task tag for exec, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 26/32] migration: return incoming task tag for fd, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 27/32] migration: store listen task tag, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 28/32] migration: allow migrate_incoming for paused VM, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 29/32] migration: init dst in migration_object_init too, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 30/32] migration: delay the postcopy-active state switch, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 31/32] migration, qmp: new command "migrate-pause", Peter Xu, 2017/10/16