From: Andrew Cooper Date: Thu, 30 Mar 2017 16:32:32 +0000 (+0100) Subject: tools/libxc: Avoid generating inappropriate zero-content records X-Git-Tag: RELEASE-4.8.4~99 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c31070f3505fb12f78d5b67498c6b1e460209c9a;p=people%2Fandrewcoop%2Fxen.git tools/libxc: Avoid generating inappropriate zero-content records The code as written attempted to elide zero-content records, as such records serve no purpose but come with a performance hit. Unfortunately, in the case where the hypervisor reported max size is non-zero, but the actual size is zero, the record is not elided. This previously tripped up the sanity checks in the restore side of migration, but as the underlying reasons for eliding the records in the first place are still valid, fix the elision logic. Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu (cherry picked from commit 72efb1df629421037e2795f5529210aaa95ec72e) --- diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c index ba50a43a47..5401bf96a9 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -112,6 +112,10 @@ static int write_hvm_params(struct xc_sr_context *ctx) } } + /* No params? Skip this record. */ + if ( hdr.count == 0 ) + return 0; + rc = write_split_record(ctx, &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 f218d17bce..36b10583d6 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -609,6 +609,10 @@ static int write_one_vcpu_extended(struct xc_sr_context *ctx, uint32_t id) return -1; } + /* No content? Skip the record. */ + if ( domctl.u.ext_vcpucontext.size == 0 ) + return 0; + return write_split_record(ctx, &rec, &domctl.u.ext_vcpucontext, domctl.u.ext_vcpucontext.size); } @@ -664,6 +668,10 @@ static int write_one_vcpu_xsave(struct xc_sr_context *ctx, uint32_t id) goto err; } + /* No xsave state? Skip this record. */ + if ( domctl.u.vcpuextstate.size == 0 ) + goto out; + rc = write_split_record(ctx, &rec, buffer, domctl.u.vcpuextstate.size); if ( rc ) goto err; @@ -730,6 +738,10 @@ static int write_one_vcpu_msrs(struct xc_sr_context *ctx, uint32_t id) goto err; } + /* No MSRs? Skip this record. */ + if ( domctl.u.vcpu_msrs.msr_count == 0 ) + goto out; + rc = write_split_record(ctx, &rec, buffer, domctl.u.vcpu_msrs.msr_count * sizeof(xen_domctl_vcpu_msr_t));