[PATCH v2 00/18] migration: MigrationParameters changes

Fabiano Rosas posted 18 patches 2 weeks, 2 days ago
Failed in applying to current master (apply log)
Maintainers: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Chao Liu <chao.liu@processmission.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
docs/about/deprecated.rst          |  13 +
migration/migration-hmp-cmds.c     | 457 ++++++------------
migration/migration.c              |  17 +-
migration/migration.h              |   2 +-
migration/options.c                | 732 +++++++++++------------------
migration/options.h                |  27 +-
migration/savevm.c                 |   8 +-
qapi/migration.json                | 140 +++++-
scripts/checkpatch.pl              |  11 +-
tests/qemu-iotests/300             |  20 +-
tests/qtest/migration/misc-tests.c | 534 +++++++++++++++++++++
11 files changed, 1155 insertions(+), 806 deletions(-)
[PATCH v2 00/18] migration: MigrationParameters changes
Posted by Fabiano Rosas 2 weeks, 2 days ago
since v1:

- Made the commit message clearer on the checkpatch change.

- Renamed the variables in the merge function to indicate which
  structure is the one receiving the update.

- Rewrote the string parsing on the HMP test because it was allowing
  false positives and tripping on readline escape sequences.

- Dropped the has_* fields validation patch because it was simply
  doing nothing (thank you Peter for spotting it).

- Due to the above I decided to leave MigrateParameter (singular)
  untouched. The enum max is just too convenient to lose.

- Used an array instead of a switch for the capabilities compat
  function.

- Fixed the copy of MigrationCapability documentation over to
  MigrationParameters in migration.json which was not verbatim.

- Added missing return statement in migrate_params_check.

- Added CONFIG_HMP checks after rebase on master

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

---
v1:
https://lore.kernel.org/r/20260902221547.1812481-1-farosas@suse.de

Hi, this contains the pending work from my previous two series to
reduce duplication in the migration parameters handling and unify
migration parameters and capabilities.

Supersedes these series:
- [PATCH v3 00/51] migration: Unify capabilities and parameters
https://lore.kernel.org/r/20251215220041.12657-1-farosas@suse.de

- [PATCH v2 0/9] qapi: Use visitors for migration parameters handling
https://lore.kernel.org/r/20260202224101.20568-1-farosas@suse.de

I held on to the "pass full config to migration commands" changes for
now, let's put this^ scaffolding in first.

Changes from previous versions:

1) hacky qapi dealloc visitor replaced with a simple merge using
QDict.

  Suggested as one of the alternatives by Markus in:
  https://lore.kernel.org/r/871pio3d3h.fsf@pond.sub.org

This^ made me realise we've been doing manual checking in a lot of
places where a QAPI->QDict serialization would do the work
automatically, so:

2) New qtest to validate migration HMP commands.

  Good to have in general, but also this series touches that code
  heavily.

3) Rewrite of hmp_migrate_set_parameters, hmp_info_migrate_parameters
and hmp_migrate_set_parameter_completion.

  I want to remove all manual handling of migration parameters. These
  commands were the last heavy users of the "if params->has_foo,
  handle params->foo" pattern. We lose some user-friendliness here,
  but hopefully it's ok.

4) Remove MigrationParameter (singular).

  With this, migration.json now has only one place to define and
  document migration parameters, the MigrationParameters (plural).

5) New routine to validate has_* fields.

  Due to the above change, we lose MIGRATION_PARAMETER__MAX. Add a
  routine that ensures s->parameters has all has_ fields set to
  true. This is required for all the QAPI cloning and merging, etc.

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

Fabiano Rosas (18):
  checkpatch: Fix checking of newlines in error messages
  migration/options.c: Don't export migrate_tls_opts_free
  migration: Rename variables in qmp_migrate_set_parameters
  migration: Use QAPI_CLONE_MEMBERS in migrate_params_apply
  migration: Merge parameter structs instead of assigning one by one
  migration: Open code migrate_params_apply
  migration: Stop freeing s->parameters members individually
  migration: Use migrate_params_free during finalize
  tests/qtest/migration: Add a test for HMP
  tests/qtest/migration: Add a test for HMP completion
  migration: HMP: Fix bandwidth parameters
  migration: Change HMP 'info migrate_parameters' output
  migration: Use keyval input visitor in HMP set command
  migration: Use output visitor in info command
  migration: Rewrite migrate_set_parameter_completion using QDict
  migration: Add capabilities into MigrationParameters
  migration: Remove s->capabilities
  qapi/migration: Deprecate capabilities commands

 docs/about/deprecated.rst          |  13 +
 migration/migration-hmp-cmds.c     | 457 ++++++------------
 migration/migration.c              |  17 +-
 migration/migration.h              |   2 +-
 migration/options.c                | 732 +++++++++++------------------
 migration/options.h                |  27 +-
 migration/savevm.c                 |   8 +-
 qapi/migration.json                | 140 +++++-
 scripts/checkpatch.pl              |  11 +-
 tests/qemu-iotests/300             |  20 +-
 tests/qtest/migration/misc-tests.c | 534 +++++++++++++++++++++
 11 files changed, 1155 insertions(+), 806 deletions(-)

