From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Fabiano Rosas <farosas@suse.de>
Cc: Peter Xu <peterx@redhat.com>, John Snow <jsnow@redhat.com>
Subject: [PATCH 4/4] tests/functional: Test with scripts/vmstate-static-checker.py
Date: Tue, 29 Apr 2025 17:21:41 +0200 [thread overview]
Message-ID: <20250429152141.294380-5-thuth@redhat.com> (raw)
In-Reply-To: <20250429152141.294380-1-thuth@redhat.com>
From: Thomas Huth <thuth@redhat.com>
We've got this nice vmstate-static-checker.py script that can help
to detect screw-ups in the migration states. Unfortunately, it's
currently only run manually, so there could be regressions that nobody
notices immediately. Let's run it from a functional test automatically
so that we got at least a basic coverage in each CI run.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
MAINTAINERS | 1 +
tests/functional/meson.build | 13 +++++++-
tests/functional/test_vmstate.py | 56 ++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 1 deletion(-)
create mode 100755 tests/functional/test_vmstate.py
diff --git a/MAINTAINERS b/MAINTAINERS
index 65fb61844b3..6a8d81458ad 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3525,6 +3525,7 @@ F: migration/
F: scripts/vmstate-static-checker.py
F: tests/data/vmstate-static-checker/
F: tests/functional/test_migration.py
+F: tests/functional/test_vmstate.py
F: tests/qtest/migration/
F: tests/qtest/migration-*
F: docs/devel/migration/
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index b317ad42c5a..9f339e626f6 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -76,6 +76,7 @@ tests_generic_bsduser = [
tests_aarch64_system_quick = [
'migration',
+ 'vmstate',
]
tests_aarch64_system_thorough = [
@@ -164,6 +165,10 @@ tests_loongarch64_system_thorough = [
'loongarch64_virt',
]
+tests_m68k_system_quick = [
+ 'vmstate',
+]
+
tests_m68k_system_thorough = [
'm68k_mcf5208evb',
'm68k_nextcube',
@@ -230,6 +235,7 @@ tests_ppc_system_thorough = [
tests_ppc64_system_quick = [
'migration',
+ 'vmstate',
]
tests_ppc64_system_thorough = [
@@ -265,6 +271,10 @@ tests_rx_system_thorough = [
'rx_gdbsim',
]
+tests_s390x_system_quick = [
+ 'vmstate',
+]
+
tests_s390x_system_thorough = [
's390x_ccw_virtio',
's390x_replay',
@@ -305,8 +315,9 @@ tests_x86_64_system_quick = [
'migration',
'pc_cpu_hotplug_props',
'virtio_version',
- 'x86_cpu_model_versions',
+ 'vmstate',
'vnc',
+ 'x86_cpu_model_versions',
]
tests_x86_64_system_thorough = [
diff --git a/tests/functional/test_vmstate.py b/tests/functional/test_vmstate.py
new file mode 100755
index 00000000000..3ba56d580db
--- /dev/null
+++ b/tests/functional/test_vmstate.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# This test runs the vmstate-static-checker script with the current QEMU
+
+import subprocess
+
+from qemu_test import QemuSystemTest
+
+
+class VmStateTest(QemuSystemTest):
+
+ def test_vmstate(self):
+ target_machine = {
+ 'aarch64': 'virt-7.2',
+ 'm68k': 'virt-7.2',
+ 'ppc64': 'pseries-7.2',
+ 's390x': 's390-ccw-virtio-7.2',
+ 'x86_64': 'pc-q35-7.2',
+ }
+ self.set_machine(target_machine[self.arch])
+
+ # Run QEMU to get the current vmstate json file:
+ dst_json = self.scratch_file('dest.json')
+ self.log.info('Dumping vmstate from ' + self.qemu_bin)
+ cp = subprocess.run([self.qemu_bin, '-nodefaults',
+ '-M', target_machine[self.arch],
+ '-dump-vmstate', dst_json],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ text=True)
+ if cp.returncode != 0:
+ self.fail('Running QEMU failed:\n' + cp.stdout)
+ if cp.stdout:
+ self.log.info('QEMU output: ' + cp.stdout)
+
+ # Check whether the old vmstate json file is still compatible:
+ src_json = self.data_file('..', 'data', 'vmstate-static-checker',
+ self.arch,
+ target_machine[self.arch] + '.json')
+ vmstate_checker = self.data_file('..', '..', 'scripts',
+ 'vmstate-static-checker.py')
+ self.log.info('Comparing vmstate with ' + src_json)
+ cp = subprocess.run([vmstate_checker, '-s', src_json, '-d', dst_json],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ text=True)
+ if cp.returncode != 0:
+ self.fail('Running vmstate-static-checker failed:\n' + cp.stdout)
+ if cp.stdout:
+ self.log.warning('vmstate-static-checker output: ' + cp.stdout)
+
+
+if __name__ == '__main__':
+ QemuSystemTest.main()
--
2.49.0
next prev parent reply other threads:[~2025-04-29 15:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 15:21 [PATCH 0/4] Test vmstate with scripts/vmstate-static-checker.py Thomas Huth
2025-04-29 15:21 ` [PATCH 1/4] tests/vmstate-static-checker-data: Remove old dump files Thomas Huth
2025-04-29 15:29 ` Philippe Mathieu-Daudé
2025-04-29 22:13 ` Peter Xu
2025-04-30 10:55 ` Thomas Huth
2025-04-29 15:21 ` [PATCH 2/4] scripts/vmstate-static-checker.py: Allow new name for ghes_addr_le field Thomas Huth
2025-04-29 22:16 ` Peter Xu
2025-04-29 15:21 ` [PATCH 3/4] tests/data/vmstate-static-checker: Add dump files from QEMU 7.2.17 Thomas Huth
2025-04-29 22:30 ` Peter Xu
2025-04-30 11:13 ` Thomas Huth
2025-04-30 15:46 ` Peter Xu
2025-04-29 15:21 ` Thomas Huth [this message]
2025-04-30 16:10 ` [PATCH 4/4] tests/functional: Test with scripts/vmstate-static-checker.py Pierrick Bouvier
2025-05-01 14:28 ` Peter Xu
2025-05-01 15:58 ` Pierrick Bouvier
2025-05-06 22:05 ` Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250429152141.294380-5-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=farosas@suse.de \
--cc=jsnow@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.