From patchwork Wed Dec 30 02:37:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 7931581 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 26A6EBEEE5 for ; Wed, 30 Dec 2015 02:40:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E40920211 for ; Wed, 30 Dec 2015 02:40: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 4D85B2013D for ; Wed, 30 Dec 2015 02:40: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 1aE6ex-0002kg-1f; Wed, 30 Dec 2015 02:38:43 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aE6eu-0002gn-9s for xen-devel@lists.xen.org; Wed, 30 Dec 2015 02:38:40 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id 41/C3-24450-FA343865; Wed, 30 Dec 2015 02:38:39 +0000 X-Env-Sender: wency@cn.fujitsu.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1451443108!10039549!2 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 9616 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-8.tower-27.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="2080165" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Dec 2015 10:38:21 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 4D6E841890E0; Wed, 30 Dec 2015 10:38:02 +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:02 +0800 From: Wen Congyang To: xen devel , Andrew Cooper , Ian Campbell , Ian Jackson , Wei Liu Date: Wed, 30 Dec 2015 10:37:35 +0800 Message-ID: <1451443075-27428-6-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: 4D6E841890E0.A583D 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 05/25] 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 86026ac..5fd9db2 100644 --- a/tools/libxl/libxl_dom_save.c +++ b/tools/libxl/libxl_dom_save.c @@ -409,6 +409,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 b6929a9..b473748 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3040,6 +3040,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 852546f..538a1c6 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); @@ -584,7 +596,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,