[Libguestfs] [PATCH nbdkit] server: Implement extents/can_extents calls for plugins and filters.

Eric Blake eblake at redhat.com
Wed Mar 13 13:20:57 UTC 2019


On 3/13/19 7:45 AM, Richard W.M. Jones wrote:
> This pair of calls allows plugins to describe which extents in the
> virtual disk are allocated, holes or zeroes.
> ---

> + int nbdkit_extents_foreach_range (
> +            const struct nbdkit_extents_map *extents_map,
> +            uint64_t range_offset, uint64_t range_length,
> +            int (*fn) (uint64_t offset, uint64_t length,
> +                       uint32_t type, void *opaque),
> +             void *opaque);
> +
> +Iterate over the extents in ascending order, calling C<fn> for each.
> +C<fn> should return 0 on success or -1 on failure.  If a call to C<fn>
> +fails then C<nbdkit_extents_foreach*> also fails immediately.
> +
> +The C<nbdkit_extents_foreach_range> variant only iterates over extents
> +overlapping C<[range_offset...range_offset+range_length-1]>.
> +
> +C<nbdkit_extents_foreach*> returns C<0> on success or C<-1> on failure.
> +However it does not call C<nbdkit_error> or C<nbdkit_set_error> - it
> +is expected that C<fn> will call those functions on failure.

expected that either C<fn> or the caller will call those functions on
failure


> +++ b/server/extents.c
> @@ -0,0 +1,71 @@
> +/* nbdkit

> +#if 0
> +int nbdkit_extents_foreach (const struct nbdkit_extents_map *,
> +                                   int (*fn) (uint64_t offset, uint64_t length,
> +                                              uint32_t type, void *opaque),
> +                                   void *opaque);
> +int nbdkit_extents_foreach_range (const struct nbdkit_extents_map *,
> +            uint64_t range_offset, uint64_t range_length,
> +                                   int (*fn) (uint64_t offset, uint64_t length,

Indentation glitch?

> +                                              uint32_t type, void *opaque),
> +                                   void *opaque);

Otherwise I think we're ready for the implementation, because the
framework is looking good.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190313/f7c734c1/attachment.sig>


More information about the Libguestfs mailing list