From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v4 07/14] libxc/save: introduce setup() and cleanup() on save Date: Tue, 12 May 2015 13:11:19 +0100 Message-ID: <5551EDE7.7030904@citrix.com> References: <1431429922-15344-1-git-send-email-yanghy@cn.fujitsu.com> <1431429922-15344-8-git-send-email-yanghy@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1431429922-15344-8-git-send-email-yanghy@cn.fujitsu.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: Yang Hongyang , xen-devel@lists.xen.org Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, wency@cn.fujitsu.com, ian.jackson@eu.citrix.com, yunhong.jiang@intel.com, eddie.dong@intel.com, rshriram@cs.ubc.ca List-Id: xen-devel@lists.xenproject.org On 12/05/15 12:25, Yang Hongyang wrote: > introduce setup() and cleanup() which subsume the > ctx->save.ops.{setup,cleanup}() calls. > The SHADOW_OP_OFF hypercall also included in the cleanup(). > > Signed-off-by: Yang Hongyang > CC: Ian Campbell > CC: Ian Jackson > CC: Wei Liu > CC: Andrew Cooper > --- > tools/libxc/xc_sr_save.c | 35 ++++++++++++++++++++++++++++------- > 1 file changed, 28 insertions(+), 7 deletions(-) > > diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c > index caa727d..8a847fc 100644 > --- a/tools/libxc/xc_sr_save.c > +++ b/tools/libxc/xc_sr_save.c > @@ -637,6 +637,32 @@ static int send_domain_memory_nonlive(struct xc_sr_context *ctx) > return rc; > } > > +static int setup(struct xc_sr_context *ctx) > +{ > + int rc; > + > + rc = ctx->save.ops.setup(ctx); > + if ( rc ) > + goto err; > + > + rc = 0; > + > + err: > + return rc; > + Stray blank line which can be dropped. Otherwise, Reviewed-by: Andrew Cooper > +} > + > +static void cleanup(struct xc_sr_context *ctx) > +{ > + xc_interface *xch = ctx->xch; > + > + xc_shadow_control(xch, ctx->domid, XEN_DOMCTL_SHADOW_OP_OFF, > + NULL, 0, NULL, 0, NULL); > + > + if ( ctx->save.ops.cleanup(ctx) ) > + PERROR("Failed to clean up"); > +} > + > /* > * Save a domain. > */ > @@ -648,7 +674,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) > IPRINTF("Saving domain %d, type %s", > ctx->domid, dhdr_type_to_str(guest_type)); > > - rc = ctx->save.ops.setup(ctx); > + rc = setup(ctx); > if ( rc ) > goto err; > > @@ -701,12 +727,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) > PERROR("Save failed"); > > done: > - xc_shadow_control(xch, ctx->domid, XEN_DOMCTL_SHADOW_OP_OFF, > - NULL, 0, NULL, 0, NULL); > - > - rc = ctx->save.ops.cleanup(ctx); > - if ( rc ) > - PERROR("Failed to clean up"); > + cleanup(ctx); > > if ( saved_rc ) > {