On Wed, Jan 20, 2021 at 10:35 PM Richard W.M. Jones <rjones@redhat.com> wrote:
On Wed, Jan 20, 2021 at 09:12:58PM +0200, Nir Soffer wrote:
> In some situations getting image extents can be slow. Add configuration
> value to simulate slow extents. This can be useful for testing and
> optimizing nbd clients.
> Example usage - simulating 1 seconds delay:
> qemu-img create -f raw test.img 10g
> ./nbdkit -f -v python ./plugins/python/examples/file.py \
>     file=test.img extents_delay=1 2>&1 | grep 'python: extents'

Sorry, I meant to send you a follow-up email about using the delay
filter for this testing, and didn't get around to it.  It is possible
to do this already by putting the delay filter over and controlling
the extents delay.  Something like:

  ./nbdkit -f -v --filter=delay \
      python ./plugins/python/examples/file.py \
      file=test.img delay-extents=1



What is the purpose of yield() here?

This returns a generator that will return one
item in the caller. Could be also:

    return [(offset, count, 0)]

> +def extents(h, count, offset, flags):
> +    time.sleep(extents_delay)
> +    yield (offset, count, 0)


Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.