[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC v2 02/23] libxc/xc_sr: parameterise write_record() on fd
From: Joshua Otto <jtotto@xxxxxxxxxxxx> 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 inconvenient. 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 <jtotto@xxxxxxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- 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 3837bc1..8aba0d8 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 fc5c6ea..54ddbfe 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"); @@ -116,7 +116,8 @@ static int write_hvm_params(struct xc_sr_context *ctx) if ( hdr.count == 0 ) return 0; - 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 36b1058..5f9b97d 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; @@ -613,7 +613,7 @@ static int write_one_vcpu_extended(struct xc_sr_context *ctx, uint32_t id) if ( domctl.u.ext_vcpucontext.size == 0 ) return 0; - 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); } @@ -672,7 +672,8 @@ static int write_one_vcpu_xsave(struct xc_sr_context *ctx, uint32_t id) if ( domctl.u.vcpuextstate.size == 0 ) goto out; - 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; @@ -742,7 +743,7 @@ static int write_one_vcpu_msrs(struct xc_sr_context *ctx, uint32_t id) if ( domctl.u.vcpu_msrs.msr_count == 0 ) goto out; - 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 ) @@ -817,7 +818,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); } /* @@ -858,7 +859,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); @@ -878,7 +879,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); } /* -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |