diff mbox series

[v3,1/6] iotests: Add extension names to qcow2.py dump

Message ID 1591019293-211155-2-git-send-email-andrey.shinkevich@virtuozzo.com
State New
Headers show
Series iotests: Dump QCOW2 dirty bitmaps metadata | expand

Commit Message

Andrey Shinkevich June 1, 2020, 1:48 p.m. UTC
Header extension:         Feature table
magic                     0x6803f857
length                    192
data                      <binary>

The change incurs modification of the output in 031, 036 and 061 test
cases.

Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
---
 tests/qemu-iotests/031.out  | 22 +++++++++++-----------
 tests/qemu-iotests/036.out  |  4 ++--
 tests/qemu-iotests/061.out  | 18 +++++++++---------
 tests/qemu-iotests/qcow2.py | 23 ++++++++++++++++++++---
 4 files changed, 42 insertions(+), 25 deletions(-)

Comments

Eric Blake June 2, 2020, 4:05 p.m. UTC | #1
On 6/1/20 8:48 AM, Andrey Shinkevich wrote:
> Header extension:         Feature table
> magic                     0x6803f857
> length                    192
> data                      <binary>
> 
> The change incurs modification of the output in 031, 036 and 061 test
> cases.
> 
> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
> ---
>   tests/qemu-iotests/031.out  | 22 +++++++++++-----------
>   tests/qemu-iotests/036.out  |  4 ++--
>   tests/qemu-iotests/061.out  | 18 +++++++++---------
>   tests/qemu-iotests/qcow2.py | 23 ++++++++++++++++++++---
>   4 files changed, 42 insertions(+), 25 deletions(-)
> 

> +++ b/tests/qemu-iotests/061.out

> @@ -491,7 +491,7 @@ wrote 65536/65536 bytes at offset 2147483648
>   64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>   wrote 65536/65536 bytes at offset 3221225472
>   64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> -    (0.00/100%)
>      (12.50/100%)
>      (25.00/100%)
>      (37.50/100%)
>      (50.00/100%)
>      (62.50/100%)
>      (75.00/100%)
>      (87.50/100%)
>      (100.00/100%)
>      (100.00/100%)
> +    (0.00/100%)    (12.50/100%)    (25.00/100%)    (37.50/100%)    (50.00/100%)    (62.50/100%)    (75.00/100%)    (87.50/100%)    (100.00/100%)    (100.00/100%)
>   No errors were found on the image.

This hunk looks odd.  But it is not necessarily wrong.  Occurs a couple 
of times.

> +++ b/tests/qemu-iotests/qcow2.py
> @@ -6,19 +6,36 @@ import string
>   
>   class QcowHeaderExtension:
>   
> +    QCOW2_EXT_MAGIC_BACKING_FORMAT = 0xE2792ACA
> +    QCOW2_EXT_MAGIC_FEATURE_TABLE = 0x6803f857

Why the inconsistency between capitalization in these constants?

Reviewed-by: Eric Blake <eblake@redhat.com>
Eric Blake June 2, 2020, 4:07 p.m. UTC | #2
On 6/2/20 11:05 AM, Eric Blake wrote:

[I hit send too soon...]

>> +++ b/tests/qemu-iotests/qcow2.py
>> @@ -6,19 +6,36 @@ import string
>>   class QcowHeaderExtension:
>> +    QCOW2_EXT_MAGIC_BACKING_FORMAT = 0xE2792ACA
>> +    QCOW2_EXT_MAGIC_FEATURE_TABLE = 0x6803f857
> 
> Why the inconsistency between capitalization in these constants?

At least it matches the inconsistency in docs/interop/qcow2.txt; a patch 
to fix that wouldn't hurt.

> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
Vladimir Sementsov-Ogievskiy June 2, 2020, 7:25 p.m. UTC | #3
01.06.2020 16:48, Andrey Shinkevich wrote:
> Header extension:         Feature table
> magic                     0x6803f857
> length                    192
> data                      <binary>
> 
> The change incurs modification of the output in 031, 036 and 061 test
> cases.
> 
> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
> ---
>   tests/qemu-iotests/031.out  | 22 +++++++++++-----------
>   tests/qemu-iotests/036.out  |  4 ++--
>   tests/qemu-iotests/061.out  | 18 +++++++++---------
>   tests/qemu-iotests/qcow2.py | 23 ++++++++++++++++++++---
>   4 files changed, 42 insertions(+), 25 deletions(-)
> 
> diff --git a/tests/qemu-iotests/031.out b/tests/qemu-iotests/031.out
> index 5a4beda..966c8d9 100644
> --- a/tests/qemu-iotests/031.out
> +++ b/tests/qemu-iotests/031.out
> @@ -24,7 +24,7 @@ autoclear_features        []
>   refcount_order            4
>   header_length             72
>   
> -Header extension:
> +Header extension:         Unknown
>   magic                     0x12345678
>   length                    31
>   data                      'This is a test header extension'
> @@ -52,7 +52,7 @@ autoclear_features        []
>   refcount_order            4
>   header_length             72
>   
> -Header extension:
> +Header extension:         Unknown
>   magic                     0x12345678
>   length                    31
>   data                      'This is a test header extension'
> @@ -80,12 +80,12 @@ autoclear_features        []
>   refcount_order            4
>   header_length             72
>   
> -Header extension:
> +Header extension:         Backing format
>   magic                     0xe2792aca
>   length                    11
>   data                      'host_device'
>   
> -Header extension:
> +Header extension:         Unknown
>   magic                     0x12345678
>   length                    31
>   data                      'This is a test header extension'
> @@ -115,12 +115,12 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
>   
> -Header extension:
> +Header extension:         Unknown
>   magic                     0x12345678
>   length                    31
>   data                      'This is a test header extension'
> @@ -148,12 +148,12 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
>   
> -Header extension:
> +Header extension:         Unknown
>   magic                     0x12345678
>   length                    31
>   data                      'This is a test header extension'
> @@ -181,17 +181,17 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Backing format
>   magic                     0xe2792aca
>   length                    11
>   data                      'host_device'
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
>   
> -Header extension:
> +Header extension:         Unknown
>   magic                     0x12345678
>   length                    31
>   data                      'This is a test header extension'
> diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out
> index e409acf..81a7366 100644
> --- a/tests/qemu-iotests/036.out
> +++ b/tests/qemu-iotests/036.out
> @@ -24,7 +24,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
>   incompatible_features     []
>   compatible_features       []
>   autoclear_features        [63]
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> @@ -36,7 +36,7 @@ No errors were found on the image.
>   incompatible_features     []
>   compatible_features       []
>   autoclear_features        []
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
> index a51ad1b..7821b7f 100644
> --- a/tests/qemu-iotests/061.out
> +++ b/tests/qemu-iotests/061.out
> @@ -24,7 +24,7 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> @@ -82,7 +82,7 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> @@ -138,7 +138,7 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> @@ -193,7 +193,7 @@ autoclear_features        [42]
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> @@ -262,7 +262,7 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> @@ -324,7 +324,7 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> @@ -353,7 +353,7 @@ autoclear_features        []
>   refcount_order            4
>   header_length             112
>   
> -Header extension:
> +Header extension:         Feature table
>   magic                     0x6803f857
>   length                    336
>   data                      <binary>
> @@ -491,7 +491,7 @@ wrote 65536/65536 bytes at offset 2147483648
>   64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>   wrote 65536/65536 bytes at offset 3221225472
>   64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> -    (0.00/100%)
>      (12.50/100%)
>      (25.00/100%)
>      (37.50/100%)
>      (50.00/100%)
>      (62.50/100%)
>      (75.00/100%)
>      (87.50/100%)
>      (100.00/100%)
>      (100.00/100%)
> +    (0.00/100%)    (12.50/100%)    (25.00/100%)    (37.50/100%)    (50.00/100%)    (62.50/100%)    (75.00/100%)    (87.50/100%)    (100.00/100%)    (100.00/100%)
>   No errors were found on the image.
>   
>   === Testing progress report with snapshot ===
> @@ -506,7 +506,7 @@ wrote 65536/65536 bytes at offset 2147483648
>   64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>   wrote 65536/65536 bytes at offset 3221225472
>   64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> -    (0.00/100%)
>      (6.25/100%)
>      (12.50/100%)
>      (18.75/100%)
>      (25.00/100%)
>      (31.25/100%)
>      (37.50/100%)
>      (43.75/100%)
>      (50.00/100%)
>      (56.25/100%)
>      (62.50/100%)
>      (68.75/100%)
>      (75.00/100%)
>      (81.25/100%)
>      (87.50/100%)
>      (93.75/100%)
>      (100.00/100%)
>      (100.00/100%)
> +    (0.00/100%)    (6.25/100%)    (12.50/100%)    (18.75/100%)    (25.00/100%)    (31.25/100%)    (37.50/100%)    (43.75/100%)    (50.00/100%)    (56.25/100%)    (62.50/100%)    (68.75/100%)    (75.00/100%)    (81.25/100%)    (87.50/100%)    (93.75/100%)    (100.00/100%)    (100.00/100%)
>   No errors were found on the image.
>   
>   === Testing version downgrade with external data file ===

