tests/qtest/migration: Unify URIs
The migration tests have always used localhost migration and therefore the same URI for both sides of migration. Change the listen_uri and connect_uri into a single uri variable. For migrations using sockets, there's the possibility of detecting the socket address the destination side is using. For those, keep using different variables for migrate_qmp and migrate_incoming_qmp. Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Lukas Straub <lukasstraub2@web.de> Tested-by: Lukas Straub <lukasstraub2@web.de> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20260505160915.25558-16-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
@@ -55,12 +55,12 @@ static int test_colo_common(MigrateCommon *args,
|
||||
data_hook = args->start_hook(from, to);
|
||||
}
|
||||
|
||||
migrate_incoming_qmp(to, args->listen_uri, NULL, "{}");
|
||||
migrate_incoming_qmp(to, args->uri, NULL, "{}");
|
||||
|
||||
migrate_ensure_converge(from);
|
||||
wait_for_serial("src_serial");
|
||||
|
||||
migrate_qmp(from, to, args->connect_uri, NULL, "{}");
|
||||
migrate_qmp(from, to, NULL, NULL, "{}");
|
||||
|
||||
wait_for_migration_status(from, "colo", NULL);
|
||||
wait_for_resume(to, get_dst());
|
||||
@@ -105,7 +105,7 @@ static void test_colo_plain_common(MigrateCommon *args,
|
||||
bool failover_during_checkpoint,
|
||||
bool primary_failover)
|
||||
{
|
||||
args->listen_uri = "tcp:127.0.0.1:0";
|
||||
args->uri = "tcp:127.0.0.1:0";
|
||||
test_colo_common(args, failover_during_checkpoint, primary_failover);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ static void test_colo_multifd_common(MigrateCommon *args,
|
||||
bool failover_during_checkpoint,
|
||||
bool primary_failover)
|
||||
{
|
||||
args->listen_uri = "tcp:127.0.0.1:0";
|
||||
args->uri = "tcp:127.0.0.1:0";
|
||||
args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
|
||||
test_colo_common(args, failover_during_checkpoint, primary_failover);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ static void test_mode_reboot(char *name, MigrateCommon *args)
|
||||
g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
|
||||
FILE_TEST_FILENAME);
|
||||
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
args->start_hook = migrate_hook_start_mode_reboot;
|
||||
|
||||
args->start.mem_type = MEM_TYPE_SHMEM;
|
||||
@@ -226,7 +226,7 @@ static void test_cpr_exec(MigrateCommon *args)
|
||||
{
|
||||
QTestState *from, *to;
|
||||
void *data_hook = NULL;
|
||||
g_autofree char *connect_uri = g_strdup(args->connect_uri);
|
||||
g_autofree char *connect_uri = g_strdup(args->uri);
|
||||
g_autofree char *filename = g_strdup_printf("%s/%s", tmpfs,
|
||||
FILE_TEST_FILENAME);
|
||||
|
||||
@@ -280,7 +280,7 @@ static void test_mode_exec(char *name, MigrateCommon *args)
|
||||
{
|
||||
g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs,
|
||||
FILE_TEST_FILENAME);
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
args->start_hook = test_mode_exec_start;
|
||||
|
||||
args->start.only_source = true;
|
||||
|
||||
@@ -107,7 +107,7 @@ static void test_precopy_file_offset_fdset(char *name, MigrateCommon *args)
|
||||
{
|
||||
g_autofree char *uri = g_strdup_printf("file:/dev/fdset/1,offset=%d",
|
||||
FILE_TEST_OFFSET);
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
args->start_hook = migrate_hook_start_file_offset_fdset;
|
||||
|
||||
test_file_common(args, false);
|
||||
@@ -120,7 +120,7 @@ static void test_precopy_file_offset(char *name, MigrateCommon *args)
|
||||
FILE_TEST_FILENAME,
|
||||
FILE_TEST_OFFSET);
|
||||
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
test_file_common(args, false);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ static void test_precopy_file_offset_bad(char *name, MigrateCommon *args)
|
||||
g_autofree char *uri = g_strdup_printf("file:%s/%s,offset=0x20M",
|
||||
tmpfs, FILE_TEST_FILENAME);
|
||||
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
args->result = MIG_TEST_QMP_ERROR;
|
||||
|
||||
test_file_common(args, false);
|
||||
@@ -247,7 +247,7 @@ static void test_multifd_file_mapped_ram_fdset(char *name, MigrateCommon *args)
|
||||
g_autofree char *uri = g_strdup_printf("file:/dev/fdset/1,offset=%d",
|
||||
FILE_TEST_OFFSET);
|
||||
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
args->start_hook = migrate_hook_start_multifd_mapped_ram_fdset;
|
||||
args->end_hook = migrate_hook_end_multifd_mapped_ram_fdset;
|
||||
|
||||
@@ -262,7 +262,7 @@ static void test_multifd_file_mapped_ram_fdset_dio(char *name,
|
||||
{
|
||||
g_autofree char *uri = g_strdup_printf("file:/dev/fdset/1,offset=%d",
|
||||
FILE_TEST_OFFSET);
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
args->start_hook = migrate_hook_start_multifd_mapped_ram_fdset_dio;
|
||||
args->end_hook = migrate_hook_end_multifd_mapped_ram_fdset;
|
||||
|
||||
|
||||
@@ -832,14 +832,7 @@ int test_precopy_common(MigrateCommon *args)
|
||||
QTestState *from, *to;
|
||||
void *data_hook = NULL;
|
||||
QObject *channels = NULL;
|
||||
|
||||
assert(!args->connect_uri);
|
||||
|
||||
if (args->listen_uri) {
|
||||
args->connect_uri = args->listen_uri;
|
||||
} else {
|
||||
args->listen_uri = "tcp:127.0.0.1:0";
|
||||
}
|
||||
const char *listen_uri = args->uri ?: "tcp:127.0.0.1:0";
|
||||
|
||||
if (migrate_start(&from, &to, &args->start)) {
|
||||
return -1;
|
||||
@@ -849,7 +842,7 @@ int test_precopy_common(MigrateCommon *args)
|
||||
data_hook = args->start_hook(from, to);
|
||||
}
|
||||
|
||||
migrate_incoming_qmp(to, args->listen_uri, NULL, "{}");
|
||||
migrate_incoming_qmp(to, listen_uri, NULL, "{}");
|
||||
|
||||
/* Wait for the first serial output from the source */
|
||||
if (args->result == MIG_TEST_SUCCEED) {
|
||||
@@ -879,11 +872,11 @@ int test_precopy_common(MigrateCommon *args)
|
||||
}
|
||||
|
||||
if (args->result == MIG_TEST_QMP_ERROR) {
|
||||
migrate_qmp_fail(from, args->connect_uri, channels, "{}");
|
||||
migrate_qmp_fail(from, args->uri, channels, "{}");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
migrate_qmp(from, to, args->connect_uri, channels, "{}");
|
||||
migrate_qmp(from, to, args->uri, channels, "{}");
|
||||
|
||||
if (args->result != MIG_TEST_SUCCEED) {
|
||||
bool allow_active = args->result == MIG_TEST_FAIL;
|
||||
@@ -947,7 +940,7 @@ void test_precopy_unix_common(MigrateCommon *args)
|
||||
{
|
||||
g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
|
||||
|
||||
args->listen_uri = uri;
|
||||
args->uri = uri;
|
||||
test_precopy_common(args);
|
||||
}
|
||||
|
||||
@@ -994,9 +987,9 @@ void test_file_common(MigrateCommon *args, bool stop_src)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args->connect_uri) {
|
||||
if (!args->uri) {
|
||||
uri = g_strdup_printf("file:%s/%s", tmpfs, FILE_TEST_FILENAME);
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1006,7 +999,7 @@ void test_file_common(MigrateCommon *args, bool stop_src)
|
||||
*/
|
||||
g_assert_false(args->live);
|
||||
|
||||
if (g_strrstr(args->connect_uri, "offset=")) {
|
||||
if (g_strrstr(args->uri, "offset=")) {
|
||||
check_offset = true;
|
||||
/*
|
||||
* This comes before the start_hook because it's equivalent to
|
||||
@@ -1029,18 +1022,18 @@ void test_file_common(MigrateCommon *args, bool stop_src)
|
||||
}
|
||||
|
||||
if (args->result == MIG_TEST_QMP_ERROR) {
|
||||
migrate_qmp_fail(from, args->connect_uri, NULL, "{}");
|
||||
migrate_qmp_fail(from, args->uri, NULL, "{}");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
migrate_qmp(from, to, args->connect_uri, NULL, "{}");
|
||||
migrate_qmp(from, to, args->uri, NULL, "{}");
|
||||
wait_for_migration_complete(from);
|
||||
|
||||
/*
|
||||
* We need to wait for the source to finish before starting the
|
||||
* destination.
|
||||
*/
|
||||
migrate_incoming_qmp(to, args->connect_uri, NULL, "{}");
|
||||
migrate_incoming_qmp(to, args->uri, NULL, "{}");
|
||||
wait_for_migration_complete(to);
|
||||
|
||||
if (stop_src) {
|
||||
|
||||
@@ -163,16 +163,14 @@ typedef struct {
|
||||
/* Optional: fine tune start parameters */
|
||||
MigrateStart start;
|
||||
|
||||
/* Required: the URI for the dst QEMU to listen on */
|
||||
const char *listen_uri;
|
||||
|
||||
/*
|
||||
* Optional: the URI for the src QEMU to connect to
|
||||
* If NULL, then it will query the dst QEMU for its actual
|
||||
* listening address and use that as the connect address.
|
||||
* This allows for dynamically picking a free TCP port.
|
||||
* Optional: the migration URI. If NULL, the common code should
|
||||
* provide a default. For socket migration, the source QEMU may
|
||||
* query the dst QEMU for the listening address and use that as
|
||||
* the connection address. This allows for dynamically picking a
|
||||
* free TCP port.
|
||||
*/
|
||||
const char *connect_uri;
|
||||
const char *uri;
|
||||
|
||||
/*
|
||||
* Optional: JSON-formatted list of src QEMU URIs. If a port is
|
||||
|
||||
@@ -196,7 +196,7 @@ static void do_test_validate_uri_channel(MigrateCommon *args)
|
||||
channels = args->connect_channels ?
|
||||
qobject_from_json(args->connect_channels, &error_abort) :
|
||||
NULL;
|
||||
migrate_qmp_fail(from, args->connect_uri, channels, "{}");
|
||||
migrate_qmp_fail(from, args->uri, channels, "{}");
|
||||
|
||||
migrate_end(from, to, false);
|
||||
}
|
||||
@@ -252,7 +252,7 @@ static void test_validate_caps_pair(char *test_path, MigrateCommon *args)
|
||||
|
||||
static void test_validate_uri_channels_both_set(char *name, MigrateCommon *args)
|
||||
{
|
||||
args->connect_uri = "tcp:127.0.0.1:0",
|
||||
args->uri = "tcp:127.0.0.1:0",
|
||||
args->connect_channels = ("[ { ""'channel-type': 'main',"
|
||||
" 'addr': { 'transport': 'socket',"
|
||||
" 'type': 'inet',"
|
||||
|
||||
@@ -161,7 +161,7 @@ static void __test_precopy_rdma_plain(MigrateCommon *args, bool ipv6)
|
||||
**/
|
||||
g_autofree char *uri = g_strdup_printf("rdma:%s:29200", buffer);
|
||||
|
||||
args->listen_uri = uri;
|
||||
args->uri = uri;
|
||||
|
||||
test_precopy_common(args);
|
||||
}
|
||||
@@ -253,7 +253,7 @@ static void migrate_hook_end_fd(QTestState *from,
|
||||
|
||||
static void test_precopy_fd_socket(char *name, MigrateCommon *args)
|
||||
{
|
||||
args->listen_uri = "fd:fd-mig";
|
||||
args->uri = "fd:fd-mig";
|
||||
args->start_hook = migrate_hook_start_fd;
|
||||
args->end_hook = migrate_hook_end_fd;
|
||||
|
||||
@@ -970,7 +970,7 @@ static void test_dirty_limit(char *name, MigrateCommon *args)
|
||||
args->start.hide_stderr = true;
|
||||
args->start.use_dirty_ring = true;
|
||||
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
|
||||
/* Start src, dst vm */
|
||||
if (migrate_start(&from, &to, &args->start)) {
|
||||
@@ -981,8 +981,8 @@ static void test_dirty_limit(char *name, MigrateCommon *args)
|
||||
migrate_dirty_limit_wait_showup(from, dirtylimit_period, dirtylimit_value);
|
||||
|
||||
/* Start migrate */
|
||||
migrate_incoming_qmp(to, args->connect_uri, NULL, "{}");
|
||||
migrate_qmp(from, to, args->connect_uri, NULL, "{}");
|
||||
migrate_incoming_qmp(to, args->uri, NULL, "{}");
|
||||
migrate_qmp(from, to, args->uri, NULL, "{}");
|
||||
|
||||
/* Wait for dirty limit throttle begin */
|
||||
throttle_us_per_full = 0;
|
||||
@@ -1014,8 +1014,7 @@ static void test_dirty_limit(char *name, MigrateCommon *args)
|
||||
/* Assert dirty limit is not in service */
|
||||
g_assert_cmpint(throttle_us_per_full, ==, 0);
|
||||
|
||||
args->listen_uri = uri;
|
||||
args->connect_uri = uri;
|
||||
args->uri = uri;
|
||||
|
||||
args->start.only_target = true;
|
||||
args->start.use_dirty_ring = true;
|
||||
@@ -1026,8 +1025,8 @@ static void test_dirty_limit(char *name, MigrateCommon *args)
|
||||
}
|
||||
|
||||
/* Start migrate */
|
||||
migrate_incoming_qmp(to, args->listen_uri, NULL, "{}");
|
||||
migrate_qmp(from, to, args->connect_uri, NULL, "{}");
|
||||
migrate_incoming_qmp(to, args->uri, NULL, "{}");
|
||||
migrate_qmp(from, to, args->uri, NULL, "{}");
|
||||
|
||||
/* Wait for dirty limit throttle begin */
|
||||
throttle_us_per_full = 0;
|
||||
|
||||
@@ -436,7 +436,7 @@ static void test_precopy_unix_tls_x509_default_host(char *name,
|
||||
{
|
||||
g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
|
||||
|
||||
args->listen_uri = uri;
|
||||
args->uri = uri;
|
||||
args->start_hook = migrate_hook_start_tls_x509_default_host;
|
||||
args->end_hook = migrate_hook_end_tls_x509;
|
||||
args->result = MIG_TEST_FAIL;
|
||||
|
||||
Reference in New Issue
Block a user