From patchwork Wed Mar 23 08:06:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changlong Xie X-Patchwork-Id: 8647651 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 B76FB9F36E for ; Wed, 23 Mar 2016 08:06:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B25642038D for ; Wed, 23 Mar 2016 08:06:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27D47203AB for ; Wed, 23 Mar 2016 08:06:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aidmS-0001zk-Mi; Wed, 23 Mar 2016 08:04:40 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aidmR-0001wZ-Tw for xen-devel@lists.xen.org; Wed, 23 Mar 2016 08:04:40 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id 1F/E0-03645-71E42F65; Wed, 23 Mar 2016 08:04:39 +0000 X-Env-Sender: xiecl.fnst@cn.fujitsu.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1458720267!33274420!6 X-Originating-IP: [59.151.112.132] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5290 invoked from network); 23 Mar 2016 08:04:38 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-7.tower-27.messagelabs.com with SMTP; 23 Mar 2016 08:04:38 -0000 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="4882438" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 23 Mar 2016 16:04:33 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id BBFBF408D264; Wed, 23 Mar 2016 16:04:32 +0800 (CST) Received: from changlox.g08.fujitsu.local (10.167.225.55) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Wed, 23 Mar 2016 16:04:32 +0800 From: Changlong Xie To: xen devel , Konrad Rzeszutek Wilk , Andrew Cooper , Ian Campbell , Ian Jackson , Wei Liu Date: Wed, 23 Mar 2016 16:06:27 +0800 Message-ID: <1458720400-4699-14-git-send-email-xiecl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1458720400-4699-1-git-send-email-xiecl.fnst@cn.fujitsu.com> References: <1458720400-4699-1-git-send-email-xiecl.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.55] X-yoursite-MailScanner-ID: BBFBF408D264.A33AB X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xiecl.fnst@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 , Li Zhijian , Gui Jianfeng , Jiang Yunhong , Dong Eddie , Anthony Perard , Shriram Rajagopalan , Yang Hongyang Subject: [Xen-devel] [PATCH v12 13/26] libxl_internal: move stream read manipulations to right place X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP No functional changes and this cleanup will make the later patch called "primary vm suspend/resume/checkpoint code" not too complicated. Signed-off-by: Wen Congyang Signed-off-by: Changlong Xie Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 132 +++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index fc5b452..16c627d 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3017,6 +3017,72 @@ static inline bool libxl__conversion_helper_inuse (const libxl__conversion_helper_state *chs) { return libxl__ev_child_inuse(&chs->child); } +/* State for reading a libxl migration v2 stream */ +typedef struct libxl__stream_read_state libxl__stream_read_state; + +typedef struct libxl__sr_record_buf { + /* private to stream read helper */ + LIBXL_STAILQ_ENTRY(struct libxl__sr_record_buf) entry; + libxl__sr_rec_hdr hdr; + void *body; /* iff hdr.length != 0 */ +} libxl__sr_record_buf; + +struct libxl__stream_read_state { + /* filled by the user */ + libxl__ao *ao; + 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); + void (*checkpoint_callback)(libxl__egc *egc, + libxl__stream_read_state *srs, + int rc); + /* Private */ + int rc; + 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; + + /* Main stream-reading data. */ + libxl__datacopier_state dc; /* Only used when reading a record */ + libxl__sr_hdr hdr; + LIBXL_STAILQ_HEAD(, libxl__sr_record_buf) record_queue; /* NOGC */ + enum { + SRS_PHASE_NORMAL, + SRS_PHASE_BUFFERING, + SRS_PHASE_UNBUFFERING, + } phase; + bool recursion_guard; + + /* Only used while actively reading a record from the stream. */ + libxl__sr_record_buf *incoming_record; /* NOGC */ + + /* Both only used when processing an EMULATOR record. */ + libxl__datacopier_state emu_dc; + libxl__carefd *emu_carefd; +}; + +_hidden void libxl__stream_read_init(libxl__stream_read_state *stream); +_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 +libxl__stream_read_inuse(const libxl__stream_read_state *stream) +{ + return stream->running; +} + /*----- Domain suspend (save) state structure -----*/ /* @@ -3398,72 +3464,6 @@ _hidden int libxl__destroy_qdisk_backend(libxl__gc *gc, uint32_t domid); /*----- Domain creation -----*/ -/* State for manipulating a libxl migration v2 stream */ -typedef struct libxl__stream_read_state libxl__stream_read_state; - -typedef struct libxl__sr_record_buf { - /* private to stream read helper */ - LIBXL_STAILQ_ENTRY(struct libxl__sr_record_buf) entry; - libxl__sr_rec_hdr hdr; - void *body; /* iff hdr.length != 0 */ -} libxl__sr_record_buf; - -struct libxl__stream_read_state { - /* filled by the user */ - libxl__ao *ao; - 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); - void (*checkpoint_callback)(libxl__egc *egc, - libxl__stream_read_state *srs, - int rc); - /* Private */ - int rc; - 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; - - /* Main stream-reading data. */ - libxl__datacopier_state dc; /* Only used when reading a record */ - libxl__sr_hdr hdr; - LIBXL_STAILQ_HEAD(, libxl__sr_record_buf) record_queue; /* NOGC */ - enum { - SRS_PHASE_NORMAL, - SRS_PHASE_BUFFERING, - SRS_PHASE_UNBUFFERING, - } phase; - bool recursion_guard; - - /* Only used while actively reading a record from the stream. */ - libxl__sr_record_buf *incoming_record; /* NOGC */ - - /* Both only used when processing an EMULATOR record. */ - libxl__datacopier_state emu_dc; - libxl__carefd *emu_carefd; -}; - -_hidden void libxl__stream_read_init(libxl__stream_read_state *stream); -_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 -libxl__stream_read_inuse(const libxl__stream_read_state *stream) -{ - return stream->running; -} - struct libxl__domain_create_state { /* filled in by user */