From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaDh-0001mQ-Tq for qemu-devel@nongnu.org; Tue, 03 Nov 2015 06:57:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtaDf-0001Q5-UJ for qemu-devel@nongnu.org; Tue, 03 Nov 2015 06:57:45 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:22837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaDf-0001PO-0c for qemu-devel@nongnu.org; Tue, 03 Nov 2015 06:57:43 -0500 From: zhanghailiang Date: Tue, 3 Nov 2015 19:56:35 +0800 Message-ID: <1446551816-15768-18-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1446551816-15768-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1446551816-15768-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH COLO-Frame v10 17/38] 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 Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, zhanghailiang Do checkpoint periodically, the default interval is 200ms. Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian --- migration/colo.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 0efab21..a6791f4 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -11,12 +11,19 @@ */ #include +#include "qemu/timer.h" #include "sysemu/sysemu.h" #include "migration/colo.h" #include "trace.h" #include "qemu/error-report.h" #include "qemu/sockets.h" +/* + * checkpoint interval: unit ms + * Note: Please change this default value to 10000 when we support hybrid mode. + */ +#define CHECKPOINT_MAX_PEROID 200 + /* colo buffer */ #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) @@ -183,6 +190,7 @@ out: static void colo_process_checkpoint(MigrationState *s) { QEMUSizedBuffer *buffer = NULL; + int64_t current_time, checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); int fd, ret = 0; /* Dup the fd of to_dst_file */ @@ -220,11 +228,17 @@ 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 < CHECKPOINT_MAX_PEROID) { + g_usleep(100000); + continue; + } /* start a colo checkpoint */ ret = colo_do_checkpoint_transaction(s, buffer); if (ret < 0) { goto out; } + checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); } out: -- 1.8.3.1