Skip to content

Commit

Permalink
analyze-migration.py: Remove trick on parsing ramblocks
Browse files Browse the repository at this point in the history
RAM_SAVE_FLAG_MEM_SIZE contains the total length of ramblock idstr to know
whether scanning of ramblocks is complete.  Drop the trick.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240117075848.139045-4-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
  • Loading branch information
xzpeter committed Jan 26, 2024
1 parent 92c8621 commit bf0d1b2
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions scripts/analyze-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,12 @@ def read(self):
addr &= ~(self.TARGET_PAGE_SIZE - 1)

if flags & self.RAM_SAVE_FLAG_MEM_SIZE:
while True:
total_length = addr
while total_length > 0:
namelen = self.file.read8()
# We assume that no RAM chunk is big enough to ever
# hit the first byte of the address, so when we see
# a zero here we know it has to be an address, not the
# length of the next block.
if namelen == 0:
self.file.file.seek(-1, 1)
break
self.name = self.file.readstr(len = namelen)
len = self.file.read64()
total_length -= len
self.sizeinfo[self.name] = '0x%016x' % len
if self.write_memory:
print(self.name)
Expand Down

0 comments on commit bf0d1b2

Please sign in to comment.