diff options
Diffstat (limited to 'tests/qemu-iotests/qcow2.py')
-rwxr-xr-x | tests/qemu-iotests/qcow2.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py index bfb47e88fc..e27196aa26 100755 --- a/tests/qemu-iotests/qcow2.py +++ b/tests/qemu-iotests/qcow2.py @@ -35,6 +35,13 @@ class QcowHeader: [ uint32_t, '%d', 'refcount_table_clusters' ], [ uint32_t, '%d', 'nb_snapshots' ], [ uint64_t, '%#x', 'snapshot_offset' ], + + # Version 3 header fields + [ uint64_t, '%#x', 'incompatible_features' ], + [ uint64_t, '%#x', 'compatible_features' ], + [ uint64_t, '%#x', 'autoclear_features' ], + [ uint32_t, '%d', 'refcount_order' ], + [ uint32_t, '%d', 'header_length' ], ]; fmt = '>' + ''.join(field[0] for field in fields) @@ -50,9 +57,10 @@ class QcowHeader: self.__dict__ = dict((field[2], header[i]) for i, field in enumerate(QcowHeader.fields)) + self.set_defaults() self.cluster_size = 1 << self.cluster_bits - fd.seek(self.get_header_length()) + fd.seek(self.header_length) self.load_extensions(fd) if self.backing_file_offset: @@ -61,11 +69,13 @@ class QcowHeader: else: self.backing_file = None - def get_header_length(self): + def set_defaults(self): if self.version == 2: - return 72 - else: - raise Exception("version != 2 not supported") + self.incompatible_features = 0 + self.compatible_features = 0 + self.autoclear_features = 0 + self.refcount_order = 4 + self.header_length = 72 def load_extensions(self, fd): self.extensions = [] @@ -86,7 +96,7 @@ class QcowHeader: def update_extensions(self, fd): - fd.seek(self.get_header_length()) + fd.seek(self.header_length) extensions = self.extensions extensions.append(QcowHeaderExtension(0, 0, "")) for ex in extensions: @@ -103,7 +113,7 @@ class QcowHeader: def update(self, fd): - header_bytes = self.get_header_length() + header_bytes = self.header_length self.update_extensions(fd) |