On 11/10/2014 06:45 AM, Max Reitz wrote: > Add two new fields regarding refcount information (the bit width of > every entry and the maximum refcount value) to the BDRVQcowState. > > Signed-off-by: Max Reitz <mre...@redhat.com> > --- > block/qcow2-refcount.c | 2 +- > block/qcow2.c | 9 +++++++++ > block/qcow2.h | 2 ++ > 3 files changed, 12 insertions(+), 1 deletion(-)
Reviewed-by: Eric Blake <ebl...@redhat.com> > +++ b/block/qcow2.c > @@ -684,6 +684,15 @@ static int qcow2_open(BlockDriverState *bs, QDict > *options, int flags, > goto fail; > } > s->refcount_order = header.refcount_order; > + s->refcount_bits = 1 << s->refcount_order; Not shown is the context where a few lines before still enforces refcount_order==4, so this doesn't overflow. When later patches relax that, I'll make sure we don't overflow here as well. > + if (s->refcount_order < 6) { > + s->refcount_max = (UINT64_C(1) << s->refcount_bits) - 1; I don't see the UINT64_C macro get much use, but like it better than casting :) > + } else { I don't know if Coverity might complain about dead code during bisection (since we can't get here until we relax refcount_order to not be forced to 4), but that's a layer beyond making sure 'make check' works so I don't care. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature