From patchwork Wed Dec 30 02:37:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 7931481 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 A5D20BEEE5 for ; Wed, 30 Dec 2015 02:40:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3424201EF for ; Wed, 30 Dec 2015 02:40:15 +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 8579A201F4 for ; Wed, 30 Dec 2015 02:40:14 +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 1aE6eu-0002h2-CA; Wed, 30 Dec 2015 02:38:40 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aE6es-0002dt-Fr for xen-devel@lists.xen.org; Wed, 30 Dec 2015 02:38:38 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 0F/D5-21571-EA343865; Wed, 30 Dec 2015 02:38:38 +0000 X-Env-Sender: wency@cn.fujitsu.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1451443105!7658664!4 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 52028 invoked from network); 30 Dec 2015 02:38:35 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-6.tower-21.messagelabs.com with SMTP; 30 Dec 2015 02:38:35 -0000 X-IronPort-AV: E=Sophos;i="5.20,346,1444665600"; d="scan'208";a="2080167" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Dec 2015 10:38:22 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 38FB541890E1; Wed, 30 Dec 2015 10:38:03 +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; Wed, 30 Dec 2015 10:38:03 +0800 From: Wen Congyang To: xen devel , Andrew Cooper , Ian Campbell , Ian Jackson , Wei Liu Date: Wed, 30 Dec 2015 10:37:36 +0800 Message-ID: <1451443075-27428-7-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1451443075-27428-1-git-send-email-wency@cn.fujitsu.com> References: <1451443075-27428-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.52] X-yoursite-MailScanner-ID: 38FB541890E1.A5A34 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 v9 06/25] 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 b473748..3cf297f 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3052,6 +3052,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. */ @@ -3075,6 +3076,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 538a1c6..6541399 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, @@ -583,6 +589,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); } @@ -590,6 +611,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) @@ -650,7 +672,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); } /*