From patchwork Fri Mar 4 08:41:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changlong Xie X-Patchwork-Id: 8500101 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DC5E4C0553 for ; Fri, 4 Mar 2016 08:42:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBAB92014A for ; Fri, 4 Mar 2016 08:42:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0752A201F2 for ; Fri, 4 Mar 2016 08:42:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1ablHV-0007Ll-BD; Fri, 04 Mar 2016 08:40:17 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1ablHU-0007IU-Mr for xen-devel@lists.xen.org; Fri, 04 Mar 2016 08:40:16 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 0B/67-23864-FE949D65; Fri, 04 Mar 2016 08:40:15 +0000 X-Env-Sender: xiecl.fnst@cn.fujitsu.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1457080803!4530056!6 X-Originating-IP: [59.151.112.132] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55118 invoked from network); 4 Mar 2016 08:40:15 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-9.tower-31.messagelabs.com with SMTP; 4 Mar 2016 08:40:15 -0000 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="4230671" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Mar 2016 16:40:09 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 0422E42B4AFE; Fri, 4 Mar 2016 16:40:06 +0800 (CST) Received: from changlox.g08.fujitsu.local (10.167.225.55) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 4 Mar 2016 16:40:05 +0800 From: Changlong Xie To: xen devel , Konrad Rzeszutek Wilk , Andrew Cooper , Ian Campbell , Ian Jackson , Wei Liu Date: Fri, 4 Mar 2016 16:41:27 +0800 Message-ID: <1457080891-26054-24-git-send-email-xiecl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1457080891-26054-1-git-send-email-xiecl.fnst@cn.fujitsu.com> References: <1457080891-26054-1-git-send-email-xiecl.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.55] X-yoursite-MailScanner-ID: 0422E42B4AFE.AF05B X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xiecl.fnst@cn.fujitsu.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Cc: Lars Kurth , Changlong Xie , Wen Congyang , Gui Jianfeng , Jiang Yunhong , Dong Eddie , Anthony Perard , Shriram Rajagopalan , Yang Hongyang Subject: [Xen-devel] [PATCH v11 23/27] COLO proxy: preresume, postresume and checkpoint X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wen Congyang preresume, postresume and checkpoint Signed-off-by: Yang Hongyang Signed-off-by: Wen Congyang Signed-off-by: Changlong Xie --- tools/libxl/libxl_colo.h | 4 +++ tools/libxl/libxl_colo_proxy.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/tools/libxl/libxl_colo.h b/tools/libxl/libxl_colo.h index 9e7f99c..736927e 100644 --- a/tools/libxl/libxl_colo.h +++ b/tools/libxl/libxl_colo.h @@ -99,5 +99,9 @@ extern void libxl__colo_save_teardown(struct libxl__egc *egc, int rc); extern int colo_proxy_setup(libxl__colo_proxy_state *cps); extern void colo_proxy_teardown(libxl__colo_proxy_state *cps); +extern void colo_proxy_preresume(libxl__colo_proxy_state *cps); +extern void colo_proxy_postresume(libxl__colo_proxy_state *cps); +extern int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, + unsigned int timeout_us); #endif diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c index 2b3baa3..1b1dd40 100644 --- a/tools/libxl/libxl_colo_proxy.c +++ b/tools/libxl/libxl_colo_proxy.c @@ -216,3 +216,65 @@ void colo_proxy_teardown(libxl__colo_proxy_state *cps) cps->sock_fd = -1; } } + +/* ========= colo-proxy: preresume, postresume and checkpoint ========== */ + +void colo_proxy_preresume(libxl__colo_proxy_state *cps) +{ + colo_proxy_send(cps, NULL, 0, COLO_CHECKPOINT); + /* TODO: need to handle if the call fails... */ +} + +void colo_proxy_postresume(libxl__colo_proxy_state *cps) +{ + /* nothing to do... */ +} + +typedef struct colo_msg { + bool is_checkpoint; +} colo_msg; + +/* + * Return value: + * -1: error + * 0: no checkpoint event is received before timeout + * 1: do checkpoint + */ +int colo_proxy_checkpoint(libxl__colo_proxy_state *cps, + unsigned int timeout_us) +{ + uint8_t *buff; + int64_t size; + struct nlmsghdr *h; + struct colo_msg *m; + int ret = -1; + + STATE_AO_GC(cps->ao); + + size = colo_proxy_recv(cps, &buff, timeout_us); + + /* timeout, return no checkpoint message. */ + if (size <= 0) { + return 0; + } + + h = (struct nlmsghdr *) buff; + + if (h->nlmsg_type == NLMSG_ERROR) { + LOG(ERROR, "receive NLMSG_ERROR"); + goto out; + } + + if (h->nlmsg_len < NLMSG_LENGTH(sizeof(*m))) { + LOG(ERROR, "NLMSG_LENGTH is too short"); + goto out; + } + + m = NLMSG_DATA(h); + + ret = m->is_checkpoint ? 1 : 0; + +out: + free(buff); + return ret; +}