Skip to contentSkip to conversation

scripts/migration: Fix analyze-migration.py and add a test

PATCH In review Fabiano Rosas 3 participants 19 messages Oct 9, 2023 – Oct 11, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover scripts/migration: Fix analyze-migration.py and add a test

was: [PATCH] qtest/migration: Add a test for the analyze-migration script
https://lore.kernel.org/r/[email protected]

The analyze-migration.py script should be kept in sync with the code that generates the migration stream. The addition/removal of sections and flags from the stream can cause the script to break. Issues when parsing the stream mostly manifest in the form of cryptic python errors such as:

Looking at git log, it seems that this is a fairly useful script for people debugging issues with the migration stream. Let's add a test for it to catch bugs early avoid keeping a broken script in the tree.

People suggested putting this in avocado or a dedicated shell script. I hope looking at the patches it becomes clear that it's best to have this along with migration-test. Mostly to avoid duplicating capabilities code and arch-specific flags.

CI run: https://gitlab.com/farosas/qemu/-/pipelines/1030789937

Fabiano Rosas (5):
migration: Fix analyze-migration.py 'configuration' parsing
migration: Add capability parsing to analyze-migration.py
migration: Fix analyze-migration.py when ignore-shared is used
migration: Fix analyze-migration read operation signedness tests/qtest/migration: Add a test for the analyze-migration script

Nikolay Borisov (1):
migration: Add the configuration vmstate to the json writer

 migration/migration.c        |  1 +
 migration/savevm.c           | 20 ++++++++---
 scripts/analyze-migration.py | 67 ++++++++++++++++++++++++++++++++----
 tests/qtest/meson.build      |  2 ++
 tests/qtest/migration-test.c | 60 ++++++++++++++++++++++++++++++++
 5 files changed, 139 insertions(+), 11 deletions(-)
Signature · 1 line
2.35.3
#1 lore raw

PATCH v2 1/6 migration: Add the configuration vmstate to the json writer

From: Nikolay Borisov <[email protected]>

Make the migration json writer part of MigrationState struct, allowing the 'configuration' object be serialized to json.

This will facilitate the parsing of the 'configuration' object in the next patch that fixes analyze-migration.py for arm.

---
farosas: rewrote the commit message. The previous one was tied to fixed-ram.

---
 migration/migration.c |  1 +
 migration/savevm.c    | 20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
migration/migration.c +1 -0
index 585d3c8f55..dde8471f83 100644
@@ -1430,6 +1430,7 @@ int migrate_init(MigrationState *s, Error **errp)
     error_free(s->error);
     s->error = NULL;
     s->hostname = NULL;
+    s->vmdesc = NULL;
 
     migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);
 
migration/savevm.c +16 -4
index 60eec7c31f..5343cbc234 100644
@@ -1217,13 +1217,27 @@ void qemu_savevm_non_migratable_list(strList **reasons)
 
 void qemu_savevm_state_header(QEMUFile *f)
 {
+    MigrationState *s = migrate_get_current();
+
+    s->vmdesc = json_writer_new(false);
+
     trace_savevm_state_header();
     qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
     qemu_put_be32(f, QEMU_VM_FILE_VERSION);
 
-    if (migrate_get_current()->send_configuration) {
+    if (s->send_configuration) {
         qemu_put_byte(f, QEMU_VM_CONFIGURATION);
-        vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0);
+
+        /*
+         * This starts the main json object and is paired with the
+         * json_writer_end_object in
+         * qemu_savevm_state_complete_precopy_non_iterable
+         */
+        json_writer_start_object(s->vmdesc, NULL);
+
+        json_writer_start_object(s->vmdesc, "configuration");
+        vmstate_save_state(f, &vmstate_configuration, &savevm_state, s->vmdesc);
+        json_writer_end_object(s->vmdesc);
     }
 }
 
@@ -1272,8 +1286,6 @@ void qemu_savevm_state_setup(QEMUFile *f)
     Error *local_err = NULL;
     int ret;
 
-    ms->vmdesc = json_writer_new(false);
-    json_writer_start_object(ms->vmdesc, NULL);
     json_writer_int64(ms->vmdesc, "page_size", qemu_target_page_size());
     json_writer_start_array(ms->vmdesc, "devices");
 
Signature · 1 line
2.35.3
Reviewed-by on v2 1/6
#2 lore raw

Re: [PATCH v2 1/6] migration: Add the configuration vmstate to the json writer

Quoted 10 lines · Fabiano Rosas

