qemu-img: Add find_nonzero()
commitdebb38a4cec34709604a00e23368e6cd8932fe3d
authorEric Blake <eblake@redhat.com>
Thu, 12 Oct 2017 03:47:11 +0000 (11 22:47 -0500)
committerKevin Wolf <kwolf@redhat.com>
Thu, 26 Oct 2017 12:45:57 +0000 (26 14:45 +0200)
treea26f707afc46ff0a8c41eb30c54d61de0c46cf5f
parent391cb1aacad155bea4270b863710bba9adabe311
qemu-img: Add find_nonzero()

During 'qemu-img compare', when we are checking that an allocated
portion of one file is all zeros, we don't need to waste time
computing how many additional sectors after the first non-zero
byte are also non-zero.  Create a new helper find_nonzero() to do
the check for a first non-zero sector, and rebase
check_empty_sectors() to use it.

The new interface intentionally uses bytes in its interface, even
though it still crawls the buffer a sector at a time; it is robust
to a partial sector at the end of the buffer.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-img.c