Skip to contentSkip to conversation

analyze-migration.py: Fix instance_id signedness

PATCH In review Fabiano Rosas 2 participants 2 messages Feb 21, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 analyze-migration.py: Fix instance_id signedness

The instance_id field is uint32_t in the migration code, however the script currently handles it as a signed integer:

$ ./scripts/analyze-migration.py -f mig
 Traceback (most recent call last):
   File "./scripts/analyze-migration.py", line 605, in <module>
     dump.read(dump_memory = args.memory)
   File "./scripts/analyze-migration.py", line 539, in read
     classdesc = self.section_classes[section_key]
 KeyError: ('spapr_iommu', -2147483648)
---
 scripts/analyze-migration.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/analyze-migration.py +3 -3
index b82a1b0c58..713f645eea 100755
@@ -40,8 +40,8 @@ def __init__(self, filename):
     def read64(self):
         return int.from_bytes(self.file.read(8), byteorder='big', signed=True)
 
-    def read32(self):
-        return int.from_bytes(self.file.read(4), byteorder='big', signed=True)
+    def read32(self, signed=True):
+        return int.from_bytes(self.file.read(4), byteorder='big', signed=signed)
 
     def read16(self):
         return int.from_bytes(self.file.read(2), byteorder='big', signed=True)
@@ -533,7 +533,7 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False):
             elif section_type == self.QEMU_VM_SECTION_START or section_type == self.QEMU_VM_SECTION_FULL:
                 section_id = file.read32()
                 name = file.readstr()
-                instance_id = file.read32()
+                instance_id = file.read32(signed=False)
                 version_id = file.read32()
                 section_key = (name, instance_id)
                 classdesc = self.section_classes[section_key]
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Fabiano Rosas

The instance_id field is uint32_t in the migration code, however the script currently handles it as a signed integer:

$ ./scripts/analyze-migration.py -f mig
  Traceback (most recent call last):
    File "./scripts/analyze-migration.py", line 605, in <module>
      dump.read(dump_memory = args.memory)
    File "./scripts/analyze-migration.py", line 539, in read
      classdesc = self.section_classes[section_key]
  KeyError: ('spapr_iommu', -2147483648)
Quoted 4 lines
---
  scripts/analyze-migration.py | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)