]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/qtest/migration: Fix cpr-tests in case the machine is not available
authorThomas Huth <thuth@redhat.com>
Tue, 30 Sep 2025 09:09:32 +0000 (11:09 +0200)
committerFabiano Rosas <farosas@suse.de>
Wed, 1 Oct 2025 20:09:21 +0000 (17:09 -0300)
When QEMU has been compiled with "--without-default-devices", the
migration cpr-tests are currently failing since the first test leaves
a socket file behind that avoids that the second test can be initialized
correctly. Make sure that we delete the socket file in case that the
migrate_start() failed due to the missing machine.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250930090932.235151-1-thuth@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
tests/qtest/migration/cpr-tests.c
tests/qtest/migration/framework.c
tests/qtest/migration/framework.h

index 5e764a67876e08ba482bd8a425d742058c4311f1..c4ce60ff66bb35506439a1ea89a28ef7d9c1bb9a 100644 (file)
@@ -97,7 +97,10 @@ static void test_mode_transfer_common(bool incoming_defer)
         .start_hook = test_mode_transfer_start,
     };
 
-    test_precopy_common(&args);
+    if (test_precopy_common(&args) < 0) {
+        close(cpr_sockfd);
+        unlink(cpr_path);
+    }
 }
 
 static void test_mode_transfer(void)
index 407c9023c05117c1e72c87127e4f5455db25bd2a..a044b354658e5d3e8c559c5bdcc5d0dd0dd9f6cb 100644 (file)
@@ -736,7 +736,7 @@ void test_postcopy_recovery_common(MigrateCommon *args)
     migrate_postcopy_complete(from, to, args);
 }
 
-void test_precopy_common(MigrateCommon *args)
+int test_precopy_common(MigrateCommon *args)
 {
     QTestState *from, *to;
     void *data_hook = NULL;
@@ -746,7 +746,7 @@ void test_precopy_common(MigrateCommon *args)
     g_assert(!args->cpr_channel || args->connect_channels);
 
     if (migrate_start(&from, &to, args->listen_uri, &args->start)) {
-        return;
+        return -1;
     }
 
     if (args->start_hook) {
@@ -869,6 +869,8 @@ finish:
     }
 
     migrate_end(from, to, args->result == MIG_TEST_SUCCEED);
+
+    return 0;
 }
 
 static void file_dirty_offset_region(void)
index 01e425e64e2d7ec702a9eb668587970c0e66504a..744040d53a14e1b834e0f84157c0692a1584cafe 100644 (file)
@@ -227,7 +227,7 @@ void migrate_end(QTestState *from, QTestState *to, bool test_dest);
 
 void test_postcopy_common(MigrateCommon *args);
 void test_postcopy_recovery_common(MigrateCommon *args);
-void test_precopy_common(MigrateCommon *args);
+int test_precopy_common(MigrateCommon *args);
 void test_file_common(MigrateCommon *args, bool stop_src);
 void *migrate_hook_start_precopy_tcp_multifd_common(QTestState *from,
                                                     QTestState *to,