From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v9 09/15] tools/libxc: x86 PV restore code Date: Wed, 15 Apr 2015 12:22:24 +0100 Message-ID: <1429096944.15516.210.camel@citrix.com> References: <1428686167-8279-1-git-send-email-andrew.cooper3@citrix.com> <1428686167-8279-10-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1428686167-8279-10-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Wei Liu , Ian Jackson , Xen-devel List-Id: xen-devel@lists.xenproject.org On Fri, 2015-04-10 at 18:16 +0100, Andrew Cooper wrote: > Restore the x86 PV specific parts. The X86_PV_INFO, the P2M_FRAMES, > +/* > + * Set a pfn as populated, expanding the tracking structures if needed. To > + * avoid realloc()ing too excessivly, the size increased to the nearest power excessively. > +/* > + * Update details in a guests start_info strucutre. structure. > +/* > + * Processes X86_PV_VCPU_{BASIC,EXTENDED,XSAVE,MSRS} records from the stream. > + * The blobs are all stashed to one side as they need to be defered until the deferred. > + * very end of the stream, rather than being send to Xen at the point they > + * arive in the stream. It performs all pre-hypercall size validation. arrive. > + */ > +static int handle_x86_pv_vcpu_blob(struct xc_sr_context *ctx, > + struct xc_sr_record *rec) > +{ > + xc_interface *xch = ctx->xch; > + struct xc_sr_rec_x86_pv_vcpu_hdr *vhdr = rec->data; > + struct xc_sr_x86_pv_restore_vcpu *vcpu; > + const char *rec_name; > + size_t blobsz; > + void *blob; > + int rc = -1; > + > + switch ( rec->type ) > + { > +#define RECNAME(x, y) case (x): rec_name = (y) ; break > + RECNAME(REC_TYPE_X86_PV_VCPU_BASIC, "X86_PV_VCPU_BASIC"); > + RECNAME(REC_TYPE_X86_PV_VCPU_EXTENDED, "X86_PV_VCPU_EXTENDED"); > + RECNAME(REC_TYPE_X86_PV_VCPU_XSAVE, "X86_PV_VCPU_XSAVE"); > + RECNAME(REC_TYPE_X86_PV_VCPU_MSRS, "X86_PV_VCPU_MSRS"); > +#undef RECNAME I can see the point of STOREREC below but not this one unless you were to use cpp pasting to add the REC_TYPE_ prefix to a single argument. Otherwise the macro invocation doesn't seem to actually be any terser than the expansion. > + default: > + ERROR("Unrecogised vcpu blob record %s (%u)", Unrecognised. > +#define RECSTORE(x, y) case (x): free(y); (y) = blob; (y ## sz) = blobsz; break > + RECSTORE(REC_TYPE_X86_PV_VCPU_BASIC, vcpu->basic); > + RECSTORE(REC_TYPE_X86_PV_VCPU_EXTENDED, vcpu->extd); > + RECSTORE(REC_TYPE_X86_PV_VCPU_XSAVE, vcpu->xsave); > + RECSTORE(REC_TYPE_X86_PV_VCPU_MSRS, vcpu->msr); Could optionally move some of the prefix of the first argument into the macro too. Ian.