[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.2.1 18/41] migration: Add more error handling to analyze-migra
From: |
Michael Tokarev |
Subject: |
[Stable-9.2.1 18/41] migration: Add more error handling to analyze-migration.py |
Date: |
Mon, 27 Jan 2025 17:17:32 +0300 |
From: Fabiano Rosas <farosas@suse.de>
The analyze-migration script was seen failing in s390x in misterious
ways. It seems we're reaching the VMSDFieldStruct constructor without
any fields, which would indicate an empty .subsection entry, a
VMSTATE_STRUCT with no fields or a vmsd with no fields. We don't have
any of those, at least not without the unmigratable flag set, so this
should never happen.
Add some debug statements so that we can see what's going on the next
time the issue happens.
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-Id: <20250109185249.23952-2-farosas@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
(cherry picked from commit 86bee9e0c761a3d0e67c43b44001fd752f894cb0)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py
index 8a254a5b6a..f2457b1dde 100755
--- a/scripts/analyze-migration.py
+++ b/scripts/analyze-migration.py
@@ -429,6 +429,9 @@ def __init__(self, desc, file):
super(VMSDFieldStruct, self).__init__(desc, file)
self.data = collections.OrderedDict()
+ if 'fields' not in self.desc['struct']:
+ raise Exception("No fields in struct. VMSD:\n%s" % self.desc)
+
# When we see compressed array elements, unfold them here
new_fields = []
for field in self.desc['struct']['fields']:
@@ -477,6 +480,10 @@ def read(self):
raise Exception("Subsection %s not found at offset %x" % (
subsection['vmsd_name'], self.file.tell()))
name = self.file.readstr()
version_id = self.file.read32()
+
+ if not subsection:
+ raise Exception("Empty description for subsection: %s" %
name)
+
self.data[name] = VMSDSection(self.file, version_id,
subsection, (name, 0))
self.data[name].read()
@@ -574,10 +581,13 @@ def __init__(self, filename):
}
self.filename = filename
self.vmsd_desc = None
+ self.vmsd_json = ""
- def read(self, desc_only = False, dump_memory = False, write_memory =
False):
+ def read(self, desc_only = False, dump_memory = False,
+ write_memory = False):
# Read in the whole file
file = MigrationFile(self.filename)
+ self.vmsd_json = file.read_migration_debug_json()
# File magic
data = file.read32()
@@ -635,9 +645,11 @@ def read(self, desc_only = False, dump_memory = False,
write_memory = False):
file.close()
def load_vmsd_json(self, file):
- vmsd_json = file.read_migration_debug_json()
- self.vmsd_desc = json.loads(vmsd_json,
object_pairs_hook=collections.OrderedDict)
+ self.vmsd_desc = json.loads(self.vmsd_json,
+ object_pairs_hook=collections.OrderedDict)
for device in self.vmsd_desc['devices']:
+ if 'fields' not in device:
+ raise Exception("vmstate for device %s has no fields" %
device['name'])
key = (device['name'], device['instance_id'])
value = ( VMSDSection, device )
self.section_classes[key] = value
@@ -666,31 +678,34 @@ def default(self, o):
jsonenc = JSONEncoder(indent=4, separators=(',', ': '))
-if args.extract:
- dump = MigrationDump(args.file)
+if not any([args.extract, args.dump == "state", args.dump == "desc"]):
+ raise Exception("Please specify either -x, -d state or -d desc")
- dump.read(desc_only = True)
- print("desc.json")
- f = open("desc.json", "w")
- f.truncate()
- f.write(jsonenc.encode(dump.vmsd_desc))
- f.close()
-
- dump.read(write_memory = True)
- dict = dump.getDict()
- print("state.json")
- f = open("state.json", "w")
- f.truncate()
- f.write(jsonenc.encode(dict))
- f.close()
-elif args.dump == "state":
- dump = MigrationDump(args.file)
- dump.read(dump_memory = args.memory)
- dict = dump.getDict()
- print(jsonenc.encode(dict))
-elif args.dump == "desc":
+try:
dump = MigrationDump(args.file)
- dump.read(desc_only = True)
- print(jsonenc.encode(dump.vmsd_desc))
-else:
- raise Exception("Please specify either -x, -d state or -d desc")
+
+ if args.extract:
+ dump.read(desc_only = True)
+
+ print("desc.json")
+ f = open("desc.json", "w")
+ f.truncate()
+ f.write(jsonenc.encode(dump.vmsd_desc))
+ f.close()
+
+ dump.read(write_memory = True)
+ dict = dump.getDict()
+ print("state.json")
+ f = open("state.json", "w")
+ f.truncate()
+ f.write(jsonenc.encode(dict))
+ f.close()
+ elif args.dump == "state":
+ dump.read(dump_memory = args.memory)
+ dict = dump.getDict()
+ print(jsonenc.encode(dict))
+ elif args.dump == "desc":
+ dump.read(desc_only = True)
+ print(jsonenc.encode(dump.vmsd_desc))
+except Exception:
+ raise Exception("Full JSON dump:\n%s", dump.vmsd_json)
--
2.39.5
- [Stable-9.2.1 10/41] hw/intc/riscv_aplic: Fix APLIC in_clrip and clripnum write emulation, (continued)
- [Stable-9.2.1 10/41] hw/intc/riscv_aplic: Fix APLIC in_clrip and clripnum write emulation, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 07/41] hw/intc/arm_gicv3_its: Zero initialize local DTEntry etc structs, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 13/41] docs: Correct '-runas' and '-fsdev/-virtfs proxy' indentation, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 15/41] target/i386/cpu: Fix notes for CPU models, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 12/41] target/loongarch: Use actual operand size with vbsrl check, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 17/41] migration/multifd: Fix compat with QEMU < 9.0, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 22/41] migration: Rename vmstate_info_nullptr, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 16/41] migration/multifd: Fix compile error caused by page_size usage, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 20/41] migration: Fix parsing of s390 stream, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 19/41] migration: Remove unused argument in vmsd_desc_field_end, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 18/41] migration: Add more error handling to analyze-migration.py,
Michael Tokarev <=
- [Stable-9.2.1 21/41] s390x: Fix CSS migration, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 24/41] migration: Fix arrays of pointers in JSON writer, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 02/41] tcg: Reset free_temps before tcg_optimize, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 23/41] migration: Dump correct JSON format for nullptr replacement, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 25/41] multifd: bugfix for migration using compression methods, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 39/41] make-release: only leave tarball of wrap-file subprojects, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 27/41] multifd: bugfix for incorrect migration data with qatzip compression, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 28/41] tests/functional/test_rx_gdbsim: Use stable URL for test_linux_sash, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 26/41] multifd: bugfix for incorrect migration data with QPL compression, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 38/41] hw/cxl: Fix msix_notify: Assertion `vector < dev->msix_entries_nr`, Michael Tokarev, 2025/01/27