qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qcow2: QcowHeaderExtension print names for extension magics

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>

authored by

Vladimir Sementsov-Ogievskiy and committed by
Eric Blake
aef87784 a9e750e1

+36 -21
+11 -11
tests/qemu-iotests/031.out
··· 25 25 header_length 72 26 26 27 27 Header extension: 28 - magic 0x12345678 28 + magic 0x12345678 (<unknown>) 29 29 length 31 30 30 data 'This is a test header extension' 31 31 ··· 53 53 header_length 72 54 54 55 55 Header extension: 56 - magic 0x12345678 56 + magic 0x12345678 (<unknown>) 57 57 length 31 58 58 data 'This is a test header extension' 59 59 ··· 81 81 header_length 72 82 82 83 83 Header extension: 84 - magic 0xe2792aca 84 + magic 0xe2792aca (Backing format) 85 85 length 11 86 86 data 'host_device' 87 87 88 88 Header extension: 89 - magic 0x12345678 89 + magic 0x12345678 (<unknown>) 90 90 length 31 91 91 data 'This is a test header extension' 92 92 ··· 116 116 header_length 112 117 117 118 118 Header extension: 119 - magic 0x6803f857 119 + magic 0x6803f857 (Feature table) 120 120 length 336 121 121 data <binary> 122 122 123 123 Header extension: 124 - magic 0x12345678 124 + magic 0x12345678 (<unknown>) 125 125 length 31 126 126 data 'This is a test header extension' 127 127 ··· 149 149 header_length 112 150 150 151 151 Header extension: 152 - magic 0x6803f857 152 + magic 0x6803f857 (Feature table) 153 153 length 336 154 154 data <binary> 155 155 156 156 Header extension: 157 - magic 0x12345678 157 + magic 0x12345678 (<unknown>) 158 158 length 31 159 159 data 'This is a test header extension' 160 160 ··· 182 182 header_length 112 183 183 184 184 Header extension: 185 - magic 0xe2792aca 185 + magic 0xe2792aca (Backing format) 186 186 length 11 187 187 data 'host_device' 188 188 189 189 Header extension: 190 - magic 0x6803f857 190 + magic 0x6803f857 (Feature table) 191 191 length 336 192 192 data <binary> 193 193 194 194 Header extension: 195 - magic 0x12345678 195 + magic 0x12345678 (<unknown>) 196 196 length 31 197 197 data 'This is a test header extension' 198 198
+2 -2
tests/qemu-iotests/036.out
··· 25 25 compatible_features [] 26 26 autoclear_features [63] 27 27 Header extension: 28 - magic 0x6803f857 28 + magic 0x6803f857 (Feature table) 29 29 length 336 30 30 data <binary> 31 31 ··· 37 37 compatible_features [] 38 38 autoclear_features [] 39 39 Header extension: 40 - magic 0x6803f857 40 + magic 0x6803f857 (Feature table) 41 41 length 336 42 42 data <binary> 43 43
+7 -7
tests/qemu-iotests/061.out
··· 25 25 header_length 112 26 26 27 27 Header extension: 28 - magic 0x6803f857 28 + magic 0x6803f857 (Feature table) 29 29 length 336 30 30 data <binary> 31 31 ··· 83 83 header_length 112 84 84 85 85 Header extension: 86 - magic 0x6803f857 86 + magic 0x6803f857 (Feature table) 87 87 length 336 88 88 data <binary> 89 89 ··· 139 139 header_length 112 140 140 141 141 Header extension: 142 - magic 0x6803f857 142 + magic 0x6803f857 (Feature table) 143 143 length 336 144 144 data <binary> 145 145 ··· 194 194 header_length 112 195 195 196 196 Header extension: 197 - magic 0x6803f857 197 + magic 0x6803f857 (Feature table) 198 198 length 336 199 199 data <binary> 200 200 ··· 263 263 header_length 112 264 264 265 265 Header extension: 266 - magic 0x6803f857 266 + magic 0x6803f857 (Feature table) 267 267 length 336 268 268 data <binary> 269 269 ··· 325 325 header_length 112 326 326 327 327 Header extension: 328 - magic 0x6803f857 328 + magic 0x6803f857 (Feature table) 329 329 length 336 330 330 data <binary> 331 331 ··· 354 354 header_length 112 355 355 356 356 Header extension: 357 - magic 0x6803f857 357 + magic 0x6803f857 (Feature table) 358 358 length 336 359 359 data <binary> 360 360
+16 -1
tests/qemu-iotests/qcow2_format.py
··· 39 39 return str(bits) 40 40 41 41 42 + class Enum(Qcow2Field): 43 + 44 + def __str__(self): 45 + return f'{self.value:#x} ({self.mapping.get(self.value, "<unknown>")})' 46 + 47 + 42 48 class Qcow2StructMeta(type): 43 49 44 50 # Mapping from c types to python struct format ··· 99 105 100 106 class QcowHeaderExtension(Qcow2Struct): 101 107 108 + class Magic(Enum): 109 + mapping = { 110 + 0xe2792aca: 'Backing format', 111 + 0x6803f857: 'Feature table', 112 + 0x0537be77: 'Crypto header', 113 + 0x23852875: 'Bitmaps', 114 + 0x44415441: 'Data file' 115 + } 116 + 102 117 fields = ( 103 - ('u32', '{:#x}', 'magic'), 118 + ('u32', Magic, 'magic'), 104 119 ('u32', '{}', 'length') 105 120 # length bytes of data follows 106 121 # then padding to next multiply of 8