def read_bitmap_directory(self, fd):
fd.seek(self.bitmap_directory_offset)
self.bitmap_directory = \
- [Qcow2BitmapDirEntry(fd) for _ in range(self.nb_bitmaps)]
+ [Qcow2BitmapDirEntry(fd, cluster_size=self.cluster_size)
+ for _ in range(self.nb_bitmaps)]
Better to inline the bitmap directory loading code into __init__:
Benefits:
1. Less code. read_bitmap_directory() is very small, used only in
__init__ and just not needed as a separate method. __init__ is very
small and simple too, so it's not a problem.
2. no need of extra self.cluster_size variable (you can use
cluster_size parameter directly)
3. keep all fd.seek logic in one method
but it's not about this patch.
@@ -244,7 +249,6 @@ class QcowHeaderExtension(Qcow2Struct):
data_str = '<binary>'
self.data_str = data_str
-
Unrelated style-fixing chunk, please don't do so.
with it dropped:
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
def dump(self):
super().dump()
@@ -316,7 +320,7 @@ class QcowHeader(Qcow2Struct):
end = self.cluster_size
while fd.tell() < end:
- ext = QcowHeaderExtension(fd=fd)
+ ext = QcowHeaderExtension(fd=fd,
cluster_size=self.cluster_size)
if ext.magic == 0:
break
else: