From patchwork Mon Feb 22 02:52:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 8370911 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A35DE9F2F0 for ; Mon, 22 Feb 2016 02:54:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE8D42039E for ; Mon, 22 Feb 2016 02:54:51 +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 B5CE9203C0 for ; Mon, 22 Feb 2016 02:54:50 +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 1aXgbZ-000155-Qi; Mon, 22 Feb 2016 02:52:09 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXgbW-00011v-VI 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 61/B0-28791-6D77AC65; Mon, 22 Feb 2016 02:52:06 +0000 X-Env-Sender: wency@cn.fujitsu.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1456109514!24622642!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 5446 invoked from network); 22 Feb 2016 02:52:05 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-4.tower-27.messagelabs.com with SMTP; 22 Feb 2016 02:52:05 -0000 X-IronPort-AV: E=Sophos;i="5.20,346,1444665600"; d="scan'208";a="3766027" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 Feb 2016 10:51:56 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 988CE42AC855; Mon, 22 Feb 2016 10:50: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; Mon, 22 Feb 2016 10:51:54 +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:14 +0800 Message-ID: <1456109555-28299-11-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: 988CE42AC855.A7FCC 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 10/31] tools/libxl: add back channel support to write 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 Add back channel support to write stream. If the write stream is a back channel stream, this means the write stream is used by Secondary to send some records back. Signed-off-by: Yang Hongyang Signed-off-by: Wen Congyang --- tools/libxl/libxl_dom_save.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_write.c | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_dom_save.c b/tools/libxl/libxl_dom_save.c index 72b61c7..18946c5 100644 --- a/tools/libxl/libxl_dom_save.c +++ b/tools/libxl/libxl_dom_save.c @@ -404,6 +404,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) dss->sws.ao = dss->ao; dss->sws.dss = dss; dss->sws.fd = dss->fd; + dss->sws.back_channel = false; dss->sws.completion_callback = stream_done; libxl__stream_write_start(egc, &dss->sws); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 3d3e8e8..e02e554 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3044,6 +3044,7 @@ struct libxl__stream_write_state { libxl__ao *ao; libxl__domain_save_state *dss; int fd; + bool back_channel; void (*completion_callback)(libxl__egc *egc, libxl__stream_write_state *sws, int rc); diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c index f6ea55d..5379126 100644 --- a/tools/libxl/libxl_stream_write.c +++ b/tools/libxl/libxl_stream_write.c @@ -49,6 +49,13 @@ * - if (hvm) * - Emulator context record * - Checkpoint end record + * + * For back channel stream: + * - libxl__stream_write_start() + * - Set up the stream to running state + * + * - Add a new API to write the record. When the record is written + * out, call stream->checkpoint_callback() to return. */ /* Success/error/cleanup handling. */ @@ -225,6 +232,15 @@ void libxl__stream_write_start(libxl__egc *egc, stream->running = true; + dc->ao = ao; + dc->readfd = -1; + dc->copywhat = "save v2 stream"; + dc->writefd = stream->fd; + dc->maxsz = -1; + + if (stream->back_channel) + return; + if (dss->type == LIBXL_DOMAIN_TYPE_HVM) { stream->device_model_version = libxl__device_model_version_running(gc, dss->domid); @@ -249,12 +265,7 @@ void libxl__stream_write_start(libxl__egc *egc, stream->emu_sub_hdr.index = 0; } - dc->ao = ao; - dc->readfd = -1; dc->writewhat = "stream header"; - dc->copywhat = "save v2 stream"; - dc->writefd = stream->fd; - dc->maxsz = -1; dc->callback = stream_header_done; rc = libxl__datacopier_start(dc); @@ -279,6 +290,7 @@ void libxl__stream_write_start_checkpoint(libxl__egc *egc, { assert(stream->running); assert(!stream->in_checkpoint); + assert(!stream->back_channel); stream->in_checkpoint = true; write_emulator_xenstore_record(egc, stream); @@ -590,7 +602,9 @@ static void stream_done(libxl__egc *egc, libxl__carefd_close(stream->emu_carefd); free(stream->emu_body); - check_all_finished(egc, stream, rc); + if (!stream->back_channel) + /* back channel stream doesn't have save helper */ + check_all_finished(egc, stream, rc); } static void checkpoint_done(libxl__egc *egc,