Skip to content

Commit

Permalink
qcow2_format.py: dump bitmap flags in human readable way.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
a-shinkevich authored and ebblake committed Aug 21, 2020
1 parent 991a02c commit 82cb822
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/qemu-iotests/qcow2_format.py
Expand Up @@ -40,6 +40,22 @@ def __str__(self):
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):
Expand Down

0 comments on commit 82cb822

Please sign in to comment.