qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH v2 11/26] qcow2: Add qcow2_get_subcluster_type()


From: Max Reitz
Subject: Re: [RFC PATCH v2 11/26] qcow2: Add qcow2_get_subcluster_type()
Date: Mon, 4 Nov 2019 13:35:30 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

On 26.10.19 23:25, Alberto Garcia wrote:
> This function returns the type of an individual subcluster. If an
> image does not have subclusters then this returns the exact same value
> as qcow2_get_cluster_type().
> 
> The information in standard and extended L2 entries is encoded in a
> slightly different way, but all existing QCow2ClusterType values are
> also valid for subclusters and have the same meanings (although they
> typically only apply to the requested subcluster).
> 
> There are two important exceptions to this:
> 
>   a) QCOW2_CLUSTER_COMPRESSED means that the whole cluster is
>      compressed. We do not support compression at the subcluster
>      level.
> 
>   b) QCOW2_CLUSTER_UNALLOCATED means that the cluster is unallocated,
>      that is, the offset field of the L2 entry does not point to a
>      host cluster. All subclusters are obviously unallocated too but
>      any of them could be of type QCOW2_CLUSTER_ZERO_PLAIN.
> 
> In addition to that, extended L2 entries allow one new scenario where
> the cluster is normally allocated but an individual subcluster is not.
> This is very different from (b) and because of that this patch adds a
> new value called QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER.
> 
> As a last thing, this patch adds QCOW2_CLUSTER_INVALID to detect the
> cases where an L2 entry has a value that violates the spec. The caller
> is responsible for handling these situations.
> 
> To prevent compatibility problems with images that have invalid values
> but are currently being read by QEMU without causing side effects,
> QCOW2_CLUSTER_INVALID is only returned for images with extended L2
> entries.
> 
> Signed-off-by: Alberto Garcia <address@hidden>
> ---
>  block/qcow2.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 62 insertions(+)

[...]

> +        case QCOW2_CLUSTER_ZERO_PLAIN:
> +        case QCOW2_CLUSTER_ZERO_ALLOC:
> +            return QCOW2_CLUSTER_INVALID;

The spec doesn’t say anything about this, though.

(I would have assumed it’s valid and the subcluster zero status is
simply ignored.  It makes sense to forbit this case, but the spec should
make a note of it.)

Nax

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]