Skip to content

Commit

Permalink
qcow2: QcowHeaderExtension print names for extension magics
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and ebblake committed Jun 9, 2020
1 parent a9e750e commit aef8778
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
22 changes: 11 additions & 11 deletions tests/qemu-iotests/031.out
Expand Up @@ -25,7 +25,7 @@ refcount_order 4
header_length 72

Header extension:
magic 0x12345678
magic 0x12345678 (<unknown>)
length 31
data 'This is a test header extension'

Expand Down Expand Up @@ -53,7 +53,7 @@ refcount_order 4
header_length 72

Header extension:
magic 0x12345678
magic 0x12345678 (<unknown>)
length 31
data 'This is a test header extension'

Expand Down Expand Up @@ -81,12 +81,12 @@ refcount_order 4
header_length 72

Header extension:
magic 0xe2792aca
magic 0xe2792aca (Backing format)
length 11
data 'host_device'

Header extension:
magic 0x12345678
magic 0x12345678 (<unknown>)
length 31
data 'This is a test header extension'

Expand Down Expand Up @@ -116,12 +116,12 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Header extension:
magic 0x12345678
magic 0x12345678 (<unknown>)
length 31
data 'This is a test header extension'

Expand Down Expand Up @@ -149,12 +149,12 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Header extension:
magic 0x12345678
magic 0x12345678 (<unknown>)
length 31
data 'This is a test header extension'

Expand Down Expand Up @@ -182,17 +182,17 @@ refcount_order 4
header_length 112

Header extension:
magic 0xe2792aca
magic 0xe2792aca (Backing format)
length 11
data 'host_device'

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Header extension:
magic 0x12345678
magic 0x12345678 (<unknown>)
length 31
data 'This is a test header extension'

Expand Down
4 changes: 2 additions & 2 deletions tests/qemu-iotests/036.out
Expand Up @@ -25,7 +25,7 @@ incompatible_features []
compatible_features []
autoclear_features [63]
Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand All @@ -37,7 +37,7 @@ incompatible_features []
compatible_features []
autoclear_features []
Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand Down
14 changes: 7 additions & 7 deletions tests/qemu-iotests/061.out
Expand Up @@ -25,7 +25,7 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand Down Expand Up @@ -83,7 +83,7 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand Down Expand Up @@ -139,7 +139,7 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand Down Expand Up @@ -194,7 +194,7 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand Down Expand Up @@ -263,7 +263,7 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand Down Expand Up @@ -325,7 +325,7 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand Down Expand Up @@ -354,7 +354,7 @@ refcount_order 4
header_length 112

Header extension:
magic 0x6803f857
magic 0x6803f857 (Feature table)
length 336
data <binary>

Expand Down
17 changes: 16 additions & 1 deletion tests/qemu-iotests/qcow2_format.py
Expand Up @@ -39,6 +39,12 @@ def __str__(self):
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
Expand Down Expand Up @@ -99,8 +105,17 @@ def dump(self):

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
Expand Down

0 comments on commit aef8778

Please sign in to comment.