On 09/02/2014 12:59 PM, Max Reitz wrote:

>> Consider refcount_order == 0 (that is, no shared blocks, ALL blocks have
>> at most refcount 1).  Then, refcount_bits is (1 << 0) == 1.  But 1/8 in
>> integer math truncates to 0 (oops, division by zero is undefined); when
>> in reality, the expression you want here is (cluster_size * 8 /
>> refcount_bits).
> 
> If it is integer division, that is. ;-)
> 
> I'm counting on you accepting "cluster_size * 8 / refcount_bits" and not
> rejecting it because of a possible integer overflow. *g*

We already document that qemu's maximum cluster size is 2M; and 2M*8 is
less than 32 bits :)

Maybe the qcow2 spec allows the theoretical file with a cluster size of
512M, where overflow then matters.  But you are correct that I won't
reject your patch, given that qemu doesn't parse all possible
theoretical qcow2 files :)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to