aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>2020-08-06 22:35:50 +0300
committerEric Blake <eblake@redhat.com>2020-08-21 08:56:09 -0500
commit82cb8223248df5276467618638d1262d0b311c33 (patch)
treebd5b13ec0ae9a5497581327269b41edec7bd4d90 /tests
parent991a02ca7f886fb7935d8d64e50ffe72af281e7c (diff)
downloadqemu-82cb8223248df5276467618638d1262d0b311c33.zip
qemu-82cb8223248df5276467618638d1262d0b311c33.tar.gz
qemu-82cb8223248df5276467618638d1262d0b311c33.tar.bz2
qcow2_format.py: dump bitmap flags in human readable way.
Introduce the class BitmapFlags that parses a bitmap flags mask. Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <1596742557-320265-5-git-send-email-andrey.shinkevich@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qemu-iotests/qcow2_format.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/qemu-iotests/qcow2_format.py b/tests/qemu-iotests/qcow2_format.py
index d4a9974..b447344 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -40,6 +40,22 @@ class Flags64(Qcow2Field):
return str(bits)
+class BitmapFlags(Qcow2Field):
+
+ flags = {
+ 0x1: 'in-use',
+ 0x2: 'auto'
+ }
+
+ def __str__(self):
+ bits = []
+ for bit in range(64):
+ flag = self.value & (1 << bit)
+ if flag:
+ bits.append(self.flags.get(flag, f'bit-{bit}'))
+ return f'{self.value:#x} ({bits})'
+
+
class Enum(Qcow2Field):
def __str__(self):