From patchwork Tue Feb 28 10:48:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 733435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vXb8h3ZVCz9s7h for ; Tue, 28 Feb 2017 21:55:48 +1100 (AEDT) Received: from localhost ([::1]:60139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cifRa-0005Ke-10 for incoming@patchwork.ozlabs.org; Tue, 28 Feb 2017 05:55:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cifLz-00007L-Jv for qemu-devel@nongnu.org; Tue, 28 Feb 2017 05:50:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cifLx-0004lw-3d for qemu-devel@nongnu.org; Tue, 28 Feb 2017 05:49:59 -0500 Received: from [59.151.112.132] (port=51588 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cifLw-0004lJ-LS for qemu-devel@nongnu.org; Tue, 28 Feb 2017 05:49:57 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="16050259" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 28 Feb 2017 18:49:46 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 8555447C4EAE; Tue, 28 Feb 2017 18:49:43 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 28 Feb 2017 18:49:43 +0800 From: Zhang Chen To: qemu devel , Jason Wang Date: Tue, 28 Feb 2017 18:48:22 +0800 Message-ID: <1488278902-11223-4-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488278902-11223-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> References: <1488278902-11223-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: 8555447C4EAE.AF3C4 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 3/3] COLO-compare: Add colo-compare Xen notify X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhijian , bian naimeng , "eddie . dong" , zhanghailiang , Zhang Chen Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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); + } + } /*