[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/18] migration: Switch to COLO process after finish
From: |
Amit Shah |
Subject: |
[Qemu-devel] [PULL 04/18] migration: Switch to COLO process after finishing loadvm |
Date: |
Sun, 30 Oct 2016 16:16:56 +0530 |
From: zhanghailiang <address@hidden>
Switch from normal migration loadvm process into COLO checkpoint process if
COLO mode is enabled.
We add three new members to struct MigrationIncomingState,
'have_colo_incoming_thread' and 'colo_incoming_thread' record the COLO
related thread for secondary VM, 'migration_incoming_co' records the
original migration incoming coroutine.
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Li Zhijian <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Amit Shah <address@hidden>
Signed-off-by: Amit Shah <address@hidden>
---
include/migration/colo.h | 7 +++++++
include/migration/migration.h | 7 +++++++
migration/colo-comm.c | 10 ++++++++++
migration/colo.c | 21 +++++++++++++++++++++
migration/migration.c | 12 ++++++++++++
stubs/migration-colo.c | 10 ++++++++++
6 files changed, 67 insertions(+)
diff --git a/include/migration/colo.h b/include/migration/colo.h
index bf84b99..b40676c 100644
--- a/include/migration/colo.h
+++ b/include/migration/colo.h
@@ -15,6 +15,8 @@
#include "qemu-common.h"
#include "migration/migration.h"
+#include "qemu/coroutine_int.h"
+#include "qemu/thread.h"
bool colo_supported(void);
void colo_info_init(void);
@@ -22,4 +24,9 @@ void colo_info_init(void);
void migrate_start_colo_process(MigrationState *s);
bool migration_in_colo_state(void);
+/* loadvm */
+bool migration_incoming_enable_colo(void);
+void migration_incoming_exit_colo(void);
+void *colo_process_incoming_thread(void *opaque);
+bool migration_incoming_in_colo_state(void);
#endif
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 34f442b..c309d23 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -21,6 +21,7 @@
#include "migration/vmstate.h"
#include "qapi-types.h"
#include "exec/cpu-common.h"
+#include "qemu/coroutine_int.h"
#define QEMU_VM_FILE_MAGIC 0x5145564d
#define QEMU_VM_FILE_VERSION_COMPAT 0x00000002
@@ -107,6 +108,12 @@ struct MigrationIncomingState {
QEMUBH *bh;
int state;
+
+ bool have_colo_incoming_thread;
+ QemuThread colo_incoming_thread;
+ /* The coroutine we should enter (back) after failover */
+ Coroutine *migration_incoming_co;
+
/* See savevm.c */
LoadStateEntry_Head loadvm_handlers;
};
diff --git a/migration/colo-comm.c b/migration/colo-comm.c
index a2d5185..bf44f76 100644
--- a/migration/colo-comm.c
+++ b/migration/colo-comm.c
@@ -49,3 +49,13 @@ void colo_info_init(void)
{
vmstate_register(NULL, 0, &colo_state, &colo_info);
}
+
+bool migration_incoming_enable_colo(void)
+{
+ return colo_info.colo_requested;
+}
+
+void migration_incoming_exit_colo(void)
+{
+ colo_info.colo_requested = false;
+}
diff --git a/migration/colo.c b/migration/colo.c
index f480431..550cc5f 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -27,6 +27,13 @@ bool migration_in_colo_state(void)
return (s->state == MIGRATION_STATUS_COLO);
}
+bool migration_incoming_in_colo_state(void)
+{
+ MigrationIncomingState *mis = migration_incoming_get_current();
+
+ return mis && (mis->state == MIGRATION_STATUS_COLO);
+}
+
static void colo_process_checkpoint(MigrationState *s)
{
qemu_mutex_lock_iothread();
@@ -46,3 +53,17 @@ void migrate_start_colo_process(MigrationState *s)
colo_process_checkpoint(s);
qemu_mutex_lock_iothread();
}
+
+void *colo_process_incoming_thread(void *opaque)
+{
+ MigrationIncomingState *mis = opaque;
+
+ migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
+ MIGRATION_STATUS_COLO);
+
+ /* TODO: COLO checkpoint restore loop */
+
+ migration_incoming_exit_colo();
+
+ return NULL;
+}
diff --git a/migration/migration.c b/migration/migration.c
index aff3eb4..d8421b5 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -407,6 +407,18 @@ static void process_incoming_migration_co(void *opaque)
/* Else if something went wrong then just fall out of the normal exit
*/
}
+ /* we get COLO info, and know if we are in COLO mode */
+ if (!ret && migration_incoming_enable_colo()) {
+ mis->migration_incoming_co = qemu_coroutine_self();
+ qemu_thread_create(&mis->colo_incoming_thread, "COLO incoming",
+ colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE);
+ mis->have_colo_incoming_thread = true;
+ qemu_coroutine_yield();
+
+ /* Wait checkpoint incoming thread exit before free resource */
+ qemu_thread_join(&mis->colo_incoming_thread);
+ }
+
qemu_fclose(f);
free_xbzrle_decoded_buf();
diff --git a/stubs/migration-colo.c b/stubs/migration-colo.c
index 0c8eef4..7b72395 100644
--- a/stubs/migration-colo.c
+++ b/stubs/migration-colo.c
@@ -23,6 +23,16 @@ bool migration_in_colo_state(void)
return false;
}
+bool migration_incoming_in_colo_state(void)
+{
+ return false;
+}
+
void migrate_start_colo_process(MigrationState *s)
{
}
+
+void *colo_process_incoming_thread(void *opaque)
+{
+ return NULL;
+}
--
2.7.4
- [Qemu-devel] [PULL 00/18] migration: COLO, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 01/18] migration: Introduce capability 'x-colo' to migration, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 02/18] COLO: migrate COLO related info to secondary node, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 03/18] migration: Enter into COLO mode after migration if COLO is enabled, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 04/18] migration: Switch to COLO process after finishing loadvm,
Amit Shah <=
- [Qemu-devel] [PULL 05/18] COLO: Establish a new communicating path for COLO, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 06/18] COLO: Introduce checkpointing protocol, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 07/18] COLO: Add a new RunState RUN_STATE_COLO, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 08/18] COLO: Send PVM state to secondary side when do checkpoint, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 09/18] COLO: Load VMState into QIOChannelBuffer before restore it, Amit Shah, 2016/10/30
- [Qemu-devel] [PULL 10/18] COLO: Add checkpoint-delay parameter for migrate-set-parameters, Amit Shah, 2016/10/30