^^^ these two chunks are some mistake, I even can't apply the patch with them. And with them dropped, tests pass for me. [*]

> diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
> index 94a07b2..e824b09 100755
> --- a/tests/qemu-iotests/qcow2.py
> +++ b/tests/qemu-iotests/qcow2.py
> @@ -6,19 +6,36 @@ import string
>   

while being here, may add one more newline for PEP8

>   class QcowHeaderExtension:
>   
> +    QCOW2_EXT_MAGIC_BACKING_FORMAT = 0xE2792ACA
> +    QCOW2_EXT_MAGIC_FEATURE_TABLE = 0x6803f857
> +    QCOW2_EXT_MAGIC_CRYPTO_HEADER = 0x0537be77
> +    QCOW2_EXT_MAGIC_BITMAPS = 0x23852875
> +    QCOW2_EXT_MAGIC_DATA_FILE = 0x44415441
> +
>       def __init__(self, magic, length, data):
>           if length % 8 != 0:
>               padding = 8 - (length % 8)
>               data += b"\0" * padding
>   
> -        self.magic  = magic
> +        self.magic = magic
>           self.length = length
> -        self.data   = data
> +        self.data = data
> +        self.name = self.extension_name(magic)
>   
>       @classmethod
>       def create(cls, magic, data):
>           return QcowHeaderExtension(magic, len(data), data)
>   
> +    def extension_name(self, magic):

let this be classmethod

> +        return {
> +            self.QCOW2_EXT_MAGIC_BACKING_FORMAT: 'Backing format',
> +            self.QCOW2_EXT_MAGIC_FEATURE_TABLE: 'Feature table',
> +            self.QCOW2_EXT_MAGIC_CRYPTO_HEADER: 'Crypto header',
> +            self.QCOW2_EXT_MAGIC_BITMAPS: 'Bitmaps',
> +            self.QCOW2_EXT_MAGIC_DATA_FILE: 'Data file',
> +        }.get(magic, 'Unknown')
> +
> +
>   class QcowHeader:
>   
>       uint32_t = 'I'
> @@ -151,7 +168,7 @@ class QcowHeader:
>               else:
>                   data = "<binary>"
>   
> -            print("Header extension:")
> +            print("%-25s %s" % ("Header extension:", ex.name))
>               print("%-25s %#x" % ("magic", ex.magic))
>               print("%-25s %d" % ("length", ex.length))
>               print("%-25s %s" % ("data", data))
> 


With dropped two strange [*] hunks, and with (or without) the following diff additionally applied:
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


recommended additional change:

--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -4,6 +4,7 @@ import sys
  import struct
  import string
  
