[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 09/12] qcow2_format.py: QcowHeaderExtension: add dump method
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v4 09/12] qcow2_format.py: QcowHeaderExtension: add dump method |
Date: |
Thu, 4 Jun 2020 20:41:32 +0300 |
Obviously, for-loop body in dump_extensions should be the dump method
of extension.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
tests/qemu-iotests/qcow2_format.py | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/tests/qemu-iotests/qcow2_format.py
b/tests/qemu-iotests/qcow2_format.py
index ceb09bde5a..ffc7c35b18 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -84,6 +84,17 @@ class QcowHeaderExtension:
self.length = length
self.data = data
+ def dump(self):
+ data = self.data[:self.length]
+ if all(c in string.printable.encode('ascii') for c in data):
+ data = f"'{ data.decode('ascii') }'"
+ else:
+ data = '<binary>'
+
+ print(f'{"magic":<25} {self.magic:#x}')
+ print(f'{"length":<25} {self.length}')
+ print(f'{"data":<25} {data}')
+
@classmethod
def create(cls, magic, data):
return QcowHeaderExtension(magic, len(data), data)
@@ -186,15 +197,6 @@ class QcowHeader(Qcow2Struct):
def dump_extensions(self):
for ex in self.extensions:
-
- data = ex.data[:ex.length]
- if all(c in string.printable.encode('ascii') for c in data):
- data = f"'{ data.decode('ascii') }'"
- else:
- data = '<binary>'
-
print('Header extension:')
- print(f'{"magic":<25} {ex.magic:#x}')
- print(f'{"length":<25} {ex.length}')
- print(f'{"data":<25} {data}')
+ ex.dump()
print()
--
2.21.0
- Re: [PATCH v4 07/12] qcow2_format.py: separate generic functionality of structure classes, (continued)
- [PATCH v4 05/12] qcow2_format.py: use modern string formatting, Vladimir Sementsov-Ogievskiy, 2020/06/04
- [PATCH v4 06/12] qcow2_format.py: use strings to specify c-type of struct fields, Vladimir Sementsov-Ogievskiy, 2020/06/04
- [PATCH v4 11/12] qcow2: QcowHeaderExtension print names for extension magics, Vladimir Sementsov-Ogievskiy, 2020/06/04
- [PATCH v4 09/12] qcow2_format.py: QcowHeaderExtension: add dump method,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v4 08/12] qcow2_format.py: add field-formatting class, Vladimir Sementsov-Ogievskiy, 2020/06/04
- [PATCH v4 12/12] qcow2_format.py: dump bitmaps header extension, Vladimir Sementsov-Ogievskiy, 2020/06/04
- [PATCH v4 10/12] qcow2_format: refactor QcowHeaderExtension as a subclass of Qcow2Struct, Vladimir Sementsov-Ogievskiy, 2020/06/04
- Re: [PATCH v4 00/12] iotests: Dump QCOW2 dirty bitmaps metadata, no-reply, 2020/06/04
- Re: [PATCH v4 00/12] iotests: Dump QCOW2 dirty bitmaps metadata, Eric Blake, 2020/06/05