@samitouri / QOSamiQemu / commits / e9852918e4

tests/qtest/migration: Group unix migration tests

Remove some repetition when defining unix: tests by introducing a _common function. Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20260505160915.25558-5-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>

Fabiano Rosas committed May 5, 2026 at 13:09 UTC e9852918e4172c21fadd066ed0253ee03feb67e9
5 files changed +17 -41
tests/qtest/migration/compression-tests.c
+1 -5
@@ -123,10 +123,6 @@ migrate_hook_start_xbzrle(QTestState *from,
123
124 static void test_precopy_unix_xbzrle(char *name, MigrateCommon *args)
125 {
126 - g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
127 -
128 - args->connect_uri = uri;
129 - args->listen_uri = uri;
126 args->start_hook = migrate_hook_start_xbzrle;
127 args->iterations = 2;
128 /*
@@ -137,7 +133,7 @@ static void test_precopy_unix_xbzrle(char *name, MigrateCommon *args)
133
134 args->start.caps[MIGRATION_CAPABILITY_XBZRLE] = true;
135
140 - test_precopy_common(args);
136 + test_precopy_unix_common(args);
137 }
138
139 static void *
tests/qtest/migration/framework.c
+9
@@ -934,6 +934,15 @@ finish:
934 return 0;
935 }
936
937 +void test_precopy_unix_common(MigrateCommon *args)
938 +{
939 + g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
940 +
941 + args->listen_uri = uri;
942 + args->connect_uri = uri;
943 + test_precopy_common(args);
944 +}
945 +
946 static void file_dirty_offset_region(void)
947 {
948 g_autofree char *path = g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FILENAME);
tests/qtest/migration/framework.h
+1
@@ -240,6 +240,7 @@ void test_postcopy_common(MigrateCommon *args);
240 void test_postcopy_recovery_common(MigrateCommon *args,
241 PostcopyRecoveryFailStage fail_stage);
242 int test_precopy_common(MigrateCommon *args);
243 +void test_precopy_unix_common(MigrateCommon *args);
244 void test_file_common(MigrateCommon *args, bool stop_src);
245 void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from,
246 QTestState *to,
tests/qtest/migration/precopy-tests.c
+4 -26
@@ -37,62 +37,40 @@ static char *tmpfs;
37
38 static void test_precopy_unix_plain(char *name, MigrateCommon *args)
39 {
40 - g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
41 -
42 - args->listen_uri = uri;
43 - args->connect_uri = uri;
40 /*
41 * The simplest use case of precopy, covering smoke tests of
42 * get-dirty-log dirty tracking.
43 */
44 args->live = true;
49 -
50 - test_precopy_common(args);
45 + test_precopy_unix_common(args);
46 }
47
48 static void test_precopy_unix_suspend_live(char *name, MigrateCommon *args)
49 {
55 - g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
56 -
57 - args->listen_uri = uri;
58 - args->connect_uri = uri;
50 /*
51 * despite being live, the test is fast because the src
52 * suspends immediately.
53 */
54 args->live = true;
64 -
55 args->start.suspend_me = true;
66 -
67 - test_precopy_common(args);
56 + test_precopy_unix_common(args);
57 }
58
59 static void test_precopy_unix_suspend_notlive(char *name, MigrateCommon *args)
60 {
72 - g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
73 -
74 - args->listen_uri = uri;
75 - args->connect_uri = uri;
61 args->start.suspend_me = true;
77 -
78 - test_precopy_common(args);
62 + test_precopy_unix_common(args);
63 }
64
65 static void test_precopy_unix_dirty_ring(char *name, MigrateCommon *args)
66 {
83 - g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
84 -
85 - args->listen_uri = uri;
86 - args->connect_uri = uri;
67 /*
68 * Besides the precopy/unix basic test, cover dirty ring interface
69 * rather than get-dirty-log.
70 */
71 args->live = true;
92 -
72 args->start.use_dirty_ring = true;
94 -
95 - test_precopy_common(args);
73 + test_precopy_unix_common(args);
74 }
75
76 #ifdef CONFIG_RDMA
tests/qtest/migration/tls-tests.c
+2 -10
@@ -424,14 +424,10 @@ static void test_multifd_postcopy_preempt_recovery_tls_psk(char *name,
424
425 static void test_precopy_unix_tls_psk(char *name, MigrateCommon *args)
426 {
427 - g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
428 -
429 - args->connect_uri = uri;
430 - args->listen_uri = uri;
427 args->start_hook = migrate_hook_start_tls_psk_match;
428 args->end_hook = migrate_hook_end_tls_psk;
429
434 - test_precopy_common(args);
430 + test_precopy_unix_common(args);
431 }
432
433 #ifdef CONFIG_TASN1
@@ -454,14 +450,10 @@ static void test_precopy_unix_tls_x509_default_host(char *name,
450 static void test_precopy_unix_tls_x509_override_host(char *name,
451 MigrateCommon *args)
452 {
457 - g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
458 -
459 - args->connect_uri = uri;
460 - args->listen_uri = uri;
453 args->start_hook = migrate_hook_start_tls_x509_override_host;
454 args->end_hook = migrate_hook_end_tls_x509;
455
464 - test_precopy_common(args);
456 + test_precopy_unix_common(args);
457 }
458 #endif /* CONFIG_TASN1 */
459