On Fri, Sep 15, 2023 at 07:20:12PM +0300, Andrey Drobyshev wrote: > Add @chsize param to the function which, if non-zero, would represent > the chunk size to be used for comparison. If it's zero, then > BDRV_SECTOR_SIZE is used as default chunk size, which is the previous > behaviour. > > In particular, we're going to use this param in img_rebase() to make the > write requests aligned to a predefined alignment value. > > Signed-off-by: Andrey Drobyshev <andrey.drobys...@virtuozzo.com> > --- > qemu-img.c | 22 ++++++++++++++-------- > 1 file changed, 14 insertions(+), 8 deletions(-) > > diff --git a/qemu-img.c b/qemu-img.c > index d12e4a4753..fcd31d7b5b 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > @@ -1274,23 +1274,29 @@ static int is_allocated_sectors_min(const uint8_t > *buf, int n, int *pnum, > } > > /* > - * Compares two buffers sector by sector. Returns 0 if the first > - * sector of each buffer matches, non-zero otherwise. > + * Compares two buffers chunk by chunk, where @chsize is the chunk size. > + * If @chsize is 0, default chunk size of BDRV_SECTOR_SIZE is used. > + * Returns 0 if the first chunk of each buffer matches, non-zero otherwise. > * > - * pnum is set to the sector-aligned size of the buffer prefix that > + * @pnum is set to the size of the buffer prefix aligned to @chsize that > * has the same matching status as the first sector.
s/sector/chunk/ With that, Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org