On Sat, Jul 24, 2021 at 11:40:49AM +0100, Richard W.M. Jones wrote:
I wonder if this is an overflow:
$ ./nbdkit sparse-random 3G --filter=cow --run 'nbdinfo --map $uri'
# OK
$ ./nbdkit sparse-random 4G --filter=cow --run 'nbdinfo --map $uri'
nbdkit: cow.c:591: cow_extents: Assertion `count > 0' failed.
This is OK on my machine as well.
Any size >= 4G seems to cause the crash.
What struck me with this is:
cow.c:cow_extents:
/* To make this easier, align the requested extents to whole blocks.
* Note that count is a 64 bit variable containing at most a 32 bit
* value so rounding up is safe here.
*/
I started debugging the cow filter and the values for 4G image I got
are:
count=4294966784; offset=0 // Pre-rounding
end=4294967296; offset=0; count=4294967296; blknum=0 // Post-rounding
It looks like it is not asking for the whole size, but size - 1 block.
That gets rounded to 2^32 and sparse-extents then reports:
sparse-random: extents count=4294963200 offset=0 req_one=0
sparse-random: extents count=4096 offset=4294963200 req_one=0
Which is 2^32 - 4096. I hope I am not confusing anyone with this, but
it seems weird to me.
Martin
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v