From patchwork Mon Feb 22 02:52:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 8370741 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 251D3C0553 for ; Mon, 22 Feb 2016 02:54:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3790B203B4 for ; Mon, 22 Feb 2016 02:54:35 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2A64E203AC for ; Mon, 22 Feb 2016 02:54:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXgba-00015j-Pt; Mon, 22 Feb 2016 02:52:10 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXgbX-00011v-T8 for xen-devel@lists.xen.org; Mon, 22 Feb 2016 02:52:07 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id 22/B0-28791-7D77AC65; Mon, 22 Feb 2016 02:52:07 +0000 X-Env-Sender: wency@cn.fujitsu.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1456109516!25574131!5 X-Originating-IP: [59.151.112.132] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63053 invoked from network); 22 Feb 2016 02:52:06 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-5.tower-27.messagelabs.com with SMTP; 22 Feb 2016 02:52:06 -0000 X-IronPort-AV: E=Sophos;i="5.20,346,1444665600"; d="scan'208";a="3766037" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 Feb 2016 10:52:02 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 4BC7642AC843; Mon, 22 Feb 2016 10:50:05 +0800 (CST) Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 22 Feb 2016 10:51:55 +0800 From: Wen Congyang To: xen devel , Konrad Rzeszutek Wilk , Andrew Cooper , Ian Campbell , Ian Jackson , Wei Liu Date: Mon, 22 Feb 2016 10:52:15 +0800 Message-ID: <1456109555-28299-12-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456109555-28299-1-git-send-email-wency@cn.fujitsu.com> References: <1456109555-28299-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.52] X-yoursite-MailScanner-ID: 4BC7642AC843.A690C X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: wency@cn.fujitsu.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Cc: Lars Kurth , Changlong Xie , Wen Congyang , Gui Jianfeng , Jiang Yunhong , Dong Eddie , Shriram Rajagopalan , Yang Hongyang Subject: [Xen-devel] [PATCH v10 11/31] tools/libxl: write checkpoint_state records into the stream X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP write checkpoint_state records into the stream, used by both primary and secondary to send colo context. Signed-off-by: Yang Hongyang Signed-off-by: Wen Congyang --- tools/libxl/libxl_internal.h | 5 ++++ tools/libxl/libxl_stream_write.c | 60 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index e02e554..cdf6751 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3056,6 +3056,7 @@ struct libxl__stream_write_state { bool running; bool in_checkpoint; bool sync_teardown; /* Only used to coordinate shutdown on error path. */ + bool in_checkpoint_state; libxl__save_helper_state shs; /* Main stream-writing data. */ @@ -3079,6 +3080,10 @@ _hidden void libxl__stream_write_start(libxl__egc *egc, _hidden void libxl__stream_write_start_checkpoint(libxl__egc *egc, libxl__stream_write_state *stream); +_hidden void +libxl__stream_write_checkpoint_state(libxl__egc *egc, + libxl__stream_write_state *stream, + libxl_sr_checkpoint_state *srcs); _hidden void libxl__stream_write_abort(libxl__egc *egc, libxl__stream_write_state *stream, int rc); diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c index 5379126..8e0e57e 100644 --- a/tools/libxl/libxl_stream_write.c +++ b/tools/libxl/libxl_stream_write.c @@ -98,6 +98,12 @@ static void write_checkpoint_end_record(libxl__egc *egc, static void checkpoint_end_record_done(libxl__egc *egc, libxl__stream_write_state *stream); +/* checkpoint state */ +static void write_checkpoint_state_done(libxl__egc *egc, + libxl__stream_write_state *stream); +static void checkpoint_state_done(libxl__egc *egc, + libxl__stream_write_state *stream, int rc); + /*----- Helpers -----*/ static void write_done(libxl__egc *egc, @@ -589,6 +595,21 @@ static void stream_complete(libxl__egc *egc, return; } + if (stream->in_checkpoint_state) { + assert(rc); + + /* + * If an error is encountered while in a checkpoint, pass it + * back to libxc. The failure will come back around to us via + * 1. normal stream + * libxl__xc_domain_save_done() + * 2. back_channel stream + * libxl__stream_write_abort() + */ + checkpoint_state_done(egc, stream, rc); + return; + } + stream_done(egc, stream, rc); } @@ -596,6 +617,7 @@ static void stream_done(libxl__egc *egc, libxl__stream_write_state *stream, int rc) { assert(stream->running); + assert(!stream->in_checkpoint_state); stream->running = false; if (stream->emu_carefd) @@ -656,7 +678,43 @@ static void check_all_finished(libxl__egc *egc, libxl__save_helper_inuse(&stream->shs)) return; - stream->completion_callback(egc, stream, stream->rc); + if (stream->completion_callback) + /* back channel stream doesn't have completion_callback() */ + stream->completion_callback(egc, stream, stream->rc); +} + +/*----- checkpoint state -----*/ +void libxl__stream_write_checkpoint_state(libxl__egc *egc, + libxl__stream_write_state *stream, + libxl_sr_checkpoint_state *srcs) +{ + struct libxl__sr_rec_hdr rec; + + assert(stream->running); + assert(!stream->in_checkpoint); + assert(!stream->in_checkpoint_state); + stream->in_checkpoint_state = true; + + FILLZERO(rec); + rec.type = REC_TYPE_CHECKPOINT_STATE; + rec.length = sizeof(*srcs); + + setup_write(egc, stream, "checkpoint state", &rec, + srcs, write_checkpoint_state_done); +} + +static void write_checkpoint_state_done(libxl__egc *egc, + libxl__stream_write_state *stream) +{ + checkpoint_state_done(egc, stream, 0); +} + +static void checkpoint_state_done(libxl__egc *egc, + libxl__stream_write_state *stream, int rc) +{ + assert(stream->in_checkpoint_state); + stream->in_checkpoint_state = false; + stream->checkpoint_callback(egc, stream, rc); } /*