[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/14] qcow2_format.py: dump bitmap flags in human readable way.
From: |
Eric Blake |
Subject: |
[PULL 04/14] qcow2_format.py: dump bitmap flags in human readable way. |
Date: |
Fri, 21 Aug 2020 09:08:16 -0500 |
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
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>
---
tests/qemu-iotests/qcow2_format.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tests/qemu-iotests/qcow2_format.py
b/tests/qemu-iotests/qcow2_format.py
index d4a997453758..b4473442c9d4 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):
--
2.28.0
- [PULL 00/14] bitmaps patches for 2020-08-21, Eric Blake, 2020/08/21
- [PULL 04/14] qcow2_format.py: dump bitmap flags in human readable way.,
Eric Blake <=
- [PULL 10/14] qcow2_format.py: support dumping metadata in JSON format, Eric Blake, 2020/08/21
- [PULL 12/14] migration: Add block-bitmap-mapping parameter, Eric Blake, 2020/08/21
- [PULL 01/14] iotests: add test for QCOW2 header dump, Eric Blake, 2020/08/21
- [PULL 02/14] qcow2_format.py: make printable data an extension class member, Eric Blake, 2020/08/21
- [PULL 03/14] qcow2_format.py: change Qcow2BitmapExt initialization method, Eric Blake, 2020/08/21
- [PULL 06/14] qcow2_format.py: pass cluster size to substructures, Eric Blake, 2020/08/21
- [PULL 05/14] qcow2_format.py: Dump bitmap directory information, Eric Blake, 2020/08/21
- [PULL 07/14] qcow2_format.py: Dump bitmap table serialized entries, Eric Blake, 2020/08/21
- [PULL 09/14] qcow2_format.py: collect fields to dump in JSON format, Eric Blake, 2020/08/21
- [PULL 11/14] iotests: dump QCOW2 header in JSON in #303, Eric Blake, 2020/08/21