On Mon, Dec 15, 2025 at 07:00:23PM -0300, Fabiano Rosas wrote: > Add a new start hook that takes an opaque pointer so the tests can > stop having to nest hook calls.
I saw that this hook is also removed after the whole series applied.. maybe it should be mentioned here. > > Signed-off-by: Fabiano Rosas <[email protected]> Reviewed-by: Peter Xu <[email protected]> > --- > tests/qtest/migration/framework.c | 8 ++++++++ > tests/qtest/migration/framework.h | 16 ++++++++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/tests/qtest/migration/framework.c > b/tests/qtest/migration/framework.c > index f740228cf2..b9bbdca6a9 100644 > --- a/tests/qtest/migration/framework.c > +++ b/tests/qtest/migration/framework.c > @@ -591,6 +591,9 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, > > if (args->start_hook) { > args->postcopy_data = args->start_hook(from, to); > + } else if (args->start_hook_full) { > + args->postcopy_data = args->start_hook_full(from, to, > + args->start_hook_data); > } > > migrate_ensure_non_converge(from, args->start.config); > @@ -868,6 +871,9 @@ int test_precopy_common(MigrateCommon *args) > > if (args->start_hook) { > data_hook = args->start_hook(from, to); > + } else if (args->start_hook_full) { > + data_hook = args->start_hook_full(from, to, > + args->start_hook_data); > } > > if (args->start.incoming_defer && !args->start.defer_target_connect) { > @@ -1062,6 +1068,8 @@ void test_file_common(MigrateCommon *args, bool > stop_src) > > if (args->start_hook) { > data_hook = args->start_hook(from, to); > + } else if (args->start_hook_full) { > + data_hook = args->start_hook_full(from, to, args->start_hook_data); > } > > migrate_ensure_converge(from, args->start.config); > diff --git a/tests/qtest/migration/framework.h > b/tests/qtest/migration/framework.h > index 65c656e0d3..2584599f14 100644 > --- a/tests/qtest/migration/framework.h > +++ b/tests/qtest/migration/framework.h > @@ -65,6 +65,19 @@ int migration_env_clean(MigrationTestEnv *env); > typedef void * (*TestMigrateStartHook)(QTestState *from, > QTestState *to); > > + > +/* > + * A hook that runs after the src and dst QEMUs have been created, but > + * before the migration is started. This can be used to run routines > + * that require the QTestState object. > + * > + * Returns: NULL, or a pointer to opaque state to be > + * later passed to the TestMigrateEndHook > + */ > +typedef void * (*TestMigrateStartHookFull)(QTestState *from, > + QTestState *to, > + void *opaque); > + > /* > * A hook that runs after the migration has finished, > * regardless of whether it succeeded or failed, but > @@ -196,6 +209,9 @@ typedef struct { > /* Optional: callback to run at finish to cleanup */ > TestMigrateEndHook end_hook; > > + TestMigrateStartHookFull start_hook_full; > + void *start_hook_data; > + > /* > * Optional: normally we expect the migration process to complete. > * > -- > 2.51.0 > -- Peter Xu
