From: Ian Campbell Subject: Re: [PATCH 1/2] libxc: introduce XC_SAVE_ID_TOOLSTACK Date: Fri, 20 Jan 2012 11:33:22 +0000 Message-ID: <1327059202.30054.3.camel@zakaz.uk.xensource.com> References: <1327058312-19168-1-git-send-email-stefano.stabellini@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1327058312-19168-1-git-send-email-stefano.stabellini@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Fri, 2012-01-20 at 11:18 +0000, Stefano Stabellini wrote: > diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c > index a6bb894..3d11c39 100644 > --- a/tools/libxc/xc_domain_save.c > +++ b/tools/libxc/xc_domain_save.c > @@ -1676,6 +1676,22 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter > } > } > > + if ( callbacks != NULL && callbacks->toolstack_save != NULL ) > + { > + int id = XC_SAVE_ID_TOOLSTACK; > + uint8_t *buf; > + uint32_t len; > + > + if ( callbacks->toolstack_save(dom, &buf, &len, callbacks->data) < 0 ) > + { > + PERROR("Error calling toolstack_save"); > + goto out; > + } > + wrexact(io_fd, &id, sizeof(id)); > + wrexact(io_fd, &len, sizeof(len)); > + wrexact(io_fd, buf, len); Where is buf free'd? You say below "callee allocates and frees the buffer" but there is no way that can be the case since the caller uses the buffer after the callback. I think it has to be callee-alloc, caller-free (perhaps callee-free on error). > + } > + > if ( !callbacks->checkpoint ) > { > /* > diff --git a/tools/libxc/xenguest.h b/tools/libxc/xenguest.h > index 4475ee9..8120715 100644 > --- a/tools/libxc/xenguest.h > +++ b/tools/libxc/xenguest.h > @@ -44,6 +44,13 @@ struct save_callbacks { > /* Enable qemu-dm logging dirty pages to xen */ > int (*switch_qemu_logdirty)(int domid, unsigned enable, void *data); /* HVM only */ > > + /* Save toolstack specific data > + * @param buf the buffer with the data to be saved > + * @param len the length of the buffer > + * The callee allocates and frees the buffer. > + */ > + int (*toolstack_save)(uint32_t domid, uint8_t **buf, uint32_t *len, void *data); > + > /* to be provided as the last argument to each callback function */ > void* data; > }; Ian.