[Libguestfs] [PATCH nbdkit 4/8] offset: Implement mapping of extents.

Richard W.M. Jones rjones at redhat.com
Mon Mar 25 17:27:07 UTC 2019


On Sat, Mar 23, 2019 at 11:58:26AM -0500, Eric Blake wrote:
> On 3/20/19 5:11 PM, Richard W.M. Jones wrote:
> > Allows you to safely use nbdkit-offset-filter on top of a plugin
> > supporting extents.
> > ---
> >  filters/offset/offset.c | 35 +++++++++++++++++++++++++++++++++++
> >  1 file changed, 35 insertions(+)
> 
> If we don't change our minds on the interface in patch 1, then this
> looks correct.
> 
> > +/* Extents. */
> > +static int
> > +offset_extents (struct nbdkit_next_ops *next_ops, void *nxdata,
> > +                void *handle, uint32_t count, uint64_t offs, uint32_t flags,
> > +                struct nbdkit_extents *extents, int *err)
> > +{
> > +  size_t i;
> > +  struct nbdkit_extents *extents2;
> > +  struct nbdkit_extent e;
> > +
> > +  extents2 = nbdkit_extents_new (offs + offset);
> > +  if (extents2 == NULL) {
> > +    *err = errno;
> > +    return -1;
> > +  }
> 
> Ouch - nbdkit_extents_new() returns NULL for 'start >= INT64_MAX'
> without setting errno. Of course, that failure path should be
> unreachable here, but if you are going to assign *err based on errno,
> then we have to make sure patch 1 guarantees sane errno settings on all
> failure paths.

I'll fix that in the next iteration so it returns errno = ERANGE in
this case.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the Libguestfs mailing list