[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v9 09/15] tools/libxc: x86 PV restore code



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.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.