On Wed, Dec 22, 2021 at 12:47:59AM +0200, Nir Soffer wrote:
On Wed, Dec 22, 2021 at 12:36 AM Richard W.M. Jones
<rjones(a)redhat.com> wrote:
>
> On Tue, Dec 21, 2021 at 10:25:35PM +0000, Richard W.M. Jones wrote:
> > On Wed, Dec 22, 2021 at 12:21:25AM +0200, Nir Soffer wrote:
> > > It would be help also if we can test extents argument, currently the
> > > plugin ignores the argument so we did not detect the issue with the
> > > wrong format string.
> >
> > OK, I'll take a look.
>
> I see - the plugin function is defined just to return the extents sent
> in (for testing):
>
> def extents(h, count, offset, flags):
> return cfg.get('extents', [])
>
> This means we don't test the parameters. However to test those
> realistically I suppose we would really need to support sparse disks
> in this test plugin, which seems quite tricky.
I think what can work is this:
- pass the actual extents to the plugin
For example empty sparse file:
extents = [(0, 10 * GiB, nbdkit.EXTENT_ZERO)]
Now when we request:
extents(4*GB -1, 0, 0)
The plugin can return:
return [(0, count, nbdkit.EXTENT_ZERO)]
Isn't this what the code above already does?
The logic to return extents from the existing list is a little
tricky. I have
similar code in a memory backend for imageio (in review):
https://github.com/oVirt/ovirt-imageio/pull/7/commits/9068f84c96f1239d841...
And this is also the code for getting extents from imageio, posted here:
https://listman.redhat.com/archives/libguestfs/2021-December/msg00197.html
I'm confused about this bit.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html