aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Sistare <steven.sistare@oracle.com>2025-01-15 11:00:46 -0800
committerFabiano Rosas <farosas@suse.de>2025-01-29 11:56:39 -0300
commitf5bac78cd84a8a928ac5f92e4c00772decc30bab (patch)
tree13e27951e689139174baba51b24077f8777815be
parent5357ef823a1f53673eae3e0a9a0d626bc104f8a7 (diff)
downloadqemu-f5bac78cd84a8a928ac5f92e4c00772decc30bab.zip
qemu-f5bac78cd84a8a928ac5f92e4c00772decc30bab.tar.gz
qemu-f5bac78cd84a8a928ac5f92e4c00772decc30bab.tar.bz2
migration-test: defer connection
Add an option to defer connection to the target monitor, needed by the cpr-transfer test. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Link: https://lore.kernel.org/r/1736967650-129648-21-git-send-email-steven.sistare@oracle.com Signed-off-by: Fabiano Rosas <farosas@suse.de>
-rw-r--r--tests/qtest/migration/framework.c22
-rw-r--r--tests/qtest/migration/framework.h3
2 files changed, 22 insertions, 3 deletions
diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
index f7add75..2611c31 100644
--- a/tests/qtest/migration/framework.c
+++ b/tests/qtest/migration/framework.c
@@ -223,6 +223,7 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
const char *bootpath;
g_autoptr(QList) capabilities = migrate_start_get_qmp_capabilities(args);
g_autofree char *memory_backend = NULL;
+ const char *events;
if (args->use_shmem) {
if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) {
@@ -340,22 +341,30 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
&src_state);
}
+ /*
+ * If the monitor connection is deferred, enable events on the command line
+ * so none are missed. This is for testing only, do not set migration
+ * options like this in general.
+ */
+ events = args->defer_target_connect ? "-global migration.x-events=on" : "";
+
cmd_target = g_strdup_printf("-accel kvm%s -accel tcg "
"-machine %s,%s "
"-name target,debug-threads=on "
"%s "
"-serial file:%s/dest_serial "
"-incoming %s "
- "%s %s %s %s",
+ "%s %s %s %s %s",
kvm_opts ? kvm_opts : "",
machine, machine_opts,
memory_backend, tmpfs, uri,
+ events,
arch_opts ? arch_opts : "",
shmem_opts ? shmem_opts : "",
args->opts_target ? args->opts_target : "",
ignore_stderr);
*to = qtest_init_with_env_and_capabilities(QEMU_ENV_DST, cmd_target,
- capabilities, true);
+ capabilities, !args->defer_target_connect);
qtest_qmp_set_event_callback(*to,
migrate_watch_for_events,
&dst_state);
@@ -373,7 +382,9 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
* to mimic as closer as that.
*/
migrate_set_capability(*from, "events", true);
- migrate_set_capability(*to, "events", true);
+ if (!args->defer_target_connect) {
+ migrate_set_capability(*to, "events", true);
+ }
return 0;
}
@@ -733,6 +744,11 @@ void test_precopy_common(MigrateCommon *args)
migrate_qmp(from, to, args->connect_uri, args->connect_channels, "{}");
+ if (args->start.defer_target_connect) {
+ qtest_connect(to);
+ qtest_qmp_handshake(to, NULL);
+ }
+
if (args->result != MIG_TEST_SUCCEED) {
bool allow_active = args->result == MIG_TEST_FAIL;
wait_for_migration_fail(from, allow_active);
diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h
index dd2db1c..32f3a93 100644
--- a/tests/qtest/migration/framework.h
+++ b/tests/qtest/migration/framework.h
@@ -116,6 +116,9 @@ typedef struct {
* size is plugged in. If omitted, "-m %s" is used.
*/
const char *memory_backend;
+
+ /* Do not connect to target monitor and qtest sockets in qtest_init */
+ bool defer_target_connect;
} MigrateStart;
typedef enum PostcopyRecoveryFailStage {