From patchwork Mon Feb 22 02:52:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 8370811 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 7E975C0554 for ; Mon, 22 Feb 2016 02:54:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8FDCD2039E for ; Mon, 22 Feb 2016 02:54:42 +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 8BC5F203AB for ; Mon, 22 Feb 2016 02:54:40 +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-00017h-Im; Mon, 22 Feb 2016 02:52:12 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXgba-00015S-Qx for xen-devel@lists.xen.org; Mon, 22 Feb 2016 02:52:11 +0000 Received: from [193.109.254.147] by server-3.bemta-14.messagelabs.com id 50/D3-28972-AD77AC65; Mon, 22 Feb 2016 02:52:10 +0000 X-Env-Sender: wency@cn.fujitsu.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1456109516!25574131!6 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 63090 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-5.tower-27.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="3766039" 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 513F542AC848; Mon, 22 Feb 2016 10:50:06 +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:57 +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:16 +0800 Message-ID: <1456109555-28299-13-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: 513F542AC848.A71BA 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 12/31] tools/libxl: add back channel support to 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 This is used by primay to read records sent by secondary. Signed-off-by: Yang Hongyang Signed-off-by: Wen Congyang --- tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_read.c | 27 +++++++++++++++++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 525bf85..fc746fb 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1030,6 +1030,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.dcs = dcs; dcs->srs.fd = restore_fd; dcs->srs.legacy = (dcs->restore_params.stream_version == 1); + dcs->srs.back_channel = false; dcs->srs.completion_callback = domcreate_stream_done; if (restore_fd >= 0) { diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index cdf6751..32957ca 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3420,6 +3420,7 @@ struct libxl__stream_read_state { libxl__domain_create_state *dcs; int fd; bool legacy; + bool back_channel; void (*completion_callback)(libxl__egc *egc, libxl__stream_read_state *srs, int rc); diff --git a/tools/libxl/libxl_stream_read.c b/tools/libxl/libxl_stream_read.c index f4781eb..02a2c46 100644 --- a/tools/libxl/libxl_stream_read.c +++ b/tools/libxl/libxl_stream_read.c @@ -118,6 +118,15 @@ * record, and therefore the buffered state is inconsistent. In * libxl__xc_domain_restore_done(), we just complete the stream and * stream->completion_callback() will be called to resume the guest + * + * For back channel stream: + * - libxl__stream_read_start() + * - Set up the stream to running state + * + * - libxl__stream_read_continue() + * - Set up reading the next record from a started stream. + * Add some codes to process_record() to handle the record. + * Then call stream->checkpoint_callback() to return. */ /* Success/error/cleanup handling. */ @@ -221,6 +230,17 @@ void libxl__stream_read_start(libxl__egc *egc, stream->running = true; stream->phase = SRS_PHASE_NORMAL; + dc->ao = stream->ao; + dc->copywhat = "restore v2 stream"; + dc->writefd = -1; + + if (stream->back_channel) { + assert(!stream->legacy); + + dc->readfd = stream->fd; + return; + } + if (stream->legacy) { /* Convert the legacy stream. */ libxl__conversion_helper_state *chs = &stream->chs; @@ -243,10 +263,7 @@ void libxl__stream_read_start(libxl__egc *egc, } /* stream->fd is now a v2 stream. */ - dc->ao = stream->ao; - dc->copywhat = "restore v2 stream"; dc->readfd = stream->fd; - dc->writefd = -1; /* Start reading the stream header. */ rc = setup_read(stream, "stream header", @@ -762,7 +779,9 @@ static void stream_done(libxl__egc *egc, LIBXL_STAILQ_FOREACH_SAFE(rec, &stream->record_queue, entry, trec) free_record(rec); - check_all_finished(egc, stream, rc); + if (!stream->back_channel) + /* back channel stream doesn't have restore helper */ + check_all_finished(egc, stream, rc); } void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,