On Tue, Jul 07, 2020 at 05:22:47PM -0500, Eric Blake wrote: > This reverts commit 2c5aec42cf04c567639bd885cf12a57192229215. > > Now that we have an easy way to generate aligned extents from the > plugin, where the client will never see an unaligned extent > transition, it's time to put it to use. > > Signed-off-by: Eric Blake <ebl...@redhat.com> > > --- > Here's what I used on the command line; I need to turn it into a formal test: > > $ ./nbdkit -U - eval pread='exit 1' get_size='echo 8' can_extents='exit 0' \ > extents='printf "0 3\n3 4 hole,zero\n7 1\n"' --run \ > 'qemu-img map -f raw --output=json $uri' > $ ./nbdkit -U - --filter=swab eval pread='exit 1' get_size='echo 8' > can_extents='exit 0' extents='printf "0 3\n3 4 hole,zero\n7 1\n"' --run > 'qemu-img map -f raw --output=json $uri' > > except it's currently failing: > nbdkit: eval[1]: error: swab: requests to this filter must be aligned > nbdkit: backend.c:621: backend_extents: Assertion `*err' failed. > qemu-img: Could not read file metadata: Input/output error
I would add -v to the command line, as it will show you exactly what requests qemu-img is making. The assert failure seems to be a separate and worrying problem. Rich. > filters/swab/swab.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/filters/swab/swab.c b/filters/swab/swab.c > index 57a51aee..2e423bbf 100644 > --- a/filters/swab/swab.c > +++ b/filters/swab/swab.c > @@ -191,15 +191,15 @@ swab_zero (struct nbdkit_next_ops *next_ops, void > *nxdata, > return next_ops->zero (nxdata, count, offset, flags, err); > } > > -/* FIXME: Extents could be useful, but if the underlying plugin ever reports > - * values not aligned to 2 bytes, it is complicated to adjust that correctly. > - * In the short term, we punt by disabling extents. > - */ > +/* Extents. */ > static int > -swab_can_extents (struct nbdkit_next_ops *next_ops, void *nxdata, > - void *handle) > +swab_extents (struct nbdkit_next_ops *next_ops, void *nxdata, > + void *handle, uint32_t count, uint64_t offset, uint32_t flags, > + struct nbdkit_extents *extents, int *err) > { > - return 0; > + if (!is_aligned (count, offset)) return -1; > + return nbdkit_extents_aligned (next_ops, nxdata, count, offset, flags, > + bits/8, extents, err); > } > > /* Cache. */ > @@ -223,7 +223,7 @@ static struct nbdkit_filter filter = { > .pwrite = swab_pwrite, > .trim = swab_trim, > .zero = swab_zero, > - .can_extents = swab_can_extents, > + .extents = swab_extents, > .cache = swab_cache, > }; > > -- > 2.27.0 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs -- 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/ _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs