@samitouri / QOSamiQemu / commits / 0fd673ca8d

tests/qtest/migration: Defer by default in precopy_common

As a design direction, we're restricting the usage of the command line option -incoming <URI>. The alternative -incoming defer should be used instead. Make all precopy_common tests defer by default. Using the defer option means that QEMU will not start the incoming migration automatically. Add the incoming QMP command. With the added command, the invocation at the multifd_common hook becomes redundant, so remove it. Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Lukas Straub <lukasstraub2@web.de> Tested-by: Lukas Straub <lukasstraub2@web.de> Link: https://lore.kernel.org/r/20260505160915.25558-8-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>

Fabiano Rosas committed May 5, 2026 at 13:09 UTC 0fd673ca8df29af08d3e7b236a995c97e88e2607
5 files changed +14 -45
tests/qtest/migration/colo-tests.c
+4 -8
@@ -45,7 +45,7 @@ static int test_colo_common(MigrateCommon *args,
45 args->start.caps[MIGRATION_CAPABILITY_RETURN_PATH] = true;
46 args->start.caps[MIGRATION_CAPABILITY_X_COLO] = true;
47
48 - if (migrate_start(&from, &to, args->listen_uri, &args->start)) {
48 + if (migrate_start(&from, &to, "defer", &args->start)) {
49 return -1;
50 }
51
@@ -55,6 +55,8 @@ static int test_colo_common(MigrateCommon *args,
55 data_hook = args->start_hook(from, to);
56 }
57
58 + migrate_incoming_qmp(to, args->listen_uri, NULL, "{}");
59 +
60 migrate_ensure_converge(from);
61 wait_for_serial("src_serial");
62
@@ -107,17 +109,11 @@ static void test_colo_plain_common(MigrateCommon *args,
109 test_colo_common(args, failover_during_checkpoint, primary_failover);
110 }
111
110 -static void *hook_start_multifd(QTestState *from, QTestState *to)
111 -{
112 - return migrate_hook_start_precopy_tcp_multifd_common(from, to, "none");
113 -}
114 -
112 static void test_colo_multifd_common(MigrateCommon *args,
113 bool failover_during_checkpoint,
114 bool primary_failover)
115 {
119 - args->listen_uri = "defer";
120 - args->start_hook = hook_start_multifd;
116 + args->listen_uri = "tcp:127.0.0.1:0";
117 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
118 test_colo_common(args, failover_during_checkpoint, primary_failover);
119 }
tests/qtest/migration/compression-tests.c
-6
@@ -33,7 +33,6 @@ migrate_hook_start_precopy_tcp_multifd_zstd(QTestState *from,
33
34 static void test_multifd_tcp_zstd(char *name, MigrateCommon *args)
35 {
36 - args->listen_uri = "defer";
36 args->start_hook = migrate_hook_start_precopy_tcp_multifd_zstd;
37
38 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
@@ -43,7 +42,6 @@ static void test_multifd_tcp_zstd(char *name, MigrateCommon *args)
42
43 static void test_multifd_postcopy_tcp_zstd(char *name, MigrateCommon *args)
44 {
46 - args->listen_uri = "defer";
45 args->start_hook = migrate_hook_start_precopy_tcp_multifd_zstd,
46
47 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
@@ -66,7 +64,6 @@ migrate_hook_start_precopy_tcp_multifd_qatzip(QTestState *from,
64
65 static void test_multifd_tcp_qatzip(char *name, MigrateCommon *args)
66 {
69 - args->listen_uri = "defer";
67 args->start_hook = migrate_hook_start_precopy_tcp_multifd_qatzip;
68
69 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
@@ -85,7 +82,6 @@ migrate_hook_start_precopy_tcp_multifd_qpl(QTestState *from,
82
83 static void test_multifd_tcp_qpl(char *name, MigrateCommon *args)
84 {
88 - args->listen_uri = "defer";
85 args->start_hook = migrate_hook_start_precopy_tcp_multifd_qpl;
86
87 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
@@ -104,7 +100,6 @@ migrate_hook_start_precopy_tcp_multifd_uadk(QTestState *from,
100
101 static void test_multifd_tcp_uadk(char *name, MigrateCommon *args)
102 {
107 - args->listen_uri = "defer";
103 args->start_hook = migrate_hook_start_precopy_tcp_multifd_uadk;
104
105 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
@@ -152,7 +147,6 @@ migrate_hook_start_precopy_tcp_multifd_zlib(QTestState *from,
147
148 static void test_multifd_tcp_zlib(char *name, MigrateCommon *args)
149 {
155 - args->listen_uri = "defer";
150 args->start_hook = migrate_hook_start_precopy_tcp_multifd_zlib;
151
152 args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
tests/qtest/migration/framework.c
+8 -7
@@ -834,11 +834,15 @@ int test_precopy_common(MigrateCommon *args)
834 void *data_hook = NULL;
835 QObject *channels = NULL;
836
837 - if (!args->listen_uri) {
837 + assert(!args->connect_uri);
838 +
839 + if (args->listen_uri) {
840 + args->connect_uri = args->listen_uri;
841 + } else {
842 args->listen_uri = "tcp:127.0.0.1:0";
843 }
844
841 - if (migrate_start(&from, &to, args->listen_uri, &args->start)) {
845 + if (migrate_start(&from, &to, "defer", &args->start)) {
846 return -1;
847 }
848
@@ -846,6 +850,8 @@ int test_precopy_common(MigrateCommon *args)
850 data_hook = args->start_hook(from, to);
851 }
852
853 + migrate_incoming_qmp(to, args->listen_uri, NULL, "{}");
854 +
855 /* Wait for the first serial output from the source */
856 if (args->result == MIG_TEST_SUCCEED) {
857 wait_for_serial("src_serial");
@@ -943,7 +949,6 @@ void test_precopy_unix_common(MigrateCommon *args)
949 g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
950
951 args->listen_uri = uri;
946 - args->connect_uri = uri;
952 test_precopy_common(args);
953 }
954
@@ -1064,10 +1069,6 @@ void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from,
1069 {
1070 migrate_set_parameter_str(from, "multifd-compression", method);
1071 migrate_set_parameter_str(to, "multifd-compression", method);
1067 -
1068 - /* Start incoming migration from the 1st socket */
1069 - migrate_incoming_qmp(to, "tcp:127.0.0.1:0", NULL, "{}");
1070 -
1072 return NULL;
1073 }
1074
tests/qtest/migration/precopy-tests.c
+1 -10
@@ -162,7 +162,6 @@ static void __test_precopy_rdma_plain(MigrateCommon *args, bool ipv6)
162 g_autofree char *uri = g_strdup_printf("rdma:%s:29200", buffer);
163
164 args->listen_uri = uri;
165 - args->connect_uri = uri;
165
166 test_precopy_common(args);
167 }
@@ -214,9 +213,6 @@ static void *migrate_hook_start_fd(QTestState *from,
213 " 'arguments': { 'fdname': 'fd-mig' }}");
214 close(pair[0]);
215
217 - /* Start incoming migration from the 1st socket */
218 - migrate_incoming_qmp(to, "fd:fd-mig", NULL, "{}");
219 -
216 /* Send the 2nd socket to the target */
217 qtest_qmp_fds_assert_success(from, &pair[1], 1,
218 "{ 'execute': 'getfd',"
@@ -257,8 +253,7 @@ static void migrate_hook_end_fd(QTestState *from,
253
254 static void test_precopy_fd_socket(char *name, MigrateCommon *args)
255 {
260 - args->listen_uri = "defer";
261 - args->connect_uri = "fd:fd-mig";
256 + args->listen_uri = "fd:fd-mig";
257 args->start_hook = migrate_hook_start_fd;
258 args->end_hook = migrate_hook_end_fd;
259
@@ -354,7 +349,6 @@ migrate_hook_start_precopy_tcp_multifd_no_zero_page(QTestState *from,
349
350 static void test_multifd_tcp_uri_none(char *name, MigrateCommon *args)
351 {
357 - args->listen_uri = "defer";
352 args->start_hook = migrate_hook_start_precopy_tcp_multifd;
353 /*
354 * Multifd is more complicated than most of the features, it
@@ -370,7 +364,6 @@ static void test_multifd_tcp_uri_none(char *name, MigrateCommon *args)
364
365 static void test_multifd_tcp_zero_page_legacy(char *name, MigrateCommon *args)
366 {
373 - args->listen_uri = "defer";
367 args->start_hook = migrate_hook_start_precopy_tcp_multifd_zero_page_legacy;
368 /*
369 * Multifd is more complicated than most of the features, it
@@ -386,7 +379,6 @@ static void test_multifd_tcp_zero_page_legacy(char *name, MigrateCommon *args)
379
380 static void test_multifd_tcp_no_zero_page(char *name, MigrateCommon *args)
381 {
389 - args->listen_uri = "defer";
382 args->start_hook = migrate_hook_start_precopy_tcp_multifd_no_zero_page;
383 /*
384 * Multifd is more complicated than most of the features, it
@@ -402,7 +394,6 @@ static void test_multifd_tcp_no_zero_page(char *name, MigrateCommon *args)
394
395 static void test_multifd_tcp_channels_none(char *name, MigrateCommon *args)
396 {
405 - args->listen_uri = "defer";
397 args->start_hook = migrate_hook_start_precopy_tcp_multifd;
398 args->live = true;
399 args->connect_channels = ("[ { 'channel-type': 'main',"
tests/qtest/migration/tls-tests.c
+1 -14
@@ -436,8 +436,7 @@ static void test_precopy_unix_tls_x509_default_host(char *name,
436 {
437 g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
438
439 - args->connect_uri = uri;
440 - args->listen_uri = "defer";
439 + args->listen_uri = uri;
440 args->start_hook = migrate_hook_start_tls_x509_default_host;
441 args->end_hook = migrate_hook_end_tls_x509;
442 args->result = MIG_TEST_FAIL;
@@ -511,8 +510,6 @@ migrate_hook_start_tls_x509_no_host(QTestState *from, QTestState *to)
510
511 static void test_precopy_tcp_tls_no_hostname(char *name, MigrateCommon *args)
512 {
514 - args->listen_uri = "defer";
515 - args->connect_uri = "tcp:127.0.0.1:0";
513 args->start_hook = migrate_hook_start_tls_x509_no_host;
514 args->end_hook = migrate_hook_end_tls_x509;
515 args->result = MIG_TEST_FAIL;
@@ -544,8 +541,6 @@ static void test_precopy_tcp_tls_x509_override_host(char *name,
541 static void test_precopy_tcp_tls_x509_mismatch_host(char *name,
542 MigrateCommon *args)
543 {
547 - args->listen_uri = "defer";
548 - args->connect_uri = "tcp:127.0.0.1:0";
544 args->start_hook = migrate_hook_start_tls_x509_mismatch_host;
545 args->end_hook = migrate_hook_end_tls_x509;
546 args->result = MIG_TEST_FAIL;
@@ -658,7 +653,6 @@ migrate_hook_start_multifd_tls_x509_reject_anon_client(QTestState *from,
653
654 static void test_multifd_tcp_tls_psk_match(char *name, MigrateCommon *args)
655 {
661 - args->listen_uri = "defer";
656 args->start_hook = migrate_hook_start_multifd_tcp_tls_psk_match;
657 args->end_hook = migrate_hook_end_tls_psk;
658
@@ -669,7 +663,6 @@ static void test_multifd_tcp_tls_psk_match(char *name, MigrateCommon *args)
663
664 static void test_multifd_tcp_tls_psk_mismatch(char *name, MigrateCommon *args)
665 {
672 - args->listen_uri = "defer";
666 args->start_hook = migrate_hook_start_multifd_tcp_tls_psk_mismatch;
667 args->end_hook = migrate_hook_end_tls_psk;
668 args->result = MIG_TEST_FAIL;
@@ -683,7 +676,6 @@ static void test_multifd_tcp_tls_psk_mismatch(char *name, MigrateCommon *args)
676 static void test_multifd_postcopy_tcp_tls_psk_match(char *name,
677 MigrateCommon *args)
678 {
686 - args->listen_uri = "defer";
679 args->start_hook = migrate_hook_start_multifd_tcp_tls_psk_match;
680 args->end_hook = migrate_hook_end_tls_psk;
681
@@ -697,7 +689,6 @@ static void test_multifd_postcopy_tcp_tls_psk_match(char *name,
689 static void test_multifd_tcp_tls_x509_default_host(char *name,
690 MigrateCommon *args)
691 {
700 - args->listen_uri = "defer";
692 args->start_hook = migrate_hook_start_multifd_tls_x509_default_host;
693 args->end_hook = migrate_hook_end_tls_x509;
694
@@ -709,7 +700,6 @@ static void test_multifd_tcp_tls_x509_default_host(char *name,
700 static void test_multifd_tcp_tls_x509_override_host(char *name,
701 MigrateCommon *args)
702 {
712 - args->listen_uri = "defer";
703 args->start_hook = migrate_hook_start_multifd_tls_x509_override_host;
704 args->end_hook = migrate_hook_end_tls_x509;
705
@@ -734,7 +724,6 @@ static void test_multifd_tcp_tls_x509_mismatch_host(char *name,
724 * to load migration state, and thus just aborts the migration
725 * without exiting.
726 */
737 - args->listen_uri = "defer";
727 args->start_hook = migrate_hook_start_multifd_tls_x509_mismatch_host;
728 args->end_hook = migrate_hook_end_tls_x509;
729 args->result = MIG_TEST_FAIL;
@@ -748,7 +737,6 @@ static void test_multifd_tcp_tls_x509_mismatch_host(char *name,
737 static void test_multifd_tcp_tls_x509_allow_anon_client(char *name,
738 MigrateCommon *args)
739 {
751 - args->listen_uri = "defer";
740 args->start_hook = migrate_hook_start_multifd_tls_x509_allow_anon_client;
741 args->end_hook = migrate_hook_end_tls_x509;
742
@@ -760,7 +748,6 @@ static void test_multifd_tcp_tls_x509_allow_anon_client(char *name,
748 static void test_multifd_tcp_tls_x509_reject_anon_client(char *name,
749 MigrateCommon *args)
750 {
763 - args->listen_uri = "defer";
751 args->start_hook = migrate_hook_start_multifd_tls_x509_reject_anon_client;
752 args->end_hook = migrate_hook_end_tls_x509;
753 args->result = MIG_TEST_FAIL;