From: Nikolay Borisov <[email protected]>

Make the migration json writer part of MigrationState struct, allowing the 'configuration' object be serialized to json.

This will facilitate the parsing of the 'configuration' object in the next patch that fixes analyze-migration.py for arm.

queued.

migration/savevm.c void qemu_savevm_non_migratable_list(strList **reasons) · line 1236

Quoted 9 lines
         qemu_put_byte(f, QEMU_VM_CONFIGURATION);
migration/savevm.c +7 -1
-        vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0);
+
+        /*
+         * This starts the main json object and is paired with the
+         * json_writer_end_object in
+         * qemu_savevm_state_complete_precopy_non_iterable
+         */
+        json_writer_start_object(s->vmdesc, NULL);

This don't depend of this patch, but it is ugly as hell.

Can we create:

json_write_start_main_object(s->vmdesc);

(equivalent for end)

And forbid json_writer_start_object() for taking a NULL parameter?

Later, Juan.

#3 lore raw

Re: [PATCH v2 1/6] migration: Add the configuration vmstate to the json writer

Quoted 30 lines · Juan Quintela
Quoted 10 lines · Fabiano Rosas

From: Nikolay Borisov <[email protected]>

Make the migration json writer part of MigrationState struct, allowing the 'configuration' object be serialized to json.

This will facilitate the parsing of the 'configuration' object in the next patch that fixes analyze-migration.py for arm.

queued.

migration/savevm.c void qemu_savevm_non_migratable_list(strList **reasons) · line 1236

Quoted 9 lines
         qemu_put_byte(f, QEMU_VM_CONFIGURATION);
migration/savevm.c +7 -1
-        vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0);
+
+        /*
+         * This starts the main json object and is paired with the
+         * json_writer_end_object in
+         * qemu_savevm_state_complete_precopy_non_iterable
+         */
+        json_writer_start_object(s->vmdesc, NULL);

This don't depend of this patch, but it is ugly as hell.

Can we create:

Quoted 7 lines

json_write_start_main_object(s->vmdesc);

(equivalent for end)

And forbid json_writer_start_object() for taking a NULL parameter?

Later, Juan.

Yep, I'll look into it.

#4 lore raw

PATCH v2 2/6 migration: Fix analyze-migration.py 'configuration' parsing

In reply to Fabiano Rosas

The 'configuration' state subsections are currently not being parsed and the script fails when analyzing an aarch64 stream:

Traceback (most recent call last):
File "./scripts/analyze-migration.py", line 625, in <module>
dump.read(dump_memory = args.memory)
File "./scripts/analyze-migration.py", line 571, in read
raise Exception("Unknown section type: %d" % section_type)
Exception: Unknown section type: 5

---
 scripts/analyze-migration.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
scripts/analyze-migration.py +14 -4
index 082424558b..24687db497 100755
@@ -261,12 +261,21 @@ def getDict(self):
 
 
 class ConfigurationSection(object):
-    def __init__(self, file):
+    def __init__(self, file, desc):
         self.file = file
+        self.desc = desc
 
     def read(self):
-        name_len = self.file.read32()
-        name = self.file.readstr(len = name_len)
+        if self.desc:
+            version_id = self.desc['version']
+            section = VMSDSection(self.file, version_id, self.desc,
+                                  'configuration')
+            section.read()
+        else:
+            # backward compatibility for older streams that don't have
+            # the configuration section in the json
+            name_len = self.file.read32()
+            name = self.file.readstr(len = name_len)
 
 class VMSDFieldGeneric(object):
     def __init__(self, desc, file):
@@ -532,7 +541,8 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False):
             if section_type == self.QEMU_VM_EOF:
                 break
             elif section_type == self.QEMU_VM_CONFIGURATION:
-                section = ConfigurationSection(file)
+                config_desc = self.vmsd_desc.get('configuration')
+                section = ConfigurationSection(file, config_desc)
                 section.read()
             elif section_type == self.QEMU_VM_SECTION_START or section_type == self.QEMU_VM_SECTION_FULL:
                 section_id = file.read32()
Signature · 1 line
2.35.3
Reviewed-by on v2 2/6
#5 lore raw

Re: [PATCH v2 2/6] migration: Fix analyze-migration.py 'configuration' parsing

Quoted 11 lines · Fabiano Rosas

The 'configuration' state subsections are currently not being parsed and the script fails when analyzing an aarch64 stream:

