From patchwork Mon Mar 27 09:06:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Otto X-Patchwork-Id: 9645689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6032C602C8 for ; Mon, 27 Mar 2017 09:09:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4771B27A98 for ; Mon, 27 Mar 2017 09:09:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C23828364; Mon, 27 Mar 2017 09:09:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id A441527A98 for ; Mon, 27 Mar 2017 09:09:55 +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 1csQcj-0004hH-KH; Mon, 27 Mar 2017 09:07:37 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1csQci-0004fO-BB for xen-devel@lists.xenproject.org; Mon, 27 Mar 2017 09:07:36 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 56/AB-20914-756D8D85; Mon, 27 Mar 2017 09:07:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRWlGSWpSXmKPExsXSmNjwSTfs2o0 Ig8m/jS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owlPQ4FjZYVP148Y25gvK3TxcjFISSwhEli 1s1W9i5GTg4WAR+J9Xs7GUESLAL/mSQ2/7rLBJJgE1CX2L5oI1iRiICSxL1Vk5lAipgFDjJKn Dl/mBkkISzgKbH4egfUJFWJL6u2soDYvALOEhPvngazJQTkJG6e6wSr5xRwkTh28RAbiC0EVH PtcC8jRE2xROfVHUD1HEB2iETvTSuIsI5EX9MBJgg7XmL//tlMECUmEg+meEKERSW6Dz8Du19 CYD6jxIb2VUwTGIUXMDKsYlQvTi0qSy3SNddLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZL zs/dxAgMTgYg2MHY+N3pEKMkB5OSKO+H0zcihPiS8lMqMxKLM+KLSnNSiw8xynBwKEnwXr4Cl BMsSk1PrUjLzAHGCUxagoNHSYRX4ypQmre4IDG3ODMdInWKUZfjVsOeN0xCLHn5ealS4ry5ID MEQIoySvPgRsBi9hKjrJQwLyPQUUI8BalFuZklqPKvGMU5GJWEeZlBVvFk5pXAbXoFdAQT0BG H54MdUZKIkJJqYAy8c3ah0aXZ9uJMvf0KPDwdd3+3RQRnxTX0Mxv5PeDdYrLJqGCi1h+WOV3n Jmdr/uVY9HDvX33FL4XvBFWLrp0/pKu0Q/SR4S6n92V2pY8zGG++Dp3f23JuxqXFF5b8SisKv bilvcR36u8VbJFbjB9aXrNk0RCr/rhYOEjFIH8px9uwGyKzMpRYijMSDbWYi4oTARk7ID3UAg AA X-Env-Sender: jtotto@uwaterloo.ca X-Msg-Ref: server-12.tower-31.messagelabs.com!1490605653!75428934!1 X-Originating-IP: [129.97.128.242] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58705 invoked from network); 27 Mar 2017 09:07:34 -0000 Received: from mailchk-m06.uwaterloo.ca (HELO mailchk-m06.uwaterloo.ca) (129.97.128.242) by server-12.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Mar 2017 09:07:34 -0000 Received: from eagle.uwaterloo.ca (cs-auth-dc-129-97-60-142.dynamic.uwaterloo.ca [129.97.60.142]) (authenticated bits=0) by mailchk-m06.uwaterloo.ca (8.14.4/8.14.4) with ESMTP id v2R97DTI023326 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Mon, 27 Mar 2017 05:07:26 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 mailchk-m06.uwaterloo.ca v2R97DTI023326 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uwaterloo.ca; s=default; t=1490605649; bh=0dSi89n2xDkzIYmwwtw4bYC9xpbcIU3GBy+9HzPhVhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M72kK8ZAvJO7rc89UuZcNZv5DPLH3z5xPcFa/GXc0p5DVDmxEWC5xvlEtWBqzlps9 flyr9zqLBJsJyPbMCJnigHxO9mBLny/QMg3EBAgs7Kbn4XNabyeICtI+BX1ekyB3bh 0RY/4I8cGd2RXjKqJIpXK9byboUIxFimKzNuOaBM= From: Joshua Otto To: xen-devel@lists.xenproject.org Date: Mon, 27 Mar 2017 05:06:14 -0400 Message-Id: <1490605592-12189-3-git-send-email-jtotto@uwaterloo.ca> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490605592-12189-1-git-send-email-jtotto@uwaterloo.ca> References: <1490605592-12189-1-git-send-email-jtotto@uwaterloo.ca> X-UUID: abb25e82-973b-4839-ac4c-082998a6802c X-Miltered: at mailchk-m06 with ID 58D8D641.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Virus-Scanned: clamav-milter 0.99.2 at mailchk-m06 X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (mailchk-m06.uwaterloo.ca [129.97.128.141]); Mon, 27 Mar 2017 05:07:29 -0400 (EDT) Cc: wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, czylin@uwaterloo.ca, Joshua Otto , imhy.yang@gmail.com, hjarmstr@uwaterloo.ca Subject: [Xen-devel] [PATCH RFC 02/20] libxc/xc_sr: parameterise write_record() on fd 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Right now, write_split_record() - which is delegated to by write_record() - implicitly writes to ctx->fd. This means it can't be used with the restore context's send_back_fd, which is unhandy. Add an 'fd' parameter to both write_record() and write_split_record(), and mechanically update all existing callsites to pass ctx->fd for it. No functional change. Signed-off-by: Joshua Otto Reviewed-by: Andrew Cooper Acked-by: Wei Liu --- tools/libxc/xc_sr_common.c | 6 +++--- tools/libxc/xc_sr_common.h | 8 ++++---- tools/libxc/xc_sr_common_x86.c | 2 +- tools/libxc/xc_sr_save.c | 6 +++--- tools/libxc/xc_sr_save_x86_hvm.c | 5 +++-- tools/libxc/xc_sr_save_x86_pv.c | 17 +++++++++-------- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/tools/libxc/xc_sr_common.c b/tools/libxc/xc_sr_common.c index 48fa676..c1babf6 100644 --- a/tools/libxc/xc_sr_common.c +++ b/tools/libxc/xc_sr_common.c @@ -52,8 +52,8 @@ const char *rec_type_to_str(uint32_t type) return "Reserved"; } -int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec, - void *buf, size_t sz) +int write_split_record(struct xc_sr_context *ctx, int fd, + struct xc_sr_record *rec, void *buf, size_t sz) { static const char zeroes[(1u << REC_ALIGN_ORDER) - 1] = { 0 }; @@ -81,7 +81,7 @@ int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec, if ( sz ) assert(buf); - if ( writev_exact(ctx->fd, parts, ARRAY_SIZE(parts)) ) + if ( writev_exact(fd, parts, ARRAY_SIZE(parts)) ) goto err; return 0; diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index a83f22a..2f33ccc 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -361,8 +361,8 @@ struct xc_sr_record * * Returns 0 on success and non0 on failure. */ -int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec, - void *buf, size_t sz); +int write_split_record(struct xc_sr_context *ctx, int fd, + struct xc_sr_record *rec, void *buf, size_t sz); /* * Writes a record to the stream, applying correct padding where appropriate. @@ -371,10 +371,10 @@ int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec, * * Returns 0 on success and non0 on failure. */ -static inline int write_record(struct xc_sr_context *ctx, +static inline int write_record(struct xc_sr_context *ctx, int fd, struct xc_sr_record *rec) { - return write_split_record(ctx, rec, NULL, 0); + return write_split_record(ctx, fd, rec, NULL, 0); } /* diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index 98f1cef..7b3dd50 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -18,7 +18,7 @@ int write_tsc_info(struct xc_sr_context *ctx) return -1; } - return write_record(ctx, &rec); + return write_record(ctx, ctx->fd, &rec); } int handle_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec) diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index fc63a55..61fc4a4 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -53,7 +53,7 @@ static int write_end_record(struct xc_sr_context *ctx) { struct xc_sr_record end = { REC_TYPE_END, 0, NULL }; - return write_record(ctx, &end); + return write_record(ctx, ctx->fd, &end); } /* @@ -63,7 +63,7 @@ static int write_checkpoint_record(struct xc_sr_context *ctx) { struct xc_sr_record checkpoint = { REC_TYPE_CHECKPOINT, 0, NULL }; - return write_record(ctx, &checkpoint); + return write_record(ctx, ctx->fd, &checkpoint); } /* @@ -646,7 +646,7 @@ static int verify_frames(struct xc_sr_context *ctx) DPRINTF("Enabling verify mode"); - rc = write_record(ctx, &rec); + rc = write_record(ctx, ctx->fd, &rec); if ( rc ) goto out; diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c index e485928..ea4b780 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -42,7 +42,7 @@ static int write_hvm_context(struct xc_sr_context *ctx) } hvm_rec.length = hvm_buf_size; - rc = write_record(ctx, &hvm_rec); + rc = write_record(ctx, ctx->fd, &hvm_rec); if ( rc < 0 ) { PERROR("error write HVM_CONTEXT record"); @@ -112,7 +112,8 @@ static int write_hvm_params(struct xc_sr_context *ctx) } } - rc = write_split_record(ctx, &rec, entries, hdr.count * sizeof(*entries)); + rc = write_split_record(ctx, ctx->fd, &rec, entries, + hdr.count * sizeof(*entries)); if ( rc ) PERROR("Failed to write HVM_PARAMS record"); diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c index f218d17..2b2c050 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -571,9 +571,9 @@ static int write_one_vcpu_basic(struct xc_sr_context *ctx, uint32_t id) } if ( ctx->x86_pv.width == 8 ) - rc = write_split_record(ctx, &rec, &vcpu, sizeof(vcpu.x64)); + rc = write_split_record(ctx, ctx->fd, &rec, &vcpu, sizeof(vcpu.x64)); else - rc = write_split_record(ctx, &rec, &vcpu, sizeof(vcpu.x32)); + rc = write_split_record(ctx, ctx->fd, &rec, &vcpu, sizeof(vcpu.x32)); err: return rc; @@ -609,7 +609,7 @@ static int write_one_vcpu_extended(struct xc_sr_context *ctx, uint32_t id) return -1; } - return write_split_record(ctx, &rec, &domctl.u.ext_vcpucontext, + return write_split_record(ctx, ctx->fd, &rec, &domctl.u.ext_vcpucontext, domctl.u.ext_vcpucontext.size); } @@ -664,7 +664,8 @@ static int write_one_vcpu_xsave(struct xc_sr_context *ctx, uint32_t id) goto err; } - rc = write_split_record(ctx, &rec, buffer, domctl.u.vcpuextstate.size); + rc = write_split_record(ctx, ctx->fd, &rec, buffer, + domctl.u.vcpuextstate.size); if ( rc ) goto err; @@ -730,7 +731,7 @@ static int write_one_vcpu_msrs(struct xc_sr_context *ctx, uint32_t id) goto err; } - rc = write_split_record(ctx, &rec, buffer, + rc = write_split_record(ctx, ctx->fd, &rec, buffer, domctl.u.vcpu_msrs.msr_count * sizeof(xen_domctl_vcpu_msr_t)); if ( rc ) @@ -805,7 +806,7 @@ static int write_x86_pv_info(struct xc_sr_context *ctx) .data = &info }; - return write_record(ctx, &rec); + return write_record(ctx, ctx->fd, &rec); } /* @@ -846,7 +847,7 @@ static int write_x86_pv_p2m_frames(struct xc_sr_context *ctx) else data = (uint64_t *)ctx->x86_pv.p2m_pfns; - rc = write_split_record(ctx, &rec, data, datasz); + rc = write_split_record(ctx, ctx->fd, &rec, data, datasz); if ( data != (uint64_t *)ctx->x86_pv.p2m_pfns ) free(data); @@ -866,7 +867,7 @@ static int write_shared_info(struct xc_sr_context *ctx) .data = ctx->x86_pv.shinfo, }; - return write_record(ctx, &rec); + return write_record(ctx, ctx->fd, &rec); } /*