-- 
2.53.0
Re: [PATCH v2 00/18] migration: MigrationParameters changes
Posted by Peter Xu 2 weeks, 2 days ago
On Wed, Sep 09, 2026 at 06:44:50PM -0300, Fabiano Rosas wrote:
> Fabiano Rosas (18):
>   checkpatch: Fix checking of newlines in error messages
>   migration/options.c: Don't export migrate_tls_opts_free
>   migration: Rename variables in qmp_migrate_set_parameters
>   migration: Use QAPI_CLONE_MEMBERS in migrate_params_apply
>   migration: Merge parameter structs instead of assigning one by one
>   migration: Open code migrate_params_apply
>   migration: Stop freeing s->parameters members individually
>   migration: Use migrate_params_free during finalize
>   tests/qtest/migration: Add a test for HMP
>   tests/qtest/migration: Add a test for HMP completion
>   migration: HMP: Fix bandwidth parameters
>   migration: Change HMP 'info migrate_parameters' output
>   migration: Use keyval input visitor in HMP set command
>   migration: Use output visitor in info command
>   migration: Rewrite migrate_set_parameter_completion using QDict
>   migration: Add capabilities into MigrationParameters
>   migration: Remove s->capabilities
>   qapi/migration: Deprecate capabilities commands

The new HMP test may fail when ran without userfaultfd privilege.

$ QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --full -r /x86_64/migration/hmp
TAP version 14
# random seed: R02S0ff0d2920ac5e3bffdb3b5a776110e91
# starting QEMU: exec ./qemu-system-x86_64 -qtest unix:/tmp/qtest-219499.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-219499.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -machine none  -accel qtest
# Skipping test: userfaultfd not available
# Start of x86_64 tests
# Start of migration tests
# Start of hmp tests
# Running /x86_64/migration/hmp/parameters
# starting QEMU: exec ./qemu-system-x86_64 -qtest unix:/tmp/qtest-219499.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-219499.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -accel tcg -nodefaults -S  -accel qtest
# HMP command failed:
# 
# Error: Background-snapshot is not supported by host kernel
# 
**
ERROR:../tests/qtest/migration/misc-tests.c:376:assert_hmp_success: code should not be reached
not ok /x86_64/migration/hmp/parameters - ERROR:../tests/qtest/migration/misc-tests.c:376:assert_hmp_success: code should not be reached
Bail out!
Aborted                    (core dumped) QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --full -r /x86_64/migration/hmp

We can either fix it (but I don't see easy way to wrap some TESTs to run
conditionally), or drop the verifications for background-snapshot cap for
now.

-- 
Peter Xu
Re: [PATCH v2 00/18] migration: MigrationParameters changes
Posted by Fabiano Rosas 2 weeks, 2 days ago
Peter Xu <peterx@redhat.com> writes:

> On Wed, Sep 09, 2026 at 06:44:50PM -0300, Fabiano Rosas wrote:
>> Fabiano Rosas (18):
>>   checkpatch: Fix checking of newlines in error messages
>>   migration/options.c: Don't export migrate_tls_opts_free
>>   migration: Rename variables in qmp_migrate_set_parameters
>>   migration: Use QAPI_CLONE_MEMBERS in migrate_params_apply
>>   migration: Merge parameter structs instead of assigning one by one
>>   migration: Open code migrate_params_apply
>>   migration: Stop freeing s->parameters members individually
>>   migration: Use migrate_params_free during finalize
>>   tests/qtest/migration: Add a test for HMP
>>   tests/qtest/migration: Add a test for HMP completion
>>   migration: HMP: Fix bandwidth parameters
>>   migration: Change HMP 'info migrate_parameters' output
>>   migration: Use keyval input visitor in HMP set command
>>   migration: Use output visitor in info command
>>   migration: Rewrite migrate_set_parameter_completion using QDict
>>   migration: Add capabilities into MigrationParameters
>>   migration: Remove s->capabilities
>>   qapi/migration: Deprecate capabilities commands
>
> The new HMP test may fail when ran without userfaultfd privilege.
>
> $ QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --full -r /x86_64/migration/hmp
> TAP version 14
> # random seed: R02S0ff0d2920ac5e3bffdb3b5a776110e91
> # starting QEMU: exec ./qemu-system-x86_64 -qtest unix:/tmp/qtest-219499.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-219499.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -machine none  -accel qtest
> # Skipping test: userfaultfd not available
> # Start of x86_64 tests
> # Start of migration tests
> # Start of hmp tests
> # Running /x86_64/migration/hmp/parameters
> # starting QEMU: exec ./qemu-system-x86_64 -qtest unix:/tmp/qtest-219499.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-219499.qmp,id=char0 -object monitor-qmp,id=qmp0,chardev=char0 -display none -audio none -run-with exit-with-parent=on -accel tcg -nodefaults -S  -accel qtest
> # HMP command failed:
> # 
> # Error: Background-snapshot is not supported by host kernel
> # 
> **
> ERROR:../tests/qtest/migration/misc-tests.c:376:assert_hmp_success: code should not be reached
> not ok /x86_64/migration/hmp/parameters - ERROR:../tests/qtest/migration/misc-tests.c:376:assert_hmp_success: code should not be reached
> Bail out!
> Aborted                    (core dumped) QTEST_QEMU_BINARY=./qemu-system-x86_64 ./tests/qtest/migration-test --full -r /x86_64/migration/hmp
>
> We can either fix it (but I don't see easy way to wrap some TESTs to run
> conditionally), or drop the verifications for background-snapshot cap for
> now.

Thank you for testing this. I think I can just move the array into the
test function and check env->has_uffd in there.