Traceback (most recent call last):
File "./scripts/analyze-migration.py", line 625, in <module>
dump.read(dump_memory = args.memory)
File "./scripts/analyze-migration.py", line 571, in read
raise Exception("Unknown section type: %d" % section_type)
Exception: Unknown section type: 5

#6 lore raw

PATCH v2 3/6 migration: Add capability parsing to analyze-migration.py

In reply to Fabiano Rosas

The script is broken when the configuration/capabilities section is present. Add support for parsing the capabilities so we can fix it in the next patch.

---
 scripts/analyze-migration.py | 38 ++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
scripts/analyze-migration.py +38 -0
index 24687db497..c700fed64d 100755
@@ -264,6 +264,24 @@ class ConfigurationSection(object):
     def __init__(self, file, desc):
         self.file = file
         self.desc = desc
+        self.caps = []
+
+    def parse_capabilities(self, vmsd_caps):
+        if not vmsd_caps:
+            return
+
+        ncaps = vmsd_caps.data['caps_count'].data
+        self.caps = vmsd_caps.data['capabilities']
+
+        if type(self.caps) != list:
+            self.caps = [self.caps]
+
+        if len(self.caps) != ncaps:
+            raise Exception("Number of capabilities doesn't match "
+                            "caps_count field")
+
+    def has_capability(self, cap):
+        return any([str(c) == cap for c in self.caps])
 
     def read(self):
         if self.desc:
@@ -271,6 +289,8 @@ def read(self):
             section = VMSDSection(self.file, version_id, self.desc,
                                   'configuration')
             section.read()
+            self.parse_capabilities(
+                section.data.get("configuration/capabilities"))
         else:
             # backward compatibility for older streams that don't have
             # the configuration section in the json
@@ -297,6 +317,23 @@ def read(self):
         self.data = self.file.readvar(size)
         return self.data
 
+class VMSDFieldCap(object):
+    def __init__(self, desc, file):
+        self.file = file
+        self.desc = desc
+        self.data = ""
+
+    def __repr__(self):
+        return self.data
+
+    def __str__(self):
+        return self.data
+
+    def read(self):
+        len = self.file.read8()
+        self.data = self.file.readstr(len)
+
+
 class VMSDFieldInt(VMSDFieldGeneric):
     def __init__(self, desc, file):
         super(VMSDFieldInt, self).__init__(desc, file)
@@ -471,6 +508,7 @@ def getDict(self):
     "unused_buffer" : VMSDFieldGeneric,
     "bitmap" : VMSDFieldGeneric,
     "struct" : VMSDFieldStruct,
+    "capability": VMSDFieldCap,
     "unknown" : VMSDFieldGeneric,
 }
 
Signature · 1 line
2.35.3
#8 lore raw

PATCH v2 4/6 migration: Fix analyze-migration.py when ignore-shared is used

In reply to Fabiano Rosas

The script is currently broken when the x-ignore-shared capability is used:

Traceback (most recent call last):
File "./scripts/analyze-migration.py", line 656, in <module>
dump.read(dump_memory = args.memory)
File "./scripts/analyze-migration.py", line 593, in read
section.read()
File "./scripts/analyze-migration.py", line 163, in read
self.name = self.file.readstr(len = namelen)
File "./scripts/analyze-migration.py", line 53, in readstr
return self.readvar(len).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 55: invalid start byte

We're currently adding data to the middle of the ram section depending on the presence of the capability. As a consequence, any code loading the ram section needs to know about capabilities so it can interpret the stream.

Skip the byte that's added when x-ignore-shared is used to fix the script.

---
 scripts/analyze-migration.py | 5 +++++
 1 file changed, 5 insertions(+)
scripts/analyze-migration.py +5 -0
index c700fed64d..56ab04dd2d 100755
@@ -123,6 +123,7 @@ def __init__(self, file, version_id, ramargs, section_key):
         self.TARGET_PAGE_SIZE = ramargs['page_size']
         self.dump_memory = ramargs['dump_memory']
         self.write_memory = ramargs['write_memory']
+        self.ignore_shared = ramargs['ignore_shared']
         self.sizeinfo = collections.OrderedDict()
         self.data = collections.OrderedDict()
         self.data['section sizes'] = self.sizeinfo
@@ -169,6 +170,8 @@ def read(self):
                         f.truncate(0)
                         f.truncate(len)
                         self.files[self.name] = f
+                    if self.ignore_shared:
+                        mr_addr = self.file.read64()
                 flags &= ~self.RAM_SAVE_FLAG_MEM_SIZE
 
             if flags & self.RAM_SAVE_FLAG_COMPRESS:
