summary refs log tree commit diff stats
path: root/tests/qemu-iotests/qcow2_format.py
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2020-06-06 11:18:05 +0300
committerEric Blake <eblake@redhat.com>2020-06-09 15:47:10 -0500
commitaef87784f93b9e7e07ea7b2ee9dee4c257c1881f (patch)
tree6427f725fc3857ce9ef3c930cad0828ed552b203 /tests/qemu-iotests/qcow2_format.py
parenta9e750e1ce0bfcca1ff51c71e66eb4b0f66061a8 (diff)
downloadfocaccia-qemu-aef87784f93b9e7e07ea7b2ee9dee4c257c1881f.tar.gz
focaccia-qemu-aef87784f93b9e7e07ea7b2ee9dee4c257c1881f.zip
qcow2: QcowHeaderExtension print names for extension magics
Suggested-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200606081806.23897-13-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/qcow2_format.py')
-rw-r--r--tests/qemu-iotests/qcow2_format.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/qemu-iotests/qcow2_format.py b/tests/qemu-iotests/qcow2_format.py
index 32371e42da..40b5bf467b 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -39,6 +39,12 @@ class Flags64(Qcow2Field):
         return str(bits)
 
 
+class Enum(Qcow2Field):
+
+    def __str__(self):
+        return f'{self.value:#x} ({self.mapping.get(self.value, "<unknown>")})'
+
+
 class Qcow2StructMeta(type):
 
     # Mapping from c types to python struct format
@@ -99,8 +105,17 @@ class Qcow2Struct(metaclass=Qcow2StructMeta):
 
 class QcowHeaderExtension(Qcow2Struct):
 
+    class Magic(Enum):
+        mapping = {
+            0xe2792aca: 'Backing format',
+            0x6803f857: 'Feature table',
+            0x0537be77: 'Crypto header',
+            0x23852875: 'Bitmaps',
+            0x44415441: 'Data file'
+        }
+
     fields = (
-        ('u32', '{:#x}', 'magic'),
+        ('u32', Magic, 'magic'),
         ('u32', '{}', 'length')
         # length bytes of data follows
         # then padding to next multiply of 8