From patchwork Mon Feb 22 02:52:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 8370701 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 1DA74C0554 for ; Mon, 22 Feb 2016 02:54:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2034F203C1 for ; Mon, 22 Feb 2016 02:54:32 +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 0BAE7203AC for ; Mon, 22 Feb 2016 02:54:31 +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 1aXgbc-00017E-39; Mon, 22 Feb 2016 02:52:12 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXgba-000151-7L for xen-devel@lists.xen.org; Mon, 22 Feb 2016 02:52:10 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 10/AE-04050-9D77AC65; Mon, 22 Feb 2016 02:52:09 +0000 X-Env-Sender: wency@cn.fujitsu.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1456109521!23431257!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 6248 invoked from network); 22 Feb 2016 02:52:08 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-13.tower-31.messagelabs.com with SMTP; 22 Feb 2016 02:52:08 -0000 X-IronPort-AV: E=Sophos;i="5.20,346,1444665600"; d="scan'208";a="3766040" 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 5596242AC84B; Mon, 22 Feb 2016 10:50:07 +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:58 +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:17 +0800 Message-ID: <1456109555-28299-14-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: 5596242AC84B.A7FD0 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 13/31] tools/libxl: handle checkpoint_state records in a libxl migration v2 read 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 Read a checkpoint_state and call stream->checkpoint_callback to handle it. Signed-off-by: Yang Hongyang Signed-off-by: Wen Congyang --- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_stream_read.c | 57 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 32957ca..33b658d 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3432,6 +3432,7 @@ struct libxl__stream_read_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; libxl__conversion_helper_state chs; @@ -3459,6 +3460,8 @@ _hidden void libxl__stream_read_start(libxl__egc *egc, libxl__stream_read_state *stream); _hidden void libxl__stream_read_start_checkpoint(libxl__egc *egc, libxl__stream_read_state *stream); +_hidden void libxl__stream_read_checkpoint_state(libxl__egc *egc, + libxl__stream_read_state *stream); _hidden void libxl__stream_read_abort(libxl__egc *egc, libxl__stream_read_state *stream, int rc); static inline bool diff --git a/tools/libxl/libxl_stream_read.c b/tools/libxl/libxl_stream_read.c index 02a2c46..5d980d9 100644 --- a/tools/libxl/libxl_stream_read.c +++ b/tools/libxl/libxl_stream_read.c @@ -166,6 +166,10 @@ static void write_emulator_done(libxl__egc *egc, libxl__datacopier_state *dc, int rc, int onwrite, int errnoval); +/* Handlers for checkpoint state mini-loop */ +static void checkpoint_state_done(libxl__egc *egc, + libxl__stream_read_state *stream, int rc); + /*----- Helpers -----*/ /* Helper to set up reading some data from the stream. */ @@ -549,6 +553,7 @@ static bool process_record(libxl__egc *egc, STATE_AO_GC(stream->ao); libxl__domain_create_state *dcs = stream->dcs; libxl__sr_record_buf *rec; + libxl_sr_checkpoint_state *srcs; bool further_action_needed = false; int rc = 0; @@ -619,6 +624,17 @@ static bool process_record(libxl__egc *egc, checkpoint_done(egc, stream, 0); break; + case REC_TYPE_CHECKPOINT_STATE: + if (!stream->in_checkpoint_state) { + LOG(ERROR, "Unexpected CHECKPOINT_STATE record in stream"); + rc = ERROR_FAIL; + goto err; + } + + srcs = rec->body; + checkpoint_state_done(egc, stream, srcs->id); + break; + default: LOG(ERROR, "Unrecognised record 0x%08x", rec->hdr.type); rc = ERROR_FAIL; @@ -730,6 +746,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_restore_done() + * 2. back_channel stream + * libxl__stream_read_abort() + */ + checkpoint_state_done(egc, stream, rc); + return; + } + stream_done(egc, stream, rc); } @@ -760,6 +791,7 @@ static void stream_done(libxl__egc *egc, assert(stream->running); assert(!stream->in_checkpoint); + assert(!stream->in_checkpoint_state); stream->running = false; if (stream->incoming_record) @@ -881,7 +913,30 @@ static void check_all_finished(libxl__egc *egc, libxl__conversion_helper_inuse(&stream->chs)) 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 handlers -----*/ + +void libxl__stream_read_checkpoint_state(libxl__egc *egc, + libxl__stream_read_state *stream) +{ + assert(stream->running); + assert(!stream->in_checkpoint); + assert(!stream->in_checkpoint_state); + stream->in_checkpoint_state = true; + + setup_read_record(egc, stream); +} + +static void checkpoint_state_done(libxl__egc *egc, + libxl__stream_read_state *stream, int rc) +{ + assert(stream->in_checkpoint_state); + stream->in_checkpoint_state = false; + stream->checkpoint_callback(egc, stream, rc); } /*