From: Andrey Shinkevich Date: Thu, 6 Aug 2020 19:35:50 +0000 (+0300) Subject: qcow2_format.py: dump bitmap flags in human readable way. X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=82cb8223248df5276467618638d1262d0b311c33;p=qemu.git 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 Signed-off-by: Andrey Shinkevich Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <1596742557-320265-5-git-send-email-andrey.shinkevich@virtuozzo.com> Signed-off-by: Eric Blake --- diff --git a/tests/qemu-iotests/qcow2_format.py b/tests/qemu-iotests/qcow2_format.py index d4a9974537..b4473442c9 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):