]> git.proxmox.com Git - mirror_qemu.git/commitdiff
analyze-migration.py: Remove trick on parsing ramblocks
authorPeter Xu <peterx@redhat.com>
Wed, 17 Jan 2024 07:58:48 +0000 (15:58 +0800)
committerPeter Xu <peterx@redhat.com>
Mon, 29 Jan 2024 03:02:12 +0000 (11:02 +0800)
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>
scripts/analyze-migration.py

index a39dfb8766b8af9392655c865980a106d4cc525a..8a254a5b6a2e2d311b9bfa4003af80b244fd94b3 100755 (executable)
@@ -151,17 +151,12 @@ class RamSection(object):
             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)