@samitouri / QOSamiQemu / commits / 0b15d32419

tests/qtest/migration: Use a default TCP URI for precopy

Using a localhost TCP URI for testing is quite common. Set it as a default for precopy tests that don't provide an URI. Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20260505160915.25558-7-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>

Fabiano Rosas committed May 5, 2026 at 13:09 UTC 0b15d32419ea46a64aa7fd2586409d5702dd0579
3 files changed +4 -12
tests/qtest/migration/framework.c
+4
@@ -834,6 +834,10 @@ int test_precopy_common(MigrateCommon *args)
834 void *data_hook = NULL;
835 QObject *channels = NULL;
836
837 + if (!args->listen_uri) {
838 + args->listen_uri = "tcp:127.0.0.1:0";
839 + }
840 +
841 if (migrate_start(&from, &to, args->listen_uri, &args->start)) {
842 return -1;
843 }
tests/qtest/migration/precopy-tests.c
-3
@@ -180,14 +180,11 @@ static void test_precopy_rdma_plain_ipv6(char *name, MigrateCommon *args)
180
181 static void test_precopy_tcp_plain(char *name, MigrateCommon *args)
182 {
183 - args->listen_uri = "tcp:127.0.0.1:0";
184 -
183 test_precopy_common(args);
184 }
185
186 static void test_precopy_tcp_switchover_ack(char *name, MigrateCommon *args)
187 {
190 - args->listen_uri = "tcp:127.0.0.1:0";
188 /*
189 * Source VM must be running in order to consider the switchover ACK
190 * when deciding to do switchover or not.
tests/qtest/migration/tls-tests.c
-9
@@ -459,7 +459,6 @@ static void test_precopy_unix_tls_x509_override_host(char *name,
459
460 static void test_precopy_tcp_tls_psk_match(char *name, MigrateCommon *args)
461 {
462 - args->listen_uri = "tcp:127.0.0.1:0";
462 args->start_hook = migrate_hook_start_tls_psk_match;
463 args->end_hook = migrate_hook_end_tls_psk;
464
@@ -468,7 +467,6 @@ static void test_precopy_tcp_tls_psk_match(char *name, MigrateCommon *args)
467
468 static void test_precopy_tcp_tls_psk_mismatch(char *name, MigrateCommon *args)
469 {
471 - args->listen_uri = "tcp:127.0.0.1:0";
470 args->start_hook = migrate_hook_start_tls_psk_mismatch;
471 args->end_hook = migrate_hook_end_tls_psk;
472 args->result = MIG_TEST_FAIL;
@@ -488,7 +486,6 @@ static void *migrate_hook_start_no_tls(QTestState *from, QTestState *to)
486
487 static void test_precopy_tcp_no_tls(char *name, MigrateCommon *args)
488 {
491 - args->listen_uri = "tcp:127.0.0.1:0";
489 args->start_hook = migrate_hook_start_no_tls;
490 /* the no_tls start hook requires no cleanup actions */
491 args->end_hook = NULL;
@@ -529,7 +526,6 @@ static void test_precopy_tcp_tls_no_hostname(char *name, MigrateCommon *args)
526 static void test_precopy_tcp_tls_x509_default_host(char *name,
527 MigrateCommon *args)
528 {
532 - args->listen_uri = "tcp:127.0.0.1:0";
529 args->start_hook = migrate_hook_start_tls_x509_default_host;
530 args->end_hook = migrate_hook_end_tls_x509;
531
@@ -539,7 +535,6 @@ static void test_precopy_tcp_tls_x509_default_host(char *name,
535 static void test_precopy_tcp_tls_x509_override_host(char *name,
536 MigrateCommon *args)
537 {
542 - args->listen_uri = "tcp:127.0.0.1:0";
538 args->start_hook = migrate_hook_start_tls_x509_override_host;
539 args->end_hook = migrate_hook_end_tls_x509;
540
@@ -563,7 +558,6 @@ static void test_precopy_tcp_tls_x509_mismatch_host(char *name,
558 static void test_precopy_tcp_tls_x509_friendly_client(char *name,
559 MigrateCommon *args)
560 {
566 - args->listen_uri = "tcp:127.0.0.1:0";
561 args->start_hook = migrate_hook_start_tls_x509_friendly_client;
562 args->end_hook = migrate_hook_end_tls_x509;
563
@@ -573,7 +567,6 @@ static void test_precopy_tcp_tls_x509_friendly_client(char *name,
567 static void test_precopy_tcp_tls_x509_hostile_client(char *name,
568 MigrateCommon *args)
569 {
576 - args->listen_uri = "tcp:127.0.0.1:0";
570 args->start_hook = migrate_hook_start_tls_x509_hostile_client;
571 args->end_hook = migrate_hook_end_tls_x509;
572 args->result = MIG_TEST_FAIL;
@@ -586,7 +579,6 @@ static void test_precopy_tcp_tls_x509_hostile_client(char *name,
579 static void test_precopy_tcp_tls_x509_allow_anon_client(char *name,
580 MigrateCommon *args)
581 {
589 - args->listen_uri = "tcp:127.0.0.1:0";
582 args->start_hook = migrate_hook_start_tls_x509_allow_anon_client;
583 args->end_hook = migrate_hook_end_tls_x509;
584
@@ -596,7 +588,6 @@ static void test_precopy_tcp_tls_x509_allow_anon_client(char *name,
588 static void test_precopy_tcp_tls_x509_reject_anon_client(char *name,
589 MigrateCommon *args)
590 {
599 - args->listen_uri = "tcp:127.0.0.1:0";
591 args->start_hook = migrate_hook_start_tls_x509_reject_anon_client;
592 args->end_hook = migrate_hook_end_tls_x509;
593 args->result = MIG_TEST_FAIL;