> You are hardcoding to a width of 16 bits; however, version 3 makes the
> refcount field variable-sized:
>
> 96 - 99: refcount_order
> Describes the width of a reference count block entry
> (width
> in bits = 1 << refcount_order). For version 2
> images, the
> order is always assumed to be 4 (i.e. the width is
> 16 bits).
Currently the qcow2 code doesn't support anything but refcount_order == 4.
In qcow2.c qcow_open there is:
be32_to_cpus(&header.refcount_order);
to get the qcow2 order followed by:
/* Check support for various header values */
if (header.refcount_order != 4) {
report_unsupported(bs, "%d bit reference counts",
1 << header.refcount_order);
ret = -ENOTSUP;
goto fail;
}
I guess the code doesn't need any special handling for now.
> Hmm, what happens if refcount_order is 0 to disable reference counting?
> That setting is valid for creating a qcow2 file that can't be used for
> internal snapshots. But it also interferes with dedup; so you probably
> want to add some additional requirements in the spec (patch 1/36) that
> when dedup is in use, refcount_order must be a minimum value (or require
> that it be exactly 4, for a width of 16 bits).
I'll do that.
Regards
Benoît