On 9/14/18 3:35 AM, lampahome wrote:
The function qcow2_get_cluster_type() is in /block/qcow2.h
It will return the flage based on the entry.

There're some flags confused me.
What's difference between QCOW2_CLUSTER_ZERO_ALLOC &
QCOW2_CLUSTER_ZERO_PLAIN
in there?

Look at docs/interop/qcow2.txt at the L2 entry format:

Bit 0: If set to 1, the cluster reads as all zeros
Bits 9-55: Bits 9-55 of host cluster offset; if 0 the cluster is unallocated

Both values correspond to L2 entries with bit 0 set. However, QCOW2_CLUSTER_ZERO_ALLOC is an entry that has a non-zero value in bits 9-55 (the cluster has an allocated host location, we guarantee that things read as zero regardless of whether the host data actually contains zeroes at that offset, and writes go directly to that offset with no further allocation required); while QCOW2_CLUSTER_ZERO_PLAIN is an entry with all zeros in bits 9-55 (we guarantee things read as zero, but writes have to allocate a new cluster because we have not reserved any space in the host yet).

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to