From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwxKy-00056t-Ko for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwxKr-0003id-5d for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:38:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwxKq-0003iN-SP for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:38:17 -0400 Date: Tue, 17 Jun 2014 20:38:39 +0300 From: "Michael S. Tsirkin" Message-ID: <1403021756-15960-43-git-send-email-mst@redhat.com> References: <1403021756-15960-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1403021756-15960-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 042/103] migration: introduce self_announce_delay() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Fam Zheng , Eduardo Habkost , Juan Quintela , Jason Wang , Orit Wasserman , "Michael R. Hines" , Anthony Liguori , Paolo Bonzini From: 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 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/migration/vmstate.h | 8 ++++++++ savevm.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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); -- MST