qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, mst@redhat.com, aliguori@amazon.com
Cc: Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PATCH V2 2/3] migration: introduce self_announce_delay()
Date: Tue, 20 May 2014 14:01:43 +0800	[thread overview]
Message-ID: <1400565704-11592-3-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1400565704-11592-1-git-send-email-jasowang@redhat.com>

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 <jasowang@redhat.com>
---
 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

  parent reply	other threads:[~2014-05-20  6:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20  6:01 [Qemu-devel] [PATCH V2 0/3] virtio-net: announce self by guest Jason Wang
2014-05-20  6:01 ` [Qemu-devel] [PATCH V2 1/3] migration: export SELF_ANNOUNCE_ROUNDS Jason Wang
2014-05-20  6:01 ` Jason Wang [this message]
2014-05-20  6:01 ` [Qemu-devel] [PATCH V2 3/3] virtio-net: announce self by guest Jason Wang
2014-06-10  6:20   ` Amit Shah
2014-06-10 10:10     ` Michael S. Tsirkin
2014-06-11  2:50       ` Jason Wang
2014-06-13 12:35         ` Amit Shah
2014-06-11 14:42 ` [Qemu-devel] [PATCH V2 0/3] " Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400565704-11592-3-git-send-email-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).