Signed-off-by: zhanghailiang <zhang.zhanghaili...@huawei.com> Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com> --- include/net/colo-nic.h | 3 ++- migration/colo.c | 22 +++++++++++++++++++--- net/colo-nic.c | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/include/net/colo-nic.h b/include/net/colo-nic.h index 67c9807..ddc21cd 100644 --- a/include/net/colo-nic.h +++ b/include/net/colo-nic.h @@ -20,5 +20,6 @@ void colo_add_nic_devices(NetClientState *nc); void colo_remove_nic_devices(NetClientState *nc); int colo_proxy_compare(void); - +int colo_proxy_failover(void); +int colo_proxy_checkpoint(void); #endif diff --git a/migration/colo.c b/migration/colo.c index 1c4b222..54ae184 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -122,6 +122,11 @@ static void slave_do_failover(void) ; } + if (colo_proxy_failover() != 0) { + error_report("colo proxy failed to do failover"); + } + colo_proxy_destroy(COLO_SECONDARY_MODE); + colo = NULL; if (!autostart) { @@ -144,6 +149,8 @@ static void master_do_failover(void) vm_stop_force_state(RUN_STATE_COLO); } + colo_proxy_destroy(COLO_PRIMARY_MODE); + if (s->state != MIGRATION_STATUS_FAILED) { migrate_set_state(s, MIGRATION_STATUS_COLO, MIGRATION_STATUS_COMPLETED); } @@ -267,6 +274,11 @@ static int colo_do_checkpoint_transaction(MigrationState *s, QEMUFile *control) qemu_fflush(trans); + ret = colo_proxy_checkpoint(); + if (ret < 0) { + goto out; + } + ret = colo_ctl_put(s->file, COLO_CHECKPOINT_SEND); if (ret < 0) { goto out; @@ -413,8 +425,6 @@ out: qemu_bh_schedule(s->cleanup_bh); qemu_mutex_unlock_iothread(); - colo_proxy_destroy(COLO_PRIMARY_MODE); - return NULL; } @@ -542,6 +552,12 @@ void *colo_process_incoming_checkpoints(void *opaque) goto out; } + ret = colo_proxy_checkpoint(); + if (ret < 0) { + goto out; + } + DPRINTF("proxy begin to do checkpoint\n"); + ret = colo_ctl_get(f, COLO_CHECKPOINT_SEND); if (ret < 0) { goto out; @@ -618,6 +634,7 @@ out: * just kill slave */ error_report("SVM is going to exit!"); + colo_proxy_destroy(COLO_SECONDARY_MODE); exit(1); } else { /* if we went here, means master may dead, we are doing failover */ @@ -642,6 +659,5 @@ out: loadvm_exit_colo(); - colo_proxy_destroy(COLO_SECONDARY_MODE); return NULL; } diff --git a/net/colo-nic.c b/net/colo-nic.c index 563d661..02a454d 100644 --- a/net/colo-nic.c +++ b/net/colo-nic.c @@ -379,6 +379,25 @@ void colo_proxy_destroy(int side) cp_info.index = -1; colo_nic_side = -1; } + +int colo_proxy_failover(void) +{ + if (colo_proxy_send(NULL, 0, COLO_FAILOVER) < 0) { + return -1; + } + + return 0; +} + +int colo_proxy_checkpoint(void) +{ + if (colo_proxy_send(NULL, 0, COLO_CHECKPOINT) < 0) { + return -1; + } + + return 0; +} + /* do checkpoint: return 1 error: return -1 -- 1.7.12.4