@@ -572,6 +575,7 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False):
         ramargs['page_size'] = self.vmsd_desc['page_size']
         ramargs['dump_memory'] = dump_memory
         ramargs['write_memory'] = write_memory
+        ramargs['ignore_shared'] = False
         self.section_classes[('ram',0)][1] = ramargs
 
         while True:
@@ -582,6 +586,7 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False):
                 config_desc = self.vmsd_desc.get('configuration')
                 section = ConfigurationSection(file, config_desc)
                 section.read()
+                ramargs['ignore_shared'] = section.has_capability('x-ignore-shared')
             elif section_type == self.QEMU_VM_SECTION_START or section_type == self.QEMU_VM_SECTION_FULL:
                 section_id = file.read32()
                 name = file.readstr()
Signature · 1 line
2.35.3
Reviewed-by on v2 4/6
#9 lore raw

Re: [PATCH v2 4/6] migration: Fix analyze-migration.py when ignore-shared is used

Quoted 19 lines · Fabiano Rosas

The script is currently broken when the x-ignore-shared capability is used:

Traceback (most recent call last):
File "./scripts/analyze-migration.py", line 656, in <module>
dump.read(dump_memory = args.memory)
File "./scripts/analyze-migration.py", line 593, in read
section.read()
File "./scripts/analyze-migration.py", line 163, in read
self.name = self.file.readstr(len = namelen)
File "./scripts/analyze-migration.py", line 53, in readstr
return self.readvar(len).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 55: invalid start byte

We're currently adding data to the middle of the ram section depending on the presence of the capability. As a consequence, any code loading the ram section needs to know about capabilities so it can interpret the stream.

Quoted 4 lines

Skip the byte that's added when x-ignore-shared is used to fix the script.

scripts/analyze-migration.py def read(self, desc_only = False, dump_memory = False, write_memory = False): · line 589

Quoted 5 lines
scripts/analyze-migration.py +1 -0
@@ -582,6 +586,7 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False):
                 config_desc = self.vmsd_desc.get('configuration')
                 section = ConfigurationSection(file, config_desc)
                 section.read()
+                ramargs['ignore_shared'] = section.has_capability('x-ignore-shared')

should we consider s/x-ignore-shared/ignore-shared/?

Quoted 3 lines
scripts/analyze-migration.py +0 -0
             elif section_type == self.QEMU_VM_SECTION_START or section_type == self.QEMU_VM_SECTION_FULL:
                 section_id = file.read32()
                 name = file.readstr()
#10 lore raw

Re: [PATCH v2 4/6] migration: Fix analyze-migration.py when ignore-shared is used

Quoted 27 lines · Juan Quintela
Quoted 19 lines · Fabiano Rosas

The script is currently broken when the x-ignore-shared capability is used:

Traceback (most recent call last):
File "./scripts/analyze-migration.py", line 656, in <module>
dump.read(dump_memory = args.memory)
File "./scripts/analyze-migration.py", line 593, in read
section.read()
File "./scripts/analyze-migration.py", line 163, in read
self.name = self.file.readstr(len = namelen)
File "./scripts/analyze-migration.py", line 53, in readstr
return self.readvar(len).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 55: invalid start byte

We're currently adding data to the middle of the ram section depending on the presence of the capability. As a consequence, any code loading the ram section needs to know about capabilities so it can interpret the stream.

Quoted 4 lines

Skip the byte that's added when x-ignore-shared is used to fix the script.

Quoted 8 lines

scripts/analyze-migration.py def read(self, desc_only = False, dump_memory = False, write_memory = False): · line 589

Quoted 5 lines
scripts/analyze-migration.py +1 -0
@@ -582,6 +586,7 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False):
                 config_desc = self.vmsd_desc.get('configuration')
                 section = ConfigurationSection(file, config_desc)
                 section.read()
+                ramargs['ignore_shared'] = section.has_capability('x-ignore-shared')

should we consider s/x-ignore-shared/ignore-shared/?

We can consider s/ignore-shared/x-ignore-shared/ if that's what you mean. The way you suggested doesn't work because the cap name comes from QEMU with the "x-" part in it.

If you meant filtering the x out when parsing the capabilities in this script, I think that would cause a sort of a UX issue because we need to use x-ignore-shared to set the cap in QMP/HMP.

#11 lore raw

Re: [PATCH v2 4/6] migration: Fix analyze-migration.py when ignore-shared is used

Quoted 38 lines · Fabiano Rosas
Quoted 27 lines · Juan Quintela
Quoted 19 lines · Fabiano Rosas

