[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/3] COLO-compare: Add colo-compare Xen notify
From: |
Zhang Chen |
Subject: |
[Qemu-devel] [PATCH 3/3] COLO-compare: Add colo-compare Xen notify |
Date: |
Tue, 28 Feb 2017 18:48:22 +0800 |
This patch have some TODO job.
Depend on patch:
https://lists.nongnu.org/archive/html/qemu-devel/2017-02/msg05055.html
Signed-off-by: Zhang Chen <address@hidden>
---
net/colo-compare.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 947a9e2..073d1f8 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -103,6 +103,7 @@ enum {
static int compare_chr_send(CharBackend *out,
const uint8_t *buf,
uint32_t size);
+static void colo_flush_packets(void *opaque, void *user_data);
static gint seq_sorter(Packet *a, Packet *b, gpointer data)
{
@@ -430,6 +431,15 @@ static void colo_compare_connection(void *opaque, void
*user_data)
trace_colo_compare_main("packet different");
g_queue_push_tail(&conn->primary_list, pkt);
/* TODO: colo_notify_checkpoint();*/
+ /* If we have notify_dev that means COLO run on Xen */
+ if (s->notify_dev) {
+ char msg[] = "DO_CHECKPOINT";
+ ret = compare_chr_send(&s->chr_notify_dev, (uint8_t *)msg,
+ strlen(msg));
+ if (ret < 0) {
+ error_report("Notify Xen COLO-frame failed");
+ }
+ }
break;
}
}
@@ -645,7 +655,26 @@ static void compare_sec_rs_finalize(SocketReadState
*sec_rs)
static void compare_notify_rs_finalize(SocketReadState *notify_rs)
{
+ CompareState *s = container_of(notify_rs, CompareState, notify_rs);
+
/* Get Xen colo-frame's notify and handle the message */
+ char *data = g_memdup(notify_rs->buf, notify_rs->packet_len);
+ char msg[] = "COLO_COMPARE_GET_XEN_INIT";
+ int ret;
+
+ if (!strcmp(data, "COLO_USERSPACE_PROXY_INIT")) {
+ ret = compare_chr_send(&s->chr_notify_dev, (uint8_t *)msg,
+ strlen(msg));
+ if (ret < 0) {
+ error_report("Notify Xen COLO-frame INIT failed");
+ }
+ }
+
+ if (!strcmp(data, "COLO_CHECKPOINT")) {
+ /* colo-compare do checkpoint, flush pri packet and remove sec packet
*/
+ g_queue_foreach(&s->conn_list, colo_flush_packets, s);
+ }
+
}
/*
--
2.7.4