[Libguestfs] nbdkit: how to require use of filter

Richard W.M. Jones rjones at redhat.com
Wed May 4 09:21:18 UTC 2022


On Wed, May 04, 2022 at 09:04:06AM +0100, Nikolaus Rath wrote:
> On May 03 2022, rjones at redhat.com (Richard W.M. Jones) wrote:
> > On Mon, May 02, 2022 at 10:25:44AM +0100, Nikolaus Rath wrote:
> >> Hi,
> >> 
> >> Is there a way for a nbdkit plugin to *require* use of a nbdkit filter
> >> (specifically the nbdkit-blocksize-filter) programmatically?
> >
> > No it's not possible in general, you just have to document it.
> >
> > However as it's *blocksize* filter that you're talking about, I assume
> > you mean that your filter has blocksize constraints, eg. that it
> > cannot handle sub-sector requests.  In this case it is possible to
> > tell clients that they must not issue requests smaller than a certain
> > size (and also hint about optimal and maximum sizes).  You can do this
> > by writing a .block_size callback.  For example:
> >
> > https://gitlab.com/nbdkit/nbdkit/-/blob/1f5dc0679e570ca2fa149ceaa52922d70462b62c/plugins/vddk/vddk.c#L851
> >
> > Not all clients obey these (although these clients are buggy!)
> 
> Do you happen to know if the kernel's NBD client obeys them?

I should add that examining the NBD client source code in the kernel
shows it only makes requests on sector (512 byte) boundaries.  Notice
the 9 bit shift here:

https://github.com/torvalds/linux/blob/107c948d1d3e61d10aee9d0f7c3d81bbee9842af/drivers/block/nbd.c#L604

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
nbdkit - Flexible, fast NBD server with plugins
https://gitlab.com/nbdkit/nbdkit


More information about the Libguestfs mailing list