diff options
author | Kevin Wolf <kwolf@redhat.com> | 2012-03-16 15:02:38 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-04-20 15:57:29 +0200 |
commit | 6377af48b0445e7ee50db6e0bd73a3a70098f5f4 (patch) | |
tree | e3b5171b5645490af6a392662790d7de88247a69 /block/qcow2.h | |
parent | 6744cbab8cd63b7ce72b3eee4f0055007acf0798 (diff) | |
download | qemu-6377af48b0445e7ee50db6e0bd73a3a70098f5f4.tar.gz qemu-6377af48b0445e7ee50db6e0bd73a3a70098f5f4.tar.bz2 qemu-6377af48b0445e7ee50db6e0bd73a3a70098f5f4.zip |
qcow2: Support reading zero clusters
This adds support for reading zero clusters in version 3 images.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qcow2.h')
-rw-r--r-- | block/qcow2.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/block/qcow2.h b/block/qcow2.h index 2dc8ca26fb..df2bdfd0c6 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -43,6 +43,8 @@ #define QCOW_OFLAG_COPIED (1LL << 63) /* indicate that the cluster is compressed (they never have the copied flag) */ #define QCOW_OFLAG_COMPRESSED (1LL << 62) +/* The cluster reads as all zeros */ +#define QCOW_OFLAG_ZERO (1LL << 0) #define REFCOUNT_SHIFT 1 /* refcount size is 2 bytes */ @@ -184,6 +186,7 @@ enum { QCOW2_CLUSTER_UNALLOCATED, QCOW2_CLUSTER_NORMAL, QCOW2_CLUSTER_COMPRESSED, + QCOW2_CLUSTER_ZERO }; #define L1E_OFFSET_MASK 0x00ffffffffffff00ULL @@ -213,6 +216,8 @@ static inline int qcow2_get_cluster_type(uint64_t l2_entry) { if (l2_entry & QCOW_OFLAG_COMPRESSED) { return QCOW2_CLUSTER_COMPRESSED; + } else if (l2_entry & QCOW_OFLAG_ZERO) { + return QCOW2_CLUSTER_ZERO; } else if (!(l2_entry & L2E_OFFSET_MASK)) { return QCOW2_CLUSTER_UNALLOCATED; } else { |