From: Nikolay Borisov <nbori...@suse.com> Add basic tests for file-based migration.
Signed-off-by: Nikolay Borisov <nbori...@suse.com> Signed-off-by: Fabiano Rosas <faro...@suse.de> --- (farosas) fix segfault when connect_uri is not set --- tests/qtest/migration-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 3b615b0da9..13e5cdd5a4 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -748,6 +748,7 @@ static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest) cleanup("migsocket"); cleanup("src_serial"); cleanup("dest_serial"); + cleanup("migfile"); } #ifdef CONFIG_GNUTLS @@ -1371,6 +1372,14 @@ static void test_precopy_common(MigrateCommon *args) * hanging forever if migration didn't converge */ wait_for_migration_complete(from); + /* + * For file based migration the target must begin its migration after + * the source has finished + */ + if (args->connect_uri && strstr(args->connect_uri, "file:")) { + migrate_incoming_qmp(to, args->connect_uri, "{}"); + } + if (!got_stop) { qtest_qmp_eventwait(from, "STOP"); } @@ -1524,6 +1533,17 @@ static void test_precopy_unix_xbzrle(void) test_precopy_common(&args); } +static void test_precopy_file_stream_ram(void) +{ + g_autofree char *uri = g_strdup_printf("file:%s/migfile", tmpfs); + MigrateCommon args = { + .connect_uri = uri, + .listen_uri = "defer", + }; + + test_precopy_common(&args); +} + static void test_precopy_tcp_plain(void) { MigrateCommon args = { @@ -2515,6 +2535,10 @@ int main(int argc, char **argv) qtest_add_func("/migration/bad_dest", test_baddest); qtest_add_func("/migration/precopy/unix/plain", test_precopy_unix_plain); qtest_add_func("/migration/precopy/unix/xbzrle", test_precopy_unix_xbzrle); + + qtest_add_func("/migration/precopy/file/stream-ram", + test_precopy_file_stream_ram); + #ifdef CONFIG_GNUTLS qtest_add_func("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); -- 2.35.3