tests/qtest/migration: Set file URI by default
Most file: tests use the same URI. Make it a default in the 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-4-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>
Fabiano Rosas committed
May 5, 2026 at 13:09 UTC
6714d20f97491bd4a9ccb2daf998db8cf724a517
2 files changed
+6
-29
tests/qtest/migration/file-tests.c
-29
@@ -67,9 +67,6 @@ static void test_file_connect_outgoing_fd_leak(char *name, MigrateCommon *args)
67
68
static void test_precopy_file(char *name, MigrateCommon *args)
69
{
70
- g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
71
- FILE_TEST_FILENAME);
72
- args->connect_uri = uri;
70
test_file_common(args, true);
71
}
72
@@ -142,11 +139,6 @@ static void test_precopy_file_offset_bad(char *name, MigrateCommon *args)
139
140
static void test_precopy_file_mapped_ram_live(char *name, MigrateCommon *args)
141
{
145
- g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
146
- FILE_TEST_FILENAME);
147
-
148
- args->connect_uri = uri;
149
-
142
args->start.caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true;
143
144
test_file_common(args, false);
@@ -154,11 +146,6 @@ static void test_precopy_file_mapped_ram_live(char *name, MigrateCommon *args)
146
147
static void test_precopy_file_mapped_ram(char *name, MigrateCommon *args)
148
{
157
- g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
158
- FILE_TEST_FILENAME);
159
-
160
- args->connect_uri = uri;
161
-
149
args->start.caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true;
150
151
test_file_common(args, true);
@@ -166,10 +153,6 @@ static void test_precopy_file_mapped_ram(char *name, MigrateCommon *args)
153
154
static void test_multifd_file_mapped_ram_live(char *name, MigrateCommon *args)
155
{
169
- g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
170
- FILE_TEST_FILENAME);
171
- args->connect_uri = uri;
172
-
156
args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
157
args->start.caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true;
158
@@ -178,11 +161,6 @@ static void test_multifd_file_mapped_ram_live(char *name, MigrateCommon *args)
161
162
static void test_multifd_file_mapped_ram(char *name, MigrateCommon *args)
163
{
181
- g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
182
- FILE_TEST_FILENAME);
183
-
184
- args->connect_uri = uri;
185
-
164
args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
165
args->start.caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true;
166
@@ -200,9 +178,6 @@ static void *migrate_hook_start_multifd_mapped_ram_dio(QTestState *from,
178
179
static void test_multifd_file_mapped_ram_dio(char *name, MigrateCommon *args)
180
{
203
- g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
204
- FILE_TEST_FILENAME);
205
- args->connect_uri = uri;
181
args->start_hook = migrate_hook_start_multifd_mapped_ram_dio;
182
183
args->start.caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true;
@@ -316,10 +291,6 @@ static void migration_test_add_file_smoke(MigrationTestEnv *env)
291
static void
292
test_precopy_file_mapped_ram_ignore_shared(char *name, MigrateCommon *args)
293
{
319
- g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
320
- FILE_TEST_FILENAME);
321
- args->connect_uri = uri;
322
-
294
args->start.caps[MIGRATION_CAPABILITY_MAPPED_RAM] = true;
295
args->start.caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] = true;
296
tests/qtest/migration/framework.c
+6
@@ -971,11 +971,17 @@ void test_file_common(MigrateCommon *args, bool stop_src)
971
QTestState *from, *to;
972
void *data_hook = NULL;
973
bool check_offset = false;
974
+ g_autofree char *uri = NULL;
975
976
if (migrate_start(&from, &to, "defer", &args->start)) {
977
return;
978
}
979
980
+ if (!args->connect_uri) {
981
+ uri = g_strdup_printf("file:%s/%s", tmpfs, FILE_TEST_FILENAME);
982
+ args->connect_uri = uri;
983
+ }
984
+
985
/*
986
* File migration is never live. We can keep the source VM running
987
* during migration, but the destination will not be running