<div dir="ltr"><div dir="ltr">On Wed, Jan 20, 2021 at 10:35 PM Richard W.M. Jones <<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Jan 20, 2021 at 09:12:58PM +0200, Nir Soffer wrote:<br>
> In some situations getting image extents can be slow. Add configuration<br>
> value to simulate slow extents. This can be useful for testing and<br>
> optimizing nbd clients.<br>
> <br>
> Example usage - simulating 1 seconds delay:<br>
> <br>
> qemu-img create -f raw test.img 10g<br>
> <br>
> ./nbdkit -f -v python ./plugins/python/examples/file.py \<br>
>     file=test.img extents_delay=1 2>&1 | grep 'python: extents'<br>
<br>
Sorry, I meant to send you a follow-up email about using the delay<br>
filter for this testing, and didn't get around to it.  It is possible<br>
to do this already by putting the delay filter over and controlling<br>
the extents delay.  Something like:<br>
<br>
  ./nbdkit -f -v --filter=delay \<br>
      python ./plugins/python/examples/file.py \<br>
      file=test.img delay-extents=1<br></blockquote><div><br></div><div>Nice</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
---<br>
<br>
What is the purpose of yield() here?<br></blockquote><div><br></div><div>This returns a generator that will return one</div><div>item in the caller. Could be also:</div><div><br></div><div>    return [(offset, count, 0)]</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> +def extents(h, count, offset, flags):<br>
> +    time.sleep(extents_delay)<br>
> +    yield (offset, count, 0)<br>
<br>
Rich.<br>
<br>
-- <br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones</a><br>
Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
Fedora Windows cross-compiler. Compile Windows programs, test, and<br>
build Windows installers. Over 100 libraries supported.<br>
<a href="http://fedoraproject.org/wiki/MinGW" rel="noreferrer" target="_blank">http://fedoraproject.org/wiki/MinGW</a><br>
<br>
</blockquote></div></div>