From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6jsJ-0002VL-15 for qemu-devel@nongnu.org; Wed, 09 Dec 2015 13:54:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6jsE-0001WS-Qw for qemu-devel@nongnu.org; Wed, 09 Dec 2015 13:54:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6jsE-0001WM-Lr for qemu-devel@nongnu.org; Wed, 09 Dec 2015 13:53:58 -0500 Date: Wed, 9 Dec 2015 18:53:52 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20151209185352.GB12745@work-vm> References: <1448357149-17572-1-git-send-email-zhang.zhanghailiang@huawei.com> <1448357149-17572-21-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1448357149-17572-21-git-send-email-zhang.zhanghailiang@huawei.com> Subject: Re: [Qemu-devel] [PATCH COLO-Frame v11 20/39] COLO: synchronize PVM's state to SVM periodically List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, qemu-devel@nongnu.org, arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, hongyang.yang@easystack.cn * zhanghailiang (zhang.zhanghailiang@huawei.com) wrote: > Do checkpoint periodically, the default interval is 200ms. > > Signed-off-by: zhanghailiang > Signed-off-by: Li Zhijian Reviewed-by: Dr. David Alan Gilbert > --- > v11: > - Fix wrong sleep time for checkpoint period. (Dave's review comment) > --- > migration/colo.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/migration/colo.c b/migration/colo.c > index 4095d97..5b7ff87 100644 > --- a/migration/colo.c > +++ b/migration/colo.c > @@ -11,6 +11,7 @@ > */ > > #include > +#include "qemu/timer.h" > #include "sysemu/sysemu.h" > #include "migration/colo.h" > #include "trace.h" > @@ -183,6 +184,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 ret = 0; > uint64_t value; > > @@ -216,11 +218,21 @@ 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[MIGRATION_PARAMETER_CHECKPOINT_DELAY]) { > + int64_t delay_ms; > + > + delay_ms = s->parameters[MIGRATION_PARAMETER_CHECKPOINT_DELAY] - > + (current_time - checkpoint_time); > + g_usleep(delay_ms * 1000); > + } > /* 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 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK