[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/6] migration/announce: Use the new parameters
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH 3/6] migration/announce: Use the new parameters |
Date: |
Tue, 28 Mar 2017 16:27:42 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Rework the existing constants to use the new parameters.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
hw/net/virtio-net.c | 3 ++-
include/migration/migration.h | 1 +
include/migration/vmstate.h | 10 ----------
migration/savevm.c | 32 ++++++++++++++++++++++++++++++--
4 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index c321680..b56b74a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -19,6 +19,7 @@
#include "net/tap.h"
#include "qemu/error-report.h"
#include "qemu/timer.h"
+#include "migration/migration.h"
#include "hw/virtio/virtio-net.h"
#include "net/vhost_net.h"
#include "hw/virtio/virtio-bus.h"
@@ -1611,7 +1612,7 @@ static int virtio_net_post_load_device(void *opaque, int
version_id)
if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
- n->announce_counter = SELF_ANNOUNCE_ROUNDS;
+ n->announce_counter = migrate_announce_rounds();
timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
}
diff --git a/include/migration/migration.h b/include/migration/migration.h
index a75800c..ba25dbf 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -344,6 +344,7 @@ int migrate_announce_initial(void);
int migrate_announce_max(void);
int migrate_announce_rounds(void);
int migrate_announce_step(void);
+int64_t self_announce_delay(int round);
/* Sending on the return path - generic and then for each message type */
void migrate_send_rp_message(MigrationIncomingState *mis,
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f2dbf84..c7ef11d 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -1003,8 +1003,6 @@ extern const VMStateInfo vmstate_info_qtailq;
#define VMSTATE_END_OF_LIST() \
{}
-#define SELF_ANNOUNCE_ROUNDS 5
-
void loadvm_free_handlers(MigrationIncomingState *mis);
int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
@@ -1038,14 +1036,6 @@ 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;
-}
-
void dump_vmstate_json_to_file(FILE *out_fp);
#endif
diff --git a/migration/savevm.c b/migration/savevm.c
index 361a926..69bb1d2 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -118,16 +118,44 @@ static void qemu_announce_self_iter(NICState *nic, void
*opaque)
qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
}
+/* Increasing delays between packets in the network announcments,
+ * both in the RARPs sent by QEMU and the ARPs triggered via virtio-net
+ * for the guest to send.
+ *
+ * Default parameters generate delays of
+ * 50, 150, 250, 350
+ * between 5 packets.
+ * which corresponds to:
+ * <> initial <> initial+step <> initial+2*step <> initial+3*step <>
+ * between 'rounds' packets
+ * A maximum can be used to override the step after a few packets.
+ */
+int64_t self_announce_delay(int round)
+{
+ int64_t ret;
+ ret = migrate_announce_initial() +
+ (migrate_announce_rounds() - round - 1) *
+ migrate_announce_step();
+ if (ret < 0 || ret > migrate_announce_max()) {
+ ret = migrate_announce_max();
+ }
+ return ret;
+}
static void qemu_announce_self_once(void *opaque)
{
- static int count = SELF_ANNOUNCE_ROUNDS;
+ static bool once = true;
+ static int count = -1;
QEMUTimer *timer = *(QEMUTimer **)opaque;
+ if (once) {
+ count = migrate_announce_rounds();
+ once = false;
+ }
+
qemu_foreach_nic(qemu_announce_self_iter, NULL);
if (--count) {
- /* delay 50ms, 150ms, 250ms, ... */
timer_mod(timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) +
self_announce_delay(count));
} else {
--
2.9.3
- [Qemu-devel] [PATCH 0/6 for 2.10] Parameterise self-announce, Dr. David Alan Gilbert (git), 2017/03/28
- [Qemu-devel] [PATCH 2/6] migration/announce: Accessor functions for parameters, Dr. David Alan Gilbert (git), 2017/03/28
- [Qemu-devel] [PATCH 1/6] migration/announce: Add parameters for self-announce, Dr. David Alan Gilbert (git), 2017/03/28
- [Qemu-devel] [PATCH 3/6] migration/announce: Use the new parameters,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH 4/6] migration/announce: Update hmp migrate parameter info/set, Dr. David Alan Gilbert (git), 2017/03/28
- [Qemu-devel] [PATCH 5/6] migration/announce: Document self-announce mechanism, Dr. David Alan Gilbert (git), 2017/03/28
- [Qemu-devel] [PATCH 6/6] migration/announce: Add test, Dr. David Alan Gilbert (git), 2017/03/28