diff mbox

[02/12] migration: Introduce announcement timer

Message ID 1495649128-10529-3-git-send-email-vyasevic@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vlad Yasevich May 24, 2017, 6:05 p.m. UTC
Introdec an annoucement timer structure and initialization to
be used by for self-annoucement.

Based on the work by Germano Veit Michel <germano@redhat.com>

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
 include/migration/vmstate.h | 13 +++++++++++++
 migration/savevm.c          | 22 ++++++++++++++++++++++
 2 files changed, 35 insertions(+)

Comments

Jason Wang May 26, 2017, 4:13 a.m. UTC | #1
On 2017年05月25日 02:05, Vladislav Yasevich wrote:
> Introdec

Typo.

Thanks

> an annoucement timer structure and initialization to
> be used by for self-annoucement.
>
> Based on the work by Germano Veit Michel <germano@redhat.com>
>
> Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
> ---
>   include/migration/vmstate.h | 13 +++++++++++++
>   migration/savevm.c          | 22 ++++++++++++++++++++++
>   2 files changed, 35 insertions(+)
>
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 8489659..a6bf84d 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -1057,6 +1057,19 @@ 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);
>   
> +typedef struct AnnounceTimer {
> +    QEMUTimer *tm;
> +    AnnounceParameters params;
> +    QEMUClockType type;
> +    int round;
> +} AnnounceTimer;
> +
> +AnnounceTimer *qemu_announce_timer_new(AnnounceParameters *params,
> +                                       QEMUClockType type);
> +AnnounceTimer *qemu_announce_timer_create(AnnounceParameters *params,
> +                                          QEMUClockType type,
> +                                          QEMUTimerCB *cb);
> +
>   static inline
>   int64_t self_announce_delay(int round)
>   {
> diff --git a/migration/savevm.c b/migration/savevm.c
> index cee2837..607b090 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -230,6 +230,28 @@ static void qemu_announce_self_once(void *opaque)
>       }
>   }
>   
> +AnnounceTimer *qemu_announce_timer_new(AnnounceParameters *params,
> +                                       QEMUClockType type)
> +{
> +    AnnounceTimer *timer = g_new(AnnounceTimer, 1);
> +
> +    timer->params = *params;
> +    timer->round = params->rounds;
> +    timer->type = type;
> +
> +    return timer;
> +}
> +
> +AnnounceTimer *qemu_announce_timer_create(AnnounceParameters *params,
> +                                          QEMUClockType type,
> +                                          QEMUTimerCB *cb)
> +{
> +    AnnounceTimer *timer = qemu_announce_timer_new(params, type);
> +
> +    timer->tm = timer_new_ms(type, cb, timer);
> +    return timer;
> +}
> +
>   void qemu_announce_self(void)
>   {
>       static QEMUTimer *timer;
Juan Quintela May 30, 2017, 10 a.m. UTC | #2
Vladislav Yasevich <vyasevic@redhat.com> wrote:
> Introdec an annoucement timer structure and initialization to
> be used by for self-annoucement.
>
> Based on the work by Germano Veit Michel <germano@redhat.com>
>
> Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>

Please, pretty please, create them in net/somewhere, or at least create

include/migration/net.h and migration/net.c

Except for that, code looks nice.
diff mbox

Patch

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 8489659..a6bf84d 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -1057,6 +1057,19 @@  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);
 
+typedef struct AnnounceTimer {
+    QEMUTimer *tm;
+    AnnounceParameters params;
+    QEMUClockType type;
+    int round;
+} AnnounceTimer;
+
+AnnounceTimer *qemu_announce_timer_new(AnnounceParameters *params,
+                                       QEMUClockType type);
+AnnounceTimer *qemu_announce_timer_create(AnnounceParameters *params,
+                                          QEMUClockType type,
+                                          QEMUTimerCB *cb);
+
 static inline
 int64_t self_announce_delay(int round)
 {
diff --git a/migration/savevm.c b/migration/savevm.c
index cee2837..607b090 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -230,6 +230,28 @@  static void qemu_announce_self_once(void *opaque)
     }
 }
 
+AnnounceTimer *qemu_announce_timer_new(AnnounceParameters *params,
+                                       QEMUClockType type)
+{
+    AnnounceTimer *timer = g_new(AnnounceTimer, 1);
+
+    timer->params = *params;
+    timer->round = params->rounds;
+    timer->type = type;
+
+    return timer;
+}
+
+AnnounceTimer *qemu_announce_timer_create(AnnounceParameters *params,
+                                          QEMUClockType type,
+                                          QEMUTimerCB *cb)
+{
+    AnnounceTimer *timer = qemu_announce_timer_new(params, type);
+
+    timer->tm = timer_new_ms(type, cb, timer);
+    return timer;
+}
+
 void qemu_announce_self(void)
 {
     static QEMUTimer *timer;