The script is currently broken when the x-ignore-shared capability is used:

Traceback (most recent call last):
File "./scripts/analyze-migration.py", line 656, in <module>
dump.read(dump_memory = args.memory)
File "./scripts/analyze-migration.py", line 593, in read
section.read()
File "./scripts/analyze-migration.py", line 163, in read
self.name = self.file.readstr(len = namelen)
File "./scripts/analyze-migration.py", line 53, in readstr
return self.readvar(len).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 55: invalid start byte

We're currently adding data to the middle of the ram section depending on the presence of the capability. As a consequence, any code loading the ram section needs to know about capabilities so it can interpret the stream.

Quoted 4 lines

Skip the byte that's added when x-ignore-shared is used to fix the script.

Quoted 8 lines

scripts/analyze-migration.py def read(self, desc_only = False, dump_memory = False, write_memory = False): · line 589

Quoted 5 lines
scripts/analyze-migration.py +1 -0
@@ -582,6 +586,7 @@ def read(self, desc_only = False, dump_memory = False, write_memory = False):
                 config_desc = self.vmsd_desc.get('configuration')
                 section = ConfigurationSection(file, config_desc)
                 section.read()
+                ramargs['ignore_shared'] = section.has_capability('x-ignore-shared')

should we consider s/x-ignore-shared/ignore-shared/?

Quoted 7 lines

We can consider s/ignore-shared/x-ignore-shared/ if that's what you mean. The way you suggested doesn't work because the cap name comes from QEMU with the "x-" part in it.

If you meant filtering the x out when parsing the capabilities in this script, I think that would cause a sort of a UX issue because we need to use x-ignore-shared to set the cap in QMP/HMP.

No.

I mean if we should start supporting ignore-shared.

Later, Juan.

#12 lore raw

PATCH v2 5/6 migration: Fix analyze-migration read operation signedness

In reply to Fabiano Rosas

The migration code uses unsigned values for 16, 32 and 64-bit operations. Fix the script to do the same.

This was causing an issue when parsing the migration stream generated on the ppc64 target because one of instance_ids was larger than the 32bit signed maximum:

Traceback (most recent call last):
File "/home/fabiano/kvm/qemu/build/scripts/analyze-migration.py", line 658, in <module>
dump.read(dump_memory = args.memory)
File "/home/fabiano/kvm/qemu/build/scripts/analyze-migration.py", line 592, 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 56ab04dd2d..de506cb8bf 100755
@@ -38,13 +38,13 @@ def __init__(self, filename):
         self.file = open(self.filename, "rb")
 
     def read64(self):
-        return int.from_bytes(self.file.read(8), byteorder='big', signed=True)
+        return int.from_bytes(self.file.read(8), byteorder='big', signed=False)
 
     def read32(self):
-        return int.from_bytes(self.file.read(4), byteorder='big', signed=True)
+        return int.from_bytes(self.file.read(4), byteorder='big', signed=False)
 
     def read16(self):
-        return int.from_bytes(self.file.read(2), byteorder='big', signed=True)
+        return int.from_bytes(self.file.read(2), byteorder='big', signed=False)
 
     def read8(self):
         return int.from_bytes(self.file.read(1), byteorder='big', signed=True)
Signature · 1 line
2.35.3
Reviewed-by on v2 5/6
#13 lore raw

Re: [PATCH v2 5/6] migration: Fix analyze-migration read operation signedness

Quoted 7 lines · Fabiano Rosas

The migration code uses unsigned values for 16, 32 and 64-bit operations. Fix the script to do the same.

This was causing an issue when parsing the migration stream generated on the ppc64 target because one of instance_ids was larger than the 32bit signed maximum:

Quoted 8 lines

Traceback (most recent call last):
File "/home/fabiano/kvm/qemu/build/scripts/analyze-migration.py", line 658, in <module>
dump.read(dump_memory = args.memory)
File "/home/fabiano/kvm/qemu/build/scripts/analyze-migration.py", line 592, in read
classdesc = self.section_classes[section_key]
KeyError: ('spapr_iommu', -2147483648)

#14 lore raw

PATCH v2 6/6 tests/qtest/migration: Add a test for the analyze-migration script

In reply to Fabiano Rosas

Add a smoke test that migrates to a file and gives it to the script. It should catch the most annoying errors such as changes in the ram flags.

After code has been merged it becomes way harder to figure out what is causing the script to fail, the person making the change is the most likely to know right away what the problem is.

