From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8jvY-0006xg-Nw for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:53:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8jvW-0004kL-QM for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:53:55 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:24120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8jvW-0004jG-4g for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:53:54 -0400 From: zhanghailiang Date: Fri, 3 Jun 2016 15:52:27 +0800 Message-ID: <1464940366-9880-16-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1464940366-9880-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1464940366-9880-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH COLO-Frame v17 15/34] COLO: Synchronize PVM's state to SVM periodically List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, amit.shah@redhat.com, quintela@redhat.com, dgilbert@redhat.com Cc: peter.huangpeng@huawei.com, eddie.dong@intel.com, yunhong.jiang@intel.com, wency@cn.fujitsu.com, lizhijian@cn.fujitsu.com, arei.gonglei@huawei.com, stefanha@redhat.com, hongyang.yang@easystack.cn, zhangchen.fnst@cn.fujitsu.com, xiecl.fnst@cn.fujitsu.com, zhanghailiang Do checkpoint periodically, the default interval is 200ms. Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian Reviewed-by: Dr. David Alan Gilbert --- v12: - Add Reviewed-by tag v11: - Fix wrong sleep time for checkpoint period. (Dave's comment) --- migration/colo.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 396cdcf..47718e7 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" +#include "qemu/timer.h" #include "sysemu/sysemu.h" #include "migration/colo.h" #include "io/channel-buffer.h" @@ -226,6 +227,7 @@ static void colo_process_checkpoint(MigrationState *s) { QIOChannelBuffer *bioc; QEMUFile *fb = NULL; + int64_t current_time, checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); Error *local_err = NULL; int ret; @@ -254,10 +256,20 @@ static void colo_process_checkpoint(MigrationState *s) trace_colo_vm_state_change("stop", "run"); while (s->state == MIGRATION_STATUS_COLO) { + current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); + if (current_time - checkpoint_time < + s->parameters.x_checkpoint_delay) { + int64_t delay_ms; + + delay_ms = s->parameters.x_checkpoint_delay - + (current_time - checkpoint_time); + g_usleep(delay_ms * 1000); + } ret = colo_do_checkpoint_transaction(s, bioc, fb); if (ret < 0) { goto out; } + checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); } out: -- 1.8.3.1