From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb0Q2-0000xu-Gz for qemu-devel@nongnu.org; Thu, 26 Mar 2015 01:33:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yb0Py-0007R3-5o for qemu-devel@nongnu.org; Thu, 26 Mar 2015 01:33:26 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:42067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb0Px-0007QY-DR for qemu-devel@nongnu.org; Thu, 26 Mar 2015 01:33:22 -0400 From: zhanghailiang Date: Thu, 26 Mar 2015 13:29:31 +0800 Message-ID: <1427347774-8960-26-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1427347774-8960-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1427347774-8960-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RFC PATCH v4 25/28] COLO NIC: Implement NIC checkpoint and failover List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, zhanghailiang , arei.gonglei@huawei.com, amit.shah@redhat.com, david@gibson.dropbear.id.au Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian --- 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