This solution is heavily based on Daniel's original approach here, but hopefully a cleaner way to impl:
https://lore.kernel.org/r/20230601161347.1803440-11-berra...@redhat.com The difference is we use the switchover-hold flag rather than tuning bw+downtime to guide test convergence, comparing to use the magic offset. One thing needs caution is the postcopy test - we used to only make it non-converge for precopy. Now we need the paired migrate_ensure_converge() to make sure postcopy can still complete or otherwise the flag will stops the final switchover from postcopy->finish. This can achieve similar goal of previous patch "tests/qtest: massively speed up migration-test" but without magic offset to write or monitoring. With this flag, we can safely always run migration tests with full speed (bw=0). The initial solution can reduce migration-test time from 8min to 1min40s, this patch can further reduce it from 1m40s to ~1m per my local test. Signed-off-by: Peter Xu <pet...@redhat.com> --- tests/qtest/migration-test.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b0c355bbd9..3a583238e1 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -433,16 +433,13 @@ static void migrate_set_parameter_bool(QTestState *who, const char *parameter, static void migrate_ensure_non_converge(QTestState *who) { - /* Can't converge with 1ms downtime + 3 mbs bandwidth limit */ - migrate_set_parameter_int(who, "max-bandwidth", 3 * 1000 * 1000); - migrate_set_parameter_int(who, "downtime-limit", 1); + /* Hold off switchover for precopy only */ + migrate_set_parameter_bool(who, "switchover-hold", true); } static void migrate_ensure_converge(QTestState *who) { - /* Should converge with 30s downtime + 1 gbs bandwidth limit */ - migrate_set_parameter_int(who, "max-bandwidth", 1 * 1000 * 1000 * 1000); - migrate_set_parameter_int(who, "downtime-limit", 30 * 1000); + migrate_set_parameter_bool(who, "switchover-hold", false); } static void migrate_pause(QTestState *who) @@ -492,6 +489,13 @@ static void migrate_postcopy_start(QTestState *from, QTestState *to) } qtest_qmp_eventwait(to, "RESUME"); + + /* + * Now allow precopy switchover (which will allow completion). This + * needs to be done after migrate-start-postcopy to make sure we switch + * to postcopy first. + */ + migrate_ensure_converge(from); } typedef struct { @@ -736,6 +740,14 @@ static int test_migrate_start(QTestState **from, QTestState **to, unlink(shmem_path); } + /* + * By default, use full speed for precopy in qtests as that will reduce + * the time of testing. The default bandwidth (128MB/s) may be too slow + * in this case. Specific test can overwrite this value after the + * function returns but before starting migration. + */ + migrate_set_parameter_int(*from, "max-bandwidth", 0); + return 0; } -- 2.40.1