[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 03/18] colo-compare: use notifier to notify packe
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [PATCH v2 03/18] colo-compare: use notifier to notify packets comparing result |
Date: |
Sat, 22 Apr 2017 16:25:43 +0800 |
It's a good idea to use notifier to notify COLO frame of
inconsistent packets comparing.
Cc: Jason Wang <address@hidden>
Signed-off-by: Zhang Chen <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
---
net/colo-compare.c | 32 ++++++++++++++++++++++++++++----
net/colo-compare.h | 2 ++
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 3adccfb..bb234dd 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -30,6 +30,7 @@
#include "qapi-visit.h"
#include "net/colo.h"
#include "net/colo-compare.h"
+#include "migration/migration.h"
#define TYPE_COLO_COMPARE "colo-compare"
#define COLO_COMPARE(obj) \
@@ -38,6 +39,9 @@
static QTAILQ_HEAD(, CompareState) net_compares =
QTAILQ_HEAD_INITIALIZER(net_compares);
+static NotifierList colo_compare_notifiers =
+ NOTIFIER_LIST_INITIALIZER(colo_compare_notifiers);
+
#define COMPARE_READ_LEN_MAX NET_BUFSIZE
#define MAX_QUEUE_SIZE 1024
@@ -384,6 +388,22 @@ static int colo_old_packet_check_one(Packet *pkt, int64_t
*check_time)
}
}
+static void colo_compare_inconsistent_notify(void)
+{
+ notifier_list_notify(&colo_compare_notifiers,
+ migrate_get_current());
+}
+
+void colo_compare_register_notifier(Notifier *notify)
+{
+ notifier_list_add(&colo_compare_notifiers, notify);
+}
+
+void colo_compare_unregister_notifier(Notifier *notify)
+{
+ notifier_remove(notify);
+}
+
static void colo_old_packet_check_one_conn(void *opaque,
void *user_data)
{
@@ -397,7 +417,7 @@ static void colo_old_packet_check_one_conn(void *opaque,
if (result) {
/* do checkpoint will flush old packet */
- /* TODO: colo_notify_checkpoint();*/
+ colo_compare_inconsistent_notify();
}
}
@@ -415,7 +435,10 @@ static void colo_old_packet_check(void *opaque)
/*
* Called from the compare thread on the primary
- * for compare connection
+ * for compare connection.
+ * TODO: Reconstruct this function, we should hold the max handled sequence
+ * of the connect, Don't trigger a checkpoint request if we only get packets
+ * from one side (primary or secondary).
*/
static void colo_compare_connection(void *opaque, void *user_data)
{
@@ -464,11 +487,12 @@ static void colo_compare_connection(void *opaque, void
*user_data)
/*
* If one packet arrive late, the secondary_list or
* primary_list will be empty, so we can't compare it
- * until next comparison.
+ * until next comparison. If the packets in the list are
+ * timeout, it will trigger a checkpoint request.
*/
trace_colo_compare_main("packet different");
g_queue_push_tail(&conn->primary_list, pkt);
- /* TODO: colo_notify_checkpoint();*/
+ colo_compare_inconsistent_notify();
break;
}
}
diff --git a/net/colo-compare.h b/net/colo-compare.h
index c9c62f5..a0b573e 100644
--- a/net/colo-compare.h
+++ b/net/colo-compare.h
@@ -2,5 +2,7 @@
#define QEMU_COLO_COMPARE_H
void colo_notify_compares_event(void *opaque, int event, Error **errp);
+void colo_compare_register_notifier(Notifier *notify);
+void colo_compare_unregister_notifier(Notifier *notify);
#endif /* QEMU_COLO_COMPARE_H */
--
1.8.3.1
- [Qemu-devel] [PATCH v2 02/18] colo-compare: implement the process of checkpoint, (continued)
- [Qemu-devel] [PATCH v2 02/18] colo-compare: implement the process of checkpoint, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 01/18] net/colo: Add notifier/callback related helpers for filter, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 16/18] filter: Add handle_event method for NetFilterClass, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 17/18] filter-rewriter: handle checkpoint and failover event, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 07/18] COLO: Load dirty pages into SVM's RAM cache firstly, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 10/18] qmp event: Add COLO_EXIT event to notify users while exited COLO, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 05/18] COLO: Handle shutdown command for VM in COLO state, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 18/18] COLO: notify net filters about checkpoint/failover event, zhanghailiang, 2017/04/22
- [Qemu-devel] [PATCH v2 03/18] colo-compare: use notifier to notify packets comparing result,
zhanghailiang <=