From patchwork Wed Jun 18 16:18:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 361714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C8A32140084 for ; Thu, 19 Jun 2014 04:25:31 +1000 (EST) Received: from localhost ([::1]:59906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxKY5-00075A-PF for incoming@patchwork.ozlabs.org; Wed, 18 Jun 2014 14:25:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxIYY-0000wC-IV for qemu-devel@nongnu.org; Wed, 18 Jun 2014 12:17:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxIYR-0006oM-2r for qemu-devel@nongnu.org; Wed, 18 Jun 2014 12:17:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxIYQ-0006oA-PN for qemu-devel@nongnu.org; Wed, 18 Jun 2014 12:17:43 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5IGHdXU019302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jun 2014 12:17:39 -0400 Received: from redhat.com (ovpn-116-25.ams2.redhat.com [10.36.116.25]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id s5IGHZuD008363; Wed, 18 Jun 2014 12:17:35 -0400 Date: Wed, 18 Jun 2014 19:18:04 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1403108034-32054-42-git-send-email-mst@redhat.com> References: <1403108034-32054-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1403108034-32054-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Fam Zheng , Eduardo Habkost , Juan Quintela , Jason Wang , Orit Wasserman , "Michael R. Hines" , Anthony Liguori , Paolo Bonzini Subject: [Qemu-devel] [PULL v2 041/106] migration: introduce self_announce_delay() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);