On Tue, Feb 08, 2022 at 02:29:48PM -0600, Eric Blake wrote:
On Tue, Feb 08, 2022 at 12:39:02PM +0100, Laszlo Ersek wrote:
> (The same question applies to "plugin-args" in the synopsys, more or
> less...)
Hmm, we aren't always consistent, but I agree that it can be pruned
without loss.
Yes, there's quite a lot of inconsistency across man pages. I've
tried to make the use of =item, B<>, C<>, I<>, F<> consistent as
far
as possible, but there are many other things to fix. One day ...
The code in server/ guarantees that we cannot call into a filter or
plugin with an extents request that would read out of bounds; ie. on
input, offset+count will never exceed what next->get_size() would tell
us anyways. Conversely, nbdkit_add_extent() already permits us to
pass in redundant information prior to offset (as long as we make
forward progress by eventually using nbdkit_add_extent for at least
one byte at offset before returning), as well as to provide more
information than needed (the upper layer can set a clamp, such as when
FLAG_REQ_ONE is in use by the client, or at the 32-bit boundary
condition, where our additions beyond that clamp are merely ignored).
So we could just as easily write
return nbdkit_add_extent (ret_extents, 0, INT64_MAX, 0);
Just to add to this point:
A key aim is to make nbdkit _plugins_ as easy to write as possible.
So plugins always receive bounds checked parameters, and the APIs that
plugins call are supposed to be easy to use / have no sharp edges.
Also of course the plugin API and ABI is stable.
This doesn't apply so much to filters. There's no stable API/ABI for
filters, they're all in-tree, and it's quite complicated to write them
correctly.
However in this case the API (nbdkit_add_extent) is used by both
plugins and filters, so it is meant to be easy to use.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/