Test vmstate with scripts/vmstate-static-checker.py
Subsystems (2)
cover Test vmstate with scripts/vmstate-static-checker.py
This set of patches adds an automatic test of the vmstate via the scripts/vmstate-static-checker.py script. For this we need some reference files from an older version of QEMU. There are already some files available in tests/vmstate-static-checker-data/ but they are of no use anymore since they have been taken from machines that have already been removed a long time ago (and thus these files now get removed, too). I chose to use QEMU 7.2 for the reference files instead since this is a long term support release that is still actively being maintained, so we certainly want to make sure that we don't break migration from that version to the latest one.
Thomas Huth (4):
tests/vmstate-static-checker-data: Remove old dump files scripts/vmstate-static-checker.py: Allow new name for ghes_addr_le
field
tests/data/vmstate-static-checker: Add dump files from QEMU 7.2.17 tests/functional: Test with scripts/vmstate-static-checker.py
MAINTAINERS | 3 +-
scripts/vmstate-static-checker.py | 1 +
.../aarch64/virt-7.2.json | 2571 +++++++++++++
.../vmstate-static-checker/m68k/virt-7.2.json | 2936 ++++++++++++++
.../ppc64/pseries-7.2.json} | 1276 ++++---
.../s390x/s390-ccw-virtio-7.2.json | 475 +++
.../x86_64/pc-q35-7.2.json | 3402 +++++++++++++++++
tests/functional/meson.build | 13 +-
tests/functional/test_vmstate.py | 56 +
tests/vmstate-static-checker-data/dump1.json | 1163 ------
10 files changed, 10143 insertions(+), 1753 deletions(-)
create mode 100644 tests/data/vmstate-static-checker/aarch64/virt-7.2.json
create mode 100644 tests/data/vmstate-static-checker/m68k/virt-7.2.json
rename tests/{vmstate-static-checker-data/dump2.json => data/vmstate-static-checker/ppc64/pseries-7.2.json} (51%)
create mode 100644 tests/data/vmstate-static-checker/s390x/s390-ccw-virtio-7.2.json
create mode 100644 tests/data/vmstate-static-checker/x86_64/pc-q35-7.2.json
create mode 100755 tests/functional/test_vmstate.py
delete mode 100644 tests/vmstate-static-checker-data/dump1.jsonSignature · 1 line
2.49.0
PATCH 4/4 tests/functional: Test with scripts/vmstate-static-checker.py
From: Thomas Huth <[email protected]>
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.
--- 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
MAINTAINERS +1 -0
@@ -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/
tests/functional/meson.build +12 -1
@@ -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 = [
tests/functional/test_vmstate.py new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH 3/4 tests/data/vmstate-static-checker: Add dump files from QEMU 7.2.17
In reply to Thomas HuthFrom: Thomas Huth <[email protected]>
For automatic tests, we need reference files from older QEMU versions. QEMU 7.2 is a long term stable release, so it's a good candidate for checking whether the migration could still work correctly. Let's add the files from that version that have been taken with the "-dump-vmstate" parameter of QEMU (compiled with single machines and the configure switch "--without-default-devices" to keep the json files reasonable small).
Some devices also have been removed manually from the json files, e.g. the "pci-bridge" (which can be disabled in later QEMU versions via Kconfig), and some Linux-related devices like "scsi-block" and "scsi-generic" and KVM-related devices. Without removing them, we might get errors otherwise if these devices have not been compiled into the destination QEMU build.
--- MAINTAINERS | 1 + .../aarch64/virt-7.2.json | 2571 +++++++++++++ .../vmstate-static-checker/m68k/virt-7.2.json | 2936 ++++++++++++++ .../ppc64/pseries-7.2.json | 1068 ++++++ .../s390x/s390-ccw-virtio-7.2.json | 475 +++ .../x86_64/pc-q35-7.2.json | 3402 +++++++++++++++++ 6 files changed, 10453 insertions(+) create mode 100644 tests/data/vmstate-static-checker/aarch64/virt-7.2.json create mode 100644 tests/data/vmstate-static-checker/m68k/virt-7.2.json create mode 100644 tests/data/vmstate-static-checker/ppc64/pseries-7.2.json create mode 100644 tests/data/vmstate-static-checker/s390x/s390-ccw-virtio-7.2.json create mode 100644 tests/data/vmstate-static-checker/x86_64/pc-q35-7.2.json
MAINTAINERS +1 -0
@@ -3523,6 +3523,7 @@ F: include/migration/ F: include/qemu/userfaultfd.h F: migration/ F: scripts/vmstate-static-checker.py +F: tests/data/vmstate-static-checker/ F: tests/functional/test_migration.py F: tests/qtest/migration/ F: tests/qtest/migration-*
tests/data/vmstate-static-checker/aarch64/virt-7.2.json new file +2571 -0
2,571 lines not on this page · raw message
tests/data/vmstate-static-checker/m68k/virt-7.2.json new file +2936 -0
422 lines not on this page · raw message
tests/data/vmstate-static-checker/ppc64/pseries-7.2.json new file +1068 -0
1,068 lines not on this page · raw message
tests/data/vmstate-static-checker/s390x/s390-ccw-virtio-7.2.json new file +475 -0
475 lines not on this page · raw message
tests/data/vmstate-static-checker/x86_64/pc-q35-7.2.json new file +3402 -0
3,402 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.49.0
Part of the diff is not shown here. View the raw message.
PATCH 2/4 scripts/vmstate-static-checker.py: Allow new name for ghes_addr_le field
In reply to Thomas HuthFrom: Thomas Huth <[email protected]>
ghes_addr_le has been renamed to hw_error_le in commit 652f6d86cbb ("acpi/ghes: better name the offset of the hardware error firmware"). Adjust the checker script to allow that changed field name.
--- scripts/vmstate-static-checker.py | 1 + 1 file changed, 1 insertion(+)
scripts/vmstate-static-checker.py +1 -0
@@ -42,6 +42,7 @@ def check_fields_match(name, s_field, d_field): # Some fields changed names between qemu versions. This list # is used to allow such changes in each section / description. changed_names = { + 'acpi-ghes': ['ghes_addr_le', 'hw_error_le'], 'apic': ['timer', 'timer_expiry'], 'e1000': ['dev', 'parent_obj'], 'ehci': ['dev', 'pcidev'],
Signature · 1 line
2.49.0
PATCH 1/4 tests/vmstate-static-checker-data: Remove old dump files
In reply to Thomas HuthFrom: Thomas Huth <[email protected]>
These files reference QEMU machine types that have already been removed and thus are of no use anymore.
--- MAINTAINERS | 1 - tests/vmstate-static-checker-data/dump1.json | 1163 ------------------ tests/vmstate-static-checker-data/dump2.json | 968 --------------- 3 files changed, 2132 deletions(-) delete mode 100644 tests/vmstate-static-checker-data/dump1.json delete mode 100644 tests/vmstate-static-checker-data/dump2.json
MAINTAINERS +0 -1
@@ -3524,7 +3524,6 @@ F: include/qemu/userfaultfd.h F: migration/ F: scripts/vmstate-static-checker.py F: tests/functional/test_migration.py -F: tests/vmstate-static-checker-data/ F: tests/qtest/migration/ F: tests/qtest/migration-* F: docs/devel/migration/
tests/vmstate-static-checker-data/dump1.json deleted +0 -1163
1,163 lines not on this page · raw message
tests/vmstate-static-checker-data/dump2.json deleted +0 -968
968 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH 1/4] tests/vmstate-static-checker-data: Remove old dump files
Quoted 5 lines · Thomas Huth
From: Thomas Huth <[email protected]>
These files reference QEMU machine types that have already been removed and thus are of no use anymore.
Quoted 8 lines
Signed-off-by Thomas Huth <[email protected]>--- MAINTAINERS | 1 - tests/vmstate-static-checker-data/dump1.json | 1163 ------------------ tests/vmstate-static-checker-data/dump2.json | 968 --------------- 3 files changed, 2132 deletions(-)delete mode 100644
tests/vmstate-static-checker-data/dump1.jsondelete mode 100644tests/vmstate-static-checker-data/dump2.json
Re: [PATCH 1/4] tests/vmstate-static-checker-data: Remove old dump files
In reply to Thomas HuthQuoted 6 lines · Thomas Huth
From: Thomas Huth <[email protected]>
These files reference QEMU machine types that have already been removed and thus are of no use anymore.
Signed-off-by Thomas Huth <[email protected]>
I never noticed these files, but when looking it seems to me these two dumps are tailored to be used to test the script itself..
See:
$ git ls tests/vmstate-static-checker-data/ e178113ff6 hw: Replace anti-social QOM type names 38ef86b5a6 tests: vmstate static checker: add size mismatch inside substructure af3713f6b9 tests: vmstate static checker: add substructure for usb-kbd for hid section c7173a9c18 tests: vmstate static checker: remove Subsections aa2a12bb82 tests: vmstate static checker: remove a subsection b5968f0ab3 tests: vmstate static checker: remove Description inside Fields ff29b8573f tests: vmstate static checker: remove Description 083bac3484 tests: vmstate static checker: remove Fields 1d681c712a tests: vmstate static checker: change description name fd52ffb9bf tests: vmstate static checker: remove last field in a struct 55e8e0e19c tests: vmstate static checker: remove a field ab99bdbe33 tests: vmstate static checker: remove a section 7daa3d76df tests: vmstate static checker: minimum_version_id check 4efa6e1d64 tests: vmstate static checker: version mismatch inside a Description a81d3fad87 tests: vmstate static checker: add version error in main section bc178dc563 tests: vmstate static checker: incompat machine types a10413e4fc tests: vmstate static checker: add dump1 and dump2 files
So dump2.json was deliberately modified to trigger all kinds of error that the python script can detect.
Maybe we can still keep it there, but at least make it clearer that it's testing the script? For example, we could create a bash under the same dir running the script over the two dumps and comparing the results to be the expected one?
Currently the output:
$ scripts/vmstate-static-checker.py -s ./tests/vmstate-static-checker-data/dump1.json -d ./tests/vmstate-static-checker-data/dump2.json Warning: checking incompatible machine types: "pc-i440fx-2.1", "pc-i440fx-2.2" Section "fw_cfg" does not exist in dest Section "fusbh200-ehci-usb" version error: 2 > 1 Section "fusbh200-ehci-usb", Description "ehci-core": expected field "usbsts", got "usbsts_pending"; skipping rest Section "pci-serial-4x" Description "pci-serial-multi": Entry "Fields" missing Section "intel-hda-generic", Description "intel-hda", Field "pci": missing description Section "cfi.pflash01": Entry "Description" missing Section "megasas", Description "PCIDevice": expected field "irq_state", while dest has no further fields Section "PIIX3-xen" Description "PIIX3": minimum version error: 1 < 2 Section "PIIX3-xen" Description "PIIX3": Entry "Subsections" missing Section "tpci200": Description "tpci200" missing, got "tpci2002" instead; skipping Section "sun-fdtwo" Description "fdc": version error: 2 > 1 Section "sun-fdtwo", Description "fdrive": Subsection "fdrive/media_rate" not found Section "usb-kbd" Description "usb-kbd" Field "kbd.keycodes" size mismatch: 4 , 2
So the bash can make sure the result is exactly that. If we want, we could even route that to CI, but I'd say optional.
Signature · 1 line
Peter Xu
Re: [PATCH 2/4] scripts/vmstate-static-checker.py: Allow new name for ghes_addr_le field
In reply to Thomas HuthQuoted 7 lines · Thomas Huth
From: Thomas Huth <[email protected]>
ghes_addr_lehas been renamed tohw_error_lein commit652f6d86cbb("acpi/ghes: better name the offset of the hardware error firmware"). Adjust the checker script to allow that changed field name.Signed-off-by Thomas Huth <[email protected]>
Quoted 19 lines
--- scripts/vmstate-static-checker.py | 1 + 1 file changed, 1 insertion(+)scripts/vmstate-static-checker.py +1
-0@@ -42,6 +42,7 @@ def check_fields_match(name, s_field, d_field): # Some fields changed names between qemu versions. This list # is used to allow such changes in each section / description. changed_names = { + 'acpi-ghes': ['ghes_addr_le', 'hw_error_le'], 'apic': ['timer', 'timer_expiry'], 'e1000': ['dev', 'parent_obj'], 'ehci': ['dev', 'pcidev'],Signature · 1 line
2.49.0
Signature · 1 line
Peter Xu
Re: [PATCH 3/4] tests/data/vmstate-static-checker: Add dump files from QEMU 7.2.17
In reply to Thomas HuthQuoted 16 lines · Thomas Huth
From: Thomas Huth <[email protected]>
For automatic tests, we need reference files from older QEMU versions. QEMU 7.2 is a long term stable release, so it's a good candidate for checking whether the migration could still work correctly. Let's add the files from that version that have been taken with the "-dump-vmstate" parameter of QEMU (compiled with single machines and the configure switch "--without-default-devices" to keep the json files reasonable small).
Some devices also have been removed manually from the json files, e.g. the "pci-bridge" (which can be disabled in later QEMU versions via
Kconfig), and some Linux-related devices like "scsi-block" and "scsi-generic" and KVM-related devices. Without removing them, we might get errors otherwise if these devices have not been compiled into the destination QEMU build.Signed-off-by Thomas Huth <[email protected]>
Quoted 13 lines
--- MAINTAINERS | 1 + .../aarch64/virt-7.2.json | 2571 +++++++++++++ .../vmstate-static-checker/m68k/virt-7.2.json | 2936 ++++++++++++++ .../ppc64/pseries-7.2.json | 1068 ++++++ .../s390x/s390-ccw-virtio-7.2.json | 475 +++ .../x86_64/pc-q35-7.2.json | 3402 +++++++++++++++++ 6 files changed, 10453 insertions(+) create mode 100644 tests/data/vmstate-static-checker/aarch64/virt-7.2.json create mode 100644 tests/data/vmstate-static-checker/m68k/virt-7.2.json create mode 100644 tests/data/vmstate-static-checker/ppc64/pseries-7.2.json create mode 100644 tests/data/vmstate-static-checker/s390x/s390-ccw-virtio-7.2.json create mode 100644 tests/data/vmstate-static-checker/x86_64/pc-q35-7.2.json
This looks like an improvement indeed, it so far only covers machine type 7.2, rather than all machine types. I used to run these by hands before each release.. and sometimes I forgot. Before me, I am aware at least Dave used to run also during softfreezes.
One thing I am wondering is if we can do it the same way as the compat migration test in CI, so that we always compare with a base (which is the previous release binary), then move the base after each release.
After all, due to migration-compat-common CI job, we always build the base version of QEMU already in build-previous-qemu, so we already have two binaries at hand. IIUC we only need one new job to generate the two JSON blobs, and feed them to the checker on both directions.
If that is the case, it might have a benefit that we can cover all the machines as long as listed on both binaries, then check all of them?
Meanwhile, if we keep the ball rolling for each release (by boosting the base QEMU binary version), IIUC it guarantees all the new binaries will make sure to provide compatible VMSDs all across since we start running the job.
Would that work?
Signature · 1 line
Peter Xu
Re: [PATCH 1/4] tests/vmstate-static-checker-data: Remove old dump files
In reply to Peter XuQuoted 32 lines · Peter Xu
Quoted 6 lines · Thomas Huth
From: Thomas Huth <[email protected]>
These files reference QEMU machine types that have already been removed and thus are of no use anymore.
Signed-off-by Thomas Huth <[email protected]>I never noticed these files, but when looking it seems to me these two dumps are tailored to be used to test the script itself..
See:
$ git ls tests/vmstate-static-checker-data/ e178113ff6 hw: Replace anti-social QOM type names 38ef86b5a6 tests: vmstate static checker: add size mismatch inside substructure af3713f6b9 tests: vmstate static checker: add substructure for usb-kbd for hid section c7173a9c18 tests: vmstate static checker: remove Subsections aa2a12bb82 tests: vmstate static checker: remove a subsection b5968f0ab3 tests: vmstate static checker: remove Description inside Fields ff29b8573f tests: vmstate static checker: remove Description 083bac3484 tests: vmstate static checker: remove Fields 1d681c712a tests: vmstate static checker: change description name fd52ffb9bf tests: vmstate static checker: remove last field in a struct 55e8e0e19c tests: vmstate static checker: remove a field ab99bdbe33 tests: vmstate static checker: remove a section 7daa3d76df tests: vmstate static checker: minimum_version_id check 4efa6e1d64 tests: vmstate static checker: version mismatch inside a Description a81d3fad87 tests: vmstate static checker: add version error in main section bc178dc563 tests: vmstate static checker: incompat machine types a10413e4fc tests: vmstate static checker: add dump1 and dump2 files
Quoted 2 lines
So dump2.json was deliberately modified to trigger all kinds of error that the python script can detect.
Oh, good point, I should have looked at the history, too! ... the files clearly lacked an explanation / script that is using them!
Quoted 23 lines
Maybe we can still keep it there, but at least make it clearer that it's testing the script? For example, we could create a bash under the same dir running the script over the two dumps and comparing the results to be the expected one?
Currently the output:
$ scripts/vmstate-static-checker.py -s ./tests/vmstate-static-checker-data/dump1.json -d ./tests/vmstate-static-checker-data/dump2.json Warning: checking incompatible machine types: "pc-i440fx-2.1", "pc-i440fx-2.2" Section "fw_cfg" does not exist in dest Section "fusbh200-ehci-usb" version error: 2 > 1 Section "fusbh200-ehci-usb", Description "ehci-core": expected field "usbsts", got "usbsts_pending"; skipping rest Section "pci-serial-4x" Description "pci-serial-multi": Entry "Fields" missing Section "intel-hda-generic", Description "intel-hda", Field "pci": missing description Section "cfi.pflash01": Entry "Description" missing Section "megasas", Description "PCIDevice": expected field "irq_state", while dest has no further fields Section "PIIX3-xen" Description "PIIX3": minimum version error: 1 < 2 Section "PIIX3-xen" Description "PIIX3": Entry "Subsections" missing Section "tpci200": Description "tpci200" missing, got "tpci2002" instead; skipping Section "sun-fdtwo" Description "fdc": version error: 2 > 1 Section "sun-fdtwo", Description "fdrive": Subsection "fdrive/media_rate" not found Section "usb-kbd" Description "usb-kbd" Field "kbd.keycodes" size mismatch: 4 , 2
Quoted 2 lines
So the bash can make sure the result is exactly that. If we want, we could even route that to CI, but I'd say optional.
I can include such a test in the functional python test, no need for a separate bash script here, I think. I'll try to include that in v2.
Thomas
Re: [PATCH 3/4] tests/data/vmstate-static-checker: Add dump files from QEMU 7.2.17
In reply to Peter XuQuoted 31 lines · Peter Xu
Quoted 24 lines · Thomas Huth
From: Thomas Huth <[email protected]>
For automatic tests, we need reference files from older QEMU versions. QEMU 7.2 is a long term stable release, so it's a good candidate for checking whether the migration could still work correctly. Let's add the files from that version that have been taken with the "-dump-vmstate" parameter of QEMU (compiled with single machines and the configure switch "--without-default-devices" to keep the json files reasonable small).
Some devices also have been removed manually from the json files, e.g. the "pci-bridge" (which can be disabled in later QEMU versions via
Kconfig), and some Linux-related devices like "scsi-block" and "scsi-generic" and KVM-related devices. Without removing them, we might get errors otherwise if these devices have not been compiled into the destination QEMU build.Signed-off-by Thomas Huth <[email protected]>--- MAINTAINERS | 1 + .../aarch64/virt-7.2.json | 2571 +++++++++++++ .../vmstate-static-checker/m68k/virt-7.2.json | 2936 ++++++++++++++ .../ppc64/pseries-7.2.json | 1068 ++++++ .../s390x/s390-ccw-virtio-7.2.json | 475 +++ .../x86_64/pc-q35-7.2.json | 3402 +++++++++++++++++ 6 files changed, 10453 insertions(+)Quoted 5 lines
create mode 100644
tests/data/vmstate-static-checker/aarch64/virt-7.2.jsoncreate mode 100644tests/data/vmstate-static-checker/m68k/virt-7.2.jsoncreate mode 100644tests/data/vmstate-static-checker/ppc64/pseries-7.2.jsoncreate mode 100644tests/data/vmstate-static-checker/s390x/s390-ccw-virtio-7.2.jsoncreate mode 100644tests/data/vmstate-static-checker/x86_64/pc-q35-7.2.json
Quoted 4 lines
This looks like an improvement indeed, it so far only covers machine type 7.2, rather than all machine types. I used to run these by hands before each release.. and sometimes I forgot. Before me, I am aware at least Dave used to run also during softfreezes.
Since I had to strip down the dump files quite a bit (compiling QEMU with --without-default-devices etc.) to avoid errors when the current build is limited, it's maybe best if you continue checking manually at least once during the soft-freeze with a non-stripped json file.
Quoted 12 lines
One thing I am wondering is if we can do it the same way as the compat migration test in CI, so that we always compare with a base (which is the previous release binary), then move the base after each release.
After all, due to migration-compat-common CI job, we always build the base version of QEMU already in build-previous-qemu, so we already have two binaries at hand. IIUC we only need one new job to generate the two JSON blobs, and feed them to the checker on both directions.
If that is the case, it might have a benefit that we can cover all the machines as long as listed on both binaries, then check all of them?
Quoted 6 lines
Meanwhile, if we keep the ball rolling for each release (by boosting the base QEMU binary version), IIUC it guarantees all the new binaries will make sure to provide compatible VMSDs all across since we start running the job.
Would that work?
I can have a try, though we might need to teach the checker script some more things first, e.g. it's getting confused if we clean up old and unnecessary fields like in commit 445d3facffe82788b880107c0849dab9505b33d9 ...
Thomas
Re: [PATCH 3/4] tests/data/vmstate-static-checker: Add dump files from QEMU 7.2.17
Quoted 37 lines · Thomas Huth
Quoted 31 lines · Peter Xu
Quoted 24 lines · Thomas Huth
From: Thomas Huth <[email protected]>
For automatic tests, we need reference files from older QEMU versions. QEMU 7.2 is a long term stable release, so it's a good candidate for checking whether the migration could still work correctly. Let's add the files from that version that have been taken with the "-dump-vmstate" parameter of QEMU (compiled with single machines and the configure switch "--without-default-devices" to keep the json files reasonable small).
Some devices also have been removed manually from the json files, e.g. the "pci-bridge" (which can be disabled in later QEMU versions via
Kconfig), and some Linux-related devices like "scsi-block" and "scsi-generic" and KVM-related devices. Without removing them, we might get errors otherwise if these devices have not been compiled into the destination QEMU build.Signed-off-by Thomas Huth <[email protected]>--- MAINTAINERS | 1 + .../aarch64/virt-7.2.json | 2571 +++++++++++++ .../vmstate-static-checker/m68k/virt-7.2.json | 2936 ++++++++++++++ .../ppc64/pseries-7.2.json | 1068 ++++++ .../s390x/s390-ccw-virtio-7.2.json | 475 +++ .../x86_64/pc-q35-7.2.json | 3402 +++++++++++++++++ 6 files changed, 10453 insertions(+)Quoted 5 lines
create mode 100644
tests/data/vmstate-static-checker/aarch64/virt-7.2.jsoncreate mode 100644tests/data/vmstate-static-checker/m68k/virt-7.2.jsoncreate mode 100644tests/data/vmstate-static-checker/ppc64/pseries-7.2.jsoncreate mode 100644tests/data/vmstate-static-checker/s390x/s390-ccw-virtio-7.2.jsoncreate mode 100644tests/data/vmstate-static-checker/x86_64/pc-q35-7.2.jsonQuoted 4 lines
This looks like an improvement indeed, it so far only covers machine type 7.2, rather than all machine types. I used to run these by hands before each release.. and sometimes I forgot. Before me, I am aware at least Dave used to run also during softfreezes.
Quoted 4 lines
Since I had to strip down the dump files quite a bit (compiling QEMU with --without-default-devices etc.) to avoid errors when the current build is limited, it's maybe best if you continue checking manually at least once during the soft-freeze with a non-stripped json file.
Yep, will do (if I won't forget to..).
Quoted 18 lines
Quoted 18 lines
One thing I am wondering is if we can do it the same way as the compat migration test in CI, so that we always compare with a base (which is the previous release binary), then move the base after each release.
After all, due to migration-compat-common CI job, we always build the base version of QEMU already in build-previous-qemu, so we already have two binaries at hand. IIUC we only need one new job to generate the two JSON blobs, and feed them to the checker on both directions.
If that is the case, it might have a benefit that we can cover all the machines as long as listed on both binaries, then check all of them?
Meanwhile, if we keep the ball rolling for each release (by boosting the base QEMU binary version), IIUC it guarantees all the new binaries will make sure to provide compatible VMSDs all across since we start running the job.
Quoted 5 lines
Quoted 1 line
Would that work?
I can have a try, though we might need to teach the checker script some more things first, e.g. it's getting confused if we clean up old and unnecessary fields like in commit
445d3facffe82788b880107c0849dab9505b33d9...
Right, we definitely want to have such job allow_failure set.. And this is also not the only way to fail it, e.g. I just ran it on the latest 10.0 for q35-9.2 machine type, then I spot two more failures besides what you fixed in this series.
x1:bin [migration-staging]$ ../scripts/vmstate-static-checker.py -s ./json.9.2 -d ./json.10.0 Section "sysbus-ahci" does not exist in dest
Section "hpet", Description "hpet": expected field "num_timers", got "num_timers_save"; skipping rest
The first one is caused by a Kconfig change - CONFIG_AHCI used to be selected via hw/ide on x86, now since there's the new ahci-sysbus.c since 1b26146e898086 in 10.0, vmstate_sysbus_ahci isn't available anymore on x86, but only selected by hw/arm/Kconfig even if I built the binary using exactly the same setup.
The 2nd one is a rename which is similarly benign. I'll throw a patch soon for that.
If one step further.. maybe we could also cache the checker's output for each (arch, machine type) tuple, then we mark the job fail only if the output changes. That may help to warn maintainers that something changed the VMSD so one can have a look. But we could start from simple..
Signature · 1 line
Peter Xu
Re: [PATCH 4/4] tests/functional: Test with scripts/vmstate-static-checker.py
In reply to Thomas HuthQuoted 133 lines · Thomas Huth
From: Thomas Huth <[email protected]>
We've got this nice
vmstate-static-checker.pyscript 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 <[email protected]>--- 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.pyMAINTAINERS +1
-0@@ -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/tests/functional/meson.build +12
-1@@ -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 = [tests/functional/test_vmstate.py new file +46
-0@@ -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,
tests/functional/test_vmstate.py line 56
Quoted 10 lines
tests/functional/test_vmstate.py new file +10
-0+ 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()
Thanks for this series Thomas, it's very useful.
Could we extend this automatically to test migration on all combinations: {qemu-system-*} x {machine}?
We could generate a single list of references, containing hashes of all outputs, and a simple and clean command to regenerate all those, and associated jsons, so we don't pollute qemu code with tons of json.
This way, we can automatically detect that we never regress, not only from release to release, but commit to commit.
In case we need to update reference, people can point what's the actual difference in the commit message.
As well, since I took a look into that before, this check is not enough regarding migration. Beyonds the VMDstate, we should check as well that the default values of every field are not changed. For instance, we recently changed the default pauth property of arm cpus, and without a careful backcompat, it would have break migration. It's a bit more tricky, since there is nothing available now to dump this (I hacked that using a custom trace). And definitely not something in the scope of your series, just worth mentioning.
I hope we can one day get rid of all "Is this change safe regarding migration?" comments because we know we can trust our CI instead.
Regards,
Pierrick
Re: [PATCH 4/4] tests/functional: Test with scripts/vmstate-static-checker.py
Quoted 136 lines · Pierrick Bouvier
Quoted 135 lines · Thomas Huth
From: Thomas Huth <[email protected]>
We've got this nice
vmstate-static-checker.pyscript 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 <[email protected]>--- 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.pyMAINTAINERS +1
-0@@ -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/tests/functional/meson.build +12
-1@@ -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 = [tests/functional/test_vmstate.py new file +55
-0@@ -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__':
Quoted 8 lines
tests/functional/test_vmstate.py line 56
Quoted 1 line
tests/functional/test_vmstate.py new file +1
-0+ QemuSystemTest.main()Thanks for this series Thomas, it's very useful.
Could we extend this automatically to test migration on all combinations:
{qemu-system-*} x {machine}?
We could generate a single list of references, containing hashes of all outputs, and a simple and clean command to regenerate all those, and associated jsons, so we don't pollute qemu code with tons of json.
I think a major challenge would be false positives, and how to filter them.. when we put anything into CI.
Side note: yesterday I just wrote a script to do exactly this, by auto build binaries and check all relevant archs over all machine types supported. It looks like this:
https://gitlab.com/peterx/qemu/-/commit/c4abfa39f8943cd62f0d982ecb36537df398ae70
The plan is I can run this at the end of each release, though.. not yet for CI. I also don't have plan to upstream this script, maybe I'll keep it myself as of now unless someone thinks we should have it.
PS: I just ran it over v9.2..v10.0 over the default 4 archs (x86,arm,ppc,s390) and a huge list was generated.. I believe most of them are false positives, I'll delay walking the list for some time.. I attached the result at the end in case anyone is interested.
Quoted 16 lines
This way, we can automatically detect that we never regress, not only from release to release, but commit to commit.
In case we need to update reference, people can point what's the actual difference in the commit message.
As well, since I took a look into that before, this check is not enough regarding migration. Beyonds the VMDstate, we should check as well that the default values of every field are not changed. For instance, we recently changed the default pauth property of arm cpus, and without a careful backcompat, it would have break migration. It's a bit more tricky, since there is nothing available now to dump this (I hacked that using a custom trace). And definitely not something in the scope of your series, just worth mentioning.
Quoted 2 lines
I hope we can one day get rid of all "Is this change safe regarding migration?" comments because we know we can trust our CI instead.
IMHO it's extremely hard (if not impossible) to guarantee that, because some migration bug may only trigger in special paths that not always happen, e.g. it can even involve guest driver behavior.
Said that, Fabiano used to work on supporting device-specific tests in qtests/migration-test.c. I don't think it landed but maybe we have room for specific device tests using qtests/migration-test.c framework.
https://lore.kernel.org/all/[email protected]/
Thanks,
Signature · 1 line
Peter Xu
Re: [PATCH 4/4] tests/functional: Test with scripts/vmstate-static-checker.py
Quoted 146 lines · Peter Xu
Quoted 136 lines · Pierrick Bouvier
Quoted 135 lines · Thomas Huth
From: Thomas Huth <[email protected]>
We've got this nice
vmstate-static-checker.pyscript 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 <[email protected]>--- 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.pyMAINTAINERS +1
-0@@ -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/tests/functional/meson.build +12
-1@@ -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 = [tests/functional/test_vmstate.py new file +55
-0@@ -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__':Quoted 8 lines
tests/functional/test_vmstate.py line 56
Quoted 1 line
tests/functional/test_vmstate.py new file +1
-0+ QemuSystemTest.main()Thanks for this series Thomas, it's very useful.
Could we extend this automatically to test migration on all combinations:
{qemu-system-*} x {machine}?
We could generate a single list of references, containing hashes of all outputs, and a simple and clean command to regenerate all those, and associated jsons, so we don't pollute qemu code with tons of json.
Quoted 3 lines
I think a major challenge would be false positives, and how to filter them.. when we put anything into CI.
A fail would be expected everytime something changes:
- it can be a default field that has a new value (particularly sensitive for cpus)
- it can be a new cpu field that is added
- it can be a board definition change
- it can be a hardware related change
In all cases, even though it does not break migration, it's interesting to know such a change happen.
As well, if it's simple to update and get differences of the various dumps per {binary, board}, then it's trivial to identify and comment the "false positive". The more often it runs (ideally, per PR, or per series), the easier it is to identify what changed.
Quoted 10 lines
Side note: yesterday I just wrote a script to do exactly this, by auto build binaries and check all relevant archs over all machine types supported. It looks like this:
https://gitlab.com/peterx/qemu/-/commit/c4abfa39f8943cd62f0d982ecb36537df398ae70
The plan is I can run this at the end of each release, though.. not yet for CI. I also don't have plan to upstream this script, maybe I'll keep it myself as of now unless someone thinks we should have it.
Glad to hear we have a script, but sad to hear "will run manually once every 6 months".
Quoted 5 lines
PS: I just ran it over v9.2..v10.0 over the default 4 archs (x86,arm,ppc,s390) and a huge list was generated.. I believe most of them are false positives, I'll delay walking the list for some time.. I attached the result at the end in case anyone is interested.
Would that be possible to post this on an online forge like GitLab, and commit the previous and new versions of dumps (the data, not the list of failures), so we can see all the differences in a nice way?
Quoted 16 lines
Quoted 16 lines
This way, we can automatically detect that we never regress, not only from release to release, but commit to commit.
In case we need to update reference, people can point what's the actual difference in the commit message.
As well, since I took a look into that before, this check is not enough regarding migration. Beyonds the VMDstate, we should check as well that the default values of every field are not changed. For instance, we recently changed the default pauth property of arm cpus, and without a careful backcompat, it would have break migration. It's a bit more tricky, since there is nothing available now to dump this (I hacked that using a custom trace). And definitely not something in the scope of your series, just worth mentioning.
Quoted 7 lines
Quoted 2 lines
I hope we can one day get rid of all "Is this change safe regarding migration?" comments because we know we can trust our CI instead.
IMHO it's extremely hard (if not impossible) to guarantee that, because some migration bug may only trigger in special paths that not always happen, e.g. it can even involve guest driver behavior.
It would not cover 100%, but if we already make sure that a VM stopped at end of qemu_init() has a predictable dump, it's already a huge win over having nothing. We can use the same argument that current QEMU CI does not cover 100% of the code (*much* less than that from what I tried), but it's still better than no test.
Quoted 8 lines
Said that, Fabiano used to work on supporting device-specific tests in
qtests/migration-test.c. I don't think it landed but maybe we have room for specific device tests usingqtests/migration-test.cframework.https://lore.kernel.org/all/[email protected]/
Thanks,
Regards,
Pierrick
Re: [PATCH 4/4] tests/functional: Test with scripts/vmstate-static-checker.py
Quoted 171 lines · Pierrick Bouvier
Quoted 146 lines · Peter Xu
Quoted 136 lines · Pierrick Bouvier
Quoted 135 lines · Thomas Huth
From: Thomas Huth <[email protected]>
We've got this nice
vmstate-static-checker.pyscript 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 <[email protected]>--- 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.pyMAINTAINERS +1
-0@@ -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/tests/functional/meson.build +12
-1@@ -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 = [tests/functional/test_vmstate.py new file +55
-0@@ -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__':Quoted 8 lines
tests/functional/test_vmstate.py line 56
Quoted 1 line
tests/functional/test_vmstate.py new file +1
-0+ QemuSystemTest.main()Thanks for this series Thomas, it's very useful.
Could we extend this automatically to test migration on all combinations:
{qemu-system-*} x {machine}?
We could generate a single list of references, containing hashes of all outputs, and a simple and clean command to regenerate all those, and associated jsons, so we don't pollute qemu code with tons of json.Quoted 3 lines
I think a major challenge would be false positives, and how to filter them.. when we put anything into CI.
A fail would be expected everytime something changes:
- it can be a default field that has a new value (particularly sensitive for cpus)
- it can be a new cpu field that is added
- it can be a board definition change
- it can be a hardware related changeIn all cases, even though it does not break migration, it's interesting to know such a change happen.
As well, if it's simple to update and get differences of the various dumps per {binary, board}, then it's trivial to identify and comment the "false positive". The more often it runs (ideally, per PR, or per series), the easier it is to identify what changed.Quoted 6 lines
Side note: yesterday I just wrote a script to do exactly this, by auto build binaries and check all relevant archs over all machine types supported. It looks like this:
https://gitlab.com/peterx/qemu/-/commit/c4abfa39f8943cd62f0d982ecb36537df398ae70
Quoted 13 lines
Quoted 4 lines
The plan is I can run this at the end of each release, though.. not yet for CI. I also don't have plan to upstream this script, maybe I'll keep it myself as of now unless someone thinks we should have it.
Glad to hear we have a script, but sad to hear "will run manually once every 6 months".
Quoted 5 lines
PS: I just ran it over v9.2..v10.0 over the default 4 archs (x86,arm,ppc,s390) and a huge list was generated.. I believe most of them are false positives, I'll delay walking the list for some time.. I attached the result at the end in case anyone is interested.
I probably forgot to do that. Here's the condensed list, and this time I went throught it, even though I found zero real bug.. so all false positives, AFAICT..
Found forward migration incompatibility issues:
Section "acpi-ged", Description "acpi-ghes": expected field "ghes_addr_le", got "hw_error_le"; skipping rest Section "sysbus-ahci" does not exist in dest
Section "imx.enet" Section "imx.enet" Description "imx.fec": minimum version error: 2 < 3 Section "imx.enet", Description "imx.fec": expected field "phy_status", while dest has no further fields Section "npcm7xx-clk" Section "npcm7xx-clk" Description "npcm7xx-clk": minimum version error: 1 < 3 Section "npcm7xx-clk": Description "npcm7xx-clk" missing, got "npcm-clk" instead; skipping Section "npcm7xx-gcr" Section "npcm7xx-gcr" Description "npcm7xx-gcr": minimum version error: 0 < 2 Section "npcm7xx-gcr": Description "npcm7xx-gcr" missing, got "npcm-gcr" instead; skipping Section "lan9118" Section "lan9118" Description "lan9118": minimum version error: 2 < 3 Section "lan9118", Description "lan9118": expected field "phy_status", got "eeprom_writable"; skipping rest Section "imx.fec" Section "imx.fec" Description "imx.fec": minimum version error: 2 < 3 Section "imx.fec", Description "imx.fec": expected field "phy_status", while dest has no further fields
Found backward migration incompatibility issues:
Section "uefi-vars-sysbus" does not exist in dest
Section "acpi-ged", Description "acpi-ghes": expected field "hw_error_le", got "ghes_addr_le"; skipping rest Section "uefi-vars-x64" does not exist in dest
Section "vmclock" does not exist in dest
Section "virtio-mem" does not exist in dest
Section "npcm8xx-gcr" does not exist in dest
Section "imx.enet" version error: 3 > 2
Section "imx.enet" Description "imx.fec": version error: 3 > 2
Section "rs5c372" does not exist in dest
Section "imx8mp.analog" does not exist in dest
Section "npcm7xx-clk" version error: 3 > 1
Section "npcm7xx-clk" Description "npcm-clk": version error: 3 > 1
Section "npcm7xx-clk": Description "npcm-clk" missing, got "npcm7xx-clk" instead; skipping Section "imx8mp.ccm" does not exist in dest
Section "npcm7xx-gcr" version error: 2 > 0
Section "npcm7xx-gcr" Description "npcm-gcr": version error: 2 > 0
Section "npcm7xx-gcr": Description "npcm-gcr" missing, got "npcm7xx-gcr" instead; skipping Section "fsl-imx8m-pcie-phy" does not exist in dest
Section "imx8mp.gpt" does not exist in dest
Section "lan9118" version error: 3 > 2
Section "lan9118" Description "lan9118": version error: 3 > 2
Section "lan9118", Description "lan9118": expected field "eeprom_writable", got "phy_status"; skipping rest Section "imx.fec" version error: 3 > 2
Section "imx.fec" Description "imx.fec": version error: 3 > 2
Section "lan9118-phy" does not exist in dest
Section "aspeed.hace-ast2700" does not exist in dest
Section "npcm-clk" does not exist in dest
Section "aspeed.sdhci-ast2400" does not exist in dest
Section "npcm-gcr" does not exist in dest
Section "aspeed.sdhci-ast2500" does not exist in dest
Section "npcm-pcs" does not exist in dest
Section "aspeed.sdhci-ast2600" does not exist in dest
Section "aspeed.timer-ast2700" does not exist in dest
Section "npcm8xx-clk" does not exist in dest
Section "aspeed.sdhci-ast2700" does not exist in dest
Quoted 4 lines
Would that be possible to post this on an online forge like GitLab, and commit the previous and new versions of dumps (the data, not the list of failures), so we can see all the differences in a nice way?
It should be easy to do, but now I'm thinking how much it would help developers.
As discussed above, I finally went through the list for the previous release cycle, and I see no real positive reports.
It could be that the script used to be able to capture more real issues, but as more developers / maintainers got reports, then such issues are less likely to happen. Do any of us used that to find any real bug recently?
I also start to doubt whether we should keep growing the renaming list. First of all, such list isn't that helpful if we don't run that on old enough binaries - the rename will not cause false positive anymore as long as we compare newer binaries from the commit it got changed. So if we run it per-release the rename will only bother us once per release..
Quoted 25 lines
Quoted 17 lines
Quoted 17 lines
This way, we can automatically detect that we never regress, not only from release to release, but commit to commit.
In case we need to update reference, people can point what's the actual difference in the commit message.
As well, since I took a look into that before, this check is not enough regarding migration. Beyonds the VMDstate, we should check as well that the default values of every field are not changed. For instance, we recently changed the default pauth property of arm cpus, and without a careful backcompat, it would have break migration. It's a bit more tricky, since there is nothing available now to dump this (I hacked that using a custom trace). And definitely not something in the scope of your series, just worth mentioning.
Quoted 7 lines
Quoted 2 lines
I hope we can one day get rid of all "Is this change safe regarding migration?" comments because we know we can trust our CI instead.
IMHO it's extremely hard (if not impossible) to guarantee that, because some migration bug may only trigger in special paths that not always happen, e.g. it can even involve guest driver behavior.
Quoted 6 lines
It would not cover 100%, but if we already make sure that a VM stopped at end of
qemu_init()has a predictable dump, it's already a huge win over having nothing.
We can use the same argument that current QEMU CI does not cover 100% of the code (*much* less than that from what I tried), but it's still better than no test.
So now I start to question whether we need to work more on the whole vmstate static checker.. I think I'll still try to keep running it once per release for some while, but if I can't catch any real bug maybe we're good from this regard, and people just started being very cautious on e.g. randomly adding or removing vmsd fields.
Let me know if anyone thinks it differently..
Thanks,
Signature · 1 line
Peter Xu