+
  class QcowHeaderExtension:
  
      QCOW2_EXT_MAGIC_BACKING_FORMAT = 0xE2792ACA
@@ -26,13 +27,14 @@ class QcowHeaderExtension:
      def create(cls, magic, data):
          return QcowHeaderExtension(magic, len(data), data)
  
-    def extension_name(self, magic):
+    @classmethod
+    def extension_name(cls, magic):
          return {
-            self.QCOW2_EXT_MAGIC_BACKING_FORMAT: 'Backing format',
-            self.QCOW2_EXT_MAGIC_FEATURE_TABLE: 'Feature table',
-            self.QCOW2_EXT_MAGIC_CRYPTO_HEADER: 'Crypto header',
-            self.QCOW2_EXT_MAGIC_BITMAPS: 'Bitmaps',
-            self.QCOW2_EXT_MAGIC_DATA_FILE: 'Data file',
+            cls.QCOW2_EXT_MAGIC_BACKING_FORMAT: 'Backing format',
+            cls.QCOW2_EXT_MAGIC_FEATURE_TABLE: 'Feature table',
+            cls.QCOW2_EXT_MAGIC_CRYPTO_HEADER: 'Crypto header',
+            cls.QCOW2_EXT_MAGIC_BITMAPS: 'Bitmaps',
+            cls.QCOW2_EXT_MAGIC_DATA_FILE: 'Data file',
          }.get(magic, 'Unknown')
diff mbox series

Patch

diff --git a/tests/qemu-iotests/031.out b/tests/qemu-iotests/031.out
index 5a4beda..966c8d9 100644
--- a/tests/qemu-iotests/031.out
+++ b/tests/qemu-iotests/031.out
@@ -24,7 +24,7 @@  autoclear_features        []
 refcount_order            4
 header_length             72
 
-Header extension:
+Header extension:         Unknown
 magic                     0x12345678
 length                    31
 data                      'This is a test header extension'
@@ -52,7 +52,7 @@  autoclear_features        []
 refcount_order            4
 header_length             72
 
-Header extension:
+Header extension:         Unknown
 magic                     0x12345678
 length                    31
 data                      'This is a test header extension'
@@ -80,12 +80,12 @@  autoclear_features        []
 refcount_order            4
 header_length             72
 
-Header extension:
+Header extension:         Backing format
 magic                     0xe2792aca
 length                    11
 data                      'host_device'
 
-Header extension:
+Header extension:         Unknown
 magic                     0x12345678
 length                    31
 data                      'This is a test header extension'
@@ -115,12 +115,12 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
 
-Header extension:
+Header extension:         Unknown
 magic                     0x12345678
 length                    31
 data                      'This is a test header extension'
@@ -148,12 +148,12 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
 
-Header extension:
+Header extension:         Unknown
 magic                     0x12345678
 length                    31
 data                      'This is a test header extension'
@@ -181,17 +181,17 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Backing format
 magic                     0xe2792aca
 length                    11
 data                      'host_device'
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
 
-Header extension:
+Header extension:         Unknown
 magic                     0x12345678
 length                    31
 data                      'This is a test header extension'
diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out
index e409acf..81a7366 100644
--- a/tests/qemu-iotests/036.out
+++ b/tests/qemu-iotests/036.out
@@ -24,7 +24,7 @@  Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 incompatible_features     []
 compatible_features       []
 autoclear_features        [63]
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
@@ -36,7 +36,7 @@  No errors were found on the image.
 incompatible_features     []
 compatible_features       []
 autoclear_features        []
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
index a51ad1b..7821b7f 100644
--- a/tests/qemu-iotests/061.out
+++ b/tests/qemu-iotests/061.out
@@ -24,7 +24,7 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
@@ -82,7 +82,7 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
@@ -138,7 +138,7 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
@@ -193,7 +193,7 @@  autoclear_features        [42]
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
@@ -262,7 +262,7 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
@@ -324,7 +324,7 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
@@ -353,7 +353,7 @@  autoclear_features        []
 refcount_order            4
 header_length             112
 