---
 tests/qtest/meson.build      |  2 ++
 tests/qtest/migration-test.c | 60 ++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
tests/qtest/meson.build +2 -0
index 1fba07f4ed..5e82eccb62 100644
@@ -356,6 +356,8 @@ foreach dir : target_dirs
     test_deps += [qsd]
   endif
 
+  qtest_env.set('PYTHON', python.full_path())
+
   foreach test : target_qtests
     # Executables are shared across targets, declare them only the first time we
     # encounter them
tests/qtest/migration-test.c +60 -0

78 lines not on this page · raw message

Signature · 1 line
2.35.3
Acked-by on v2 6/6
#15 lore raw

Re: [PATCH v2 6/6] tests/qtest/migration: Add a test for the analyze-migration script

Quoted 8 lines · Fabiano Rosas

Add a smoke test that migrates to a file and gives it to the script. It should catch the most annoying errors such as changes in the ram flags.

After code has been merged it becomes way harder to figure out what is causing the script to fail, the person making the change is the most likely to know right away what the problem is.

Quoted 5 lines
---
  tests/qtest/meson.build      |  2 ++
  tests/qtest/migration-test.c | 60 ++++++++++++++++++++++++++++++++++++
  2 files changed, 62 insertions(+)
Reviewed-by on v2 6/6
#16 lore raw

Re: [PATCH v2 6/6] tests/qtest/migration: Add a test for the analyze-migration script

In reply to Fabiano Rosas
Quoted 9 lines · Fabiano Rosas

Add a smoke test that migrates to a file and gives it to the script. It should catch the most annoying errors such as changes in the ram flags.

After code has been merged it becomes way harder to figure out what is causing the script to fail, the person making the change is the most likely to know right away what the problem is.

Quoted 10 lines
---
 tests/qtest/meson.build      |  2 ++
 tests/qtest/migration-test.c | 60 ++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
tests/qtest/meson.build +0 -0
index 1fba07f4ed..5e82eccb62 100644

tests/qtest/meson.build foreach dir : target_dirs · line 360

Quoted 5 lines
tests/qtest/meson.build +2 -0
@@ -356,6 +356,8 @@ foreach dir : target_dirs
     test_deps += [qsd]
   endif
 
+  qtest_env.set('PYTHON', python.full_path())
+

I accept it, but I think that this part of the test should be in a different patch so meson people could comment O:-)

tests/qtest/meson.build foreach dir : target_dirs · line 362

Quoted 2 lines
tests/qtest/meson.build +2 -0
+
+    pid = fork();

live and see, g_test and qemu don't have a function to execute a script? Wow.

#17 lore raw

Re: [PATCH v2 6/6] tests/qtest/migration: Add a test for the analyze-migration script

Quoted 33 lines · Juan Quintela
Quoted 9 lines · Fabiano Rosas

Add a smoke test that migrates to a file and gives it to the script. It should catch the most annoying errors such as changes in the ram flags.

After code has been merged it becomes way harder to figure out what is causing the script to fail, the person making the change is the most likely to know right away what the problem is.

Quoted 10 lines
---
 tests/qtest/meson.build      |  2 ++
 tests/qtest/migration-test.c | 60 ++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
tests/qtest/meson.build +0 -0
index 1fba07f4ed..5e82eccb62 100644

tests/qtest/meson.build foreach dir : target_dirs · line 360

Quoted 5 lines
tests/qtest/meson.build +2 -0
@@ -356,6 +356,8 @@ foreach dir : target_dirs
     test_deps += [qsd]
   endif
 
+  qtest_env.set('PYTHON', python.full_path())
+

I accept it, but I think that this part of the test should be in a different patch so meson people could comment O:-)

Quoted 4 lines

tests/qtest/meson.build foreach dir : target_dirs · line 362

Quoted 2 lines
tests/qtest/meson.build +2 -0
+
+    pid = fork();

live and see, g_test and qemu don't have a function to execute a script?

gtest has one to execute a _function_ in a fork, but fork+exec no.

#18 lore raw
In reply to Fabiano Rosas
Quoted 8 lines · Fabiano Rosas

was: [PATCH] qtest/migration: Add a test for the analyze-migration script
https://lore.kernel.org/r/[email protected]

The analyze-migration.py script should be kept in sync with the code that generates the migration stream. The addition/removal of sections and flags from the stream can cause the script to break. Issues when parsing the stream mostly manifest in the form of cryptic python errors such as:

Well, not _that_ cryptic. =)

I meant to add this:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 55:
invalid start byte