From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmdMk-0001BZ-Hq for qemu-devel@nongnu.org; Tue, 20 May 2014 02:17:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmdMe-00057h-Di for qemu-devel@nongnu.org; Tue, 20 May 2014 02:17:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmdMe-00057T-5g for qemu-devel@nongnu.org; Tue, 20 May 2014 02:17:28 -0400 From: Jason Wang Date: Tue, 20 May 2014 14:01:43 +0800 Message-Id: <1400565704-11592-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1400565704-11592-1-git-send-email-jasowang@redhat.com> References: <1400565704-11592-1-git-send-email-jasowang@redhat.com> Subject: [Qemu-devel] [PATCH V2 2/3] migration: introduce self_announce_delay() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, mst@redhat.com, aliguori@amazon.com Cc: Jason Wang This patch introduces self_announce_delay() to calculate the delay for the next announce round. This could be used by other device e.g virtio-net who wants to do announcing by itself. Signed-off-by: Jason Wang --- include/migration/vmstate.h | 8 ++++++++ savevm.c | 2 +- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 6edce98..799d2d0 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -780,4 +780,12 @@ void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev); void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev); void vmstate_register_ram_global(struct MemoryRegion *memory); +static inline +int64_t self_announce_delay(int round) +{ + assert(round < SELF_ANNOUNCE_ROUNDS && round > 0); + /* delay 50ms, 150ms, 250ms, ... */ + return 50 + (SELF_ANNOUNCE_ROUNDS - round - 1) * 100; +} + #endif diff --git a/savevm.c b/savevm.c index f5273f3..e126023 100644 --- a/savevm.c +++ b/savevm.c @@ -97,7 +97,7 @@ static void qemu_announce_self_once(void *opaque) if (--count) { /* delay 50ms, 150ms, 250ms, ... */ timer_mod(timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + - 50 + (SELF_ANNOUNCE_ROUNDS - count - 1) * 100); + self_announce_delay(count)); } else { timer_del(timer); timer_free(timer); -- 1.7.1