qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH V2 2/3] migration: introduce self_announce_delay()


From: Jason Wang
Subject: [Qemu-devel] [PATCH V2 2/3] migration: introduce self_announce_delay()
Date: Tue, 20 May 2014 14:01:43 +0800

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]