-Header extension:
+Header extension:         Feature table
 magic                     0x6803f857
 length                    336
 data                      <binary>
@@ -491,7 +491,7 @@  wrote 65536/65536 bytes at offset 2147483648
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 65536/65536 bytes at offset 3221225472
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-    (0.00/100%)
    (12.50/100%)
    (25.00/100%)
    (37.50/100%)
    (50.00/100%)
    (62.50/100%)
    (75.00/100%)
    (87.50/100%)
    (100.00/100%)
    (100.00/100%)
+    (0.00/100%)    (12.50/100%)    (25.00/100%)    (37.50/100%)    (50.00/100%)    (62.50/100%)    (75.00/100%)    (87.50/100%)    (100.00/100%)    (100.00/100%)
 No errors were found on the image.
 
 === Testing progress report with snapshot ===
@@ -506,7 +506,7 @@  wrote 65536/65536 bytes at offset 2147483648
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 65536/65536 bytes at offset 3221225472
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-    (0.00/100%)
    (6.25/100%)
    (12.50/100%)
    (18.75/100%)
    (25.00/100%)
    (31.25/100%)
    (37.50/100%)
    (43.75/100%)
    (50.00/100%)
    (56.25/100%)
    (62.50/100%)
    (68.75/100%)
    (75.00/100%)
    (81.25/100%)
    (87.50/100%)
    (93.75/100%)
    (100.00/100%)
    (100.00/100%)
+    (0.00/100%)    (6.25/100%)    (12.50/100%)    (18.75/100%)    (25.00/100%)    (31.25/100%)    (37.50/100%)    (43.75/100%)    (50.00/100%)    (56.25/100%)    (62.50/100%)    (68.75/100%)    (75.00/100%)    (81.25/100%)    (87.50/100%)    (93.75/100%)    (100.00/100%)    (100.00/100%)
 No errors were found on the image.
 
 === Testing version downgrade with external data file ===
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index 94a07b2..e824b09 100755
--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -6,19 +6,36 @@  import string
 
 class QcowHeaderExtension:
 
+    QCOW2_EXT_MAGIC_BACKING_FORMAT = 0xE2792ACA
+    QCOW2_EXT_MAGIC_FEATURE_TABLE = 0x6803f857
+    QCOW2_EXT_MAGIC_CRYPTO_HEADER = 0x0537be77
+    QCOW2_EXT_MAGIC_BITMAPS = 0x23852875
+    QCOW2_EXT_MAGIC_DATA_FILE = 0x44415441
+
     def __init__(self, magic, length, data):
         if length % 8 != 0:
             padding = 8 - (length % 8)
             data += b"\0" * padding
 
-        self.magic  = magic
+        self.magic = magic
         self.length = length
-        self.data   = data
+        self.data = data
+        self.name = self.extension_name(magic)
 
     @classmethod
     def create(cls, magic, data):
         return QcowHeaderExtension(magic, len(data), data)
 
+    def extension_name(self, magic):
+        return {
+            self.QCOW2_EXT_MAGIC_BACKING_FORMAT: 'Backing format',
+            self.QCOW2_EXT_MAGIC_FEATURE_TABLE: 'Feature table',
+            self.QCOW2_EXT_MAGIC_CRYPTO_HEADER: 'Crypto header',
+            self.QCOW2_EXT_MAGIC_BITMAPS: 'Bitmaps',
+            self.QCOW2_EXT_MAGIC_DATA_FILE: 'Data file',
+        }.get(magic, 'Unknown')
+
+
 class QcowHeader:
 
     uint32_t = 'I'
@@ -151,7 +168,7 @@  class QcowHeader:
             else:
                 data = "<binary>"
 
-            print("Header extension:")
+            print("%-25s %s" % ("Header extension:", ex.name))
             print("%-25s %#x" % ("magic", ex.magic))
             print("%-25s %d" % ("length", ex.length))
             print("%-25s %s" % ("data", data))