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

Re: [Xen-devel] [PATCH v2 16/27] tools/libxl: Infrastructure for reading a libxl migration v2 stream



Andrew Cooper writes ("Re: [PATCH v2 16/27] tools/libxl: Infrastructure for 
reading a libxl migration v2 stream"):
> On 10/07/15 11:23, Ian Campbell wrote:
> >> +void libxl__stream_read_start(libxl__egc *egc,
> >> +                              libxl__stream_read_state *stream)
> >> +{
> >> +    libxl__datacopier_state *dc = &stream->dc;
> >> +    int ret = 0;
> >> +
> >> +    /* State initialisation. */
> >> +    assert(!stream->running);
> >
> > Since running is declared private and there is no _init function (I
> > think _start is effectively filling that role) I'm not sure that the
> > caller can necessarily be expected to have initialised anything other
> > than the ao, fd and callback fields.
> 
> It was a sanity check that _start() doesn't get called twice (guess what
> I managed to do while developing).  It can probably be dropped.

I don't mind this at all but I think if you do this you should:
  * provide an _init method
  * document that _init must be called before start

> > You might choose to handle this as a request for a doc comment ("must
> > call LIBXL_FILLZERO on it to init"), or to add a separate init function
> > containing the memset or to do away with this check. I've not gotten to
> > the caller yet so I don't know which you will prefer.
> 
> It is all zeroed because of the way dcs is constructed.  I suppose I can
> also drop the zeroing of the dc.

Providing an init method would mean that if this thing needs to grow
calls to sub-states' init methods, there is somewhere to put them.

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®.