[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 08/11] tests/qtest/migration: Move more code under only_targe
From: |
Peter Xu |
Subject: |
[PATCH RFC 08/11] tests/qtest/migration: Move more code under only_target |
Date: |
Tue, 3 Dec 2024 19:51:35 -0500 |
From: Fabiano Rosas <farosas@suse.de>
The only_target option's purpose is to make sure only the destination
QTestState machine is initialized. This allows the test code to retain
an already initialized source machine (e.g. for doing ping pong
migration).
We have drifted from that a bit when adding new code, so move some
lines under only_target to restore the functionality.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20241125144612.16194-2-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
---
tests/qtest/migration-test.c | 44 ++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 74d3000198..eafc2da806 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -717,7 +717,6 @@ static int test_migrate_start(QTestState **from, QTestState
**to,
g_autofree gchar *arch_target = NULL;
/* options for source and target */
g_autofree gchar *arch_opts = NULL;
- g_autofree gchar *cmd_source = NULL;
g_autofree gchar *cmd_target = NULL;
const gchar *ignore_stderr;
g_autofree char *shmem_opts = NULL;
@@ -735,10 +734,7 @@ static int test_migrate_start(QTestState **from,
QTestState **to,
}
}
- dst_state = (QTestMigrationState) { };
- src_state = (QTestMigrationState) { };
bootfile_create(tmpfs, args->suspend_me);
- src_state.suspend_me = args->suspend_me;
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
memory_size = "150M";
@@ -817,27 +813,35 @@ static int test_migrate_start(QTestState **from,
QTestState **to,
g_test_message("Using machine type: %s", machine);
- cmd_source = g_strdup_printf("-accel kvm%s -accel tcg "
- "-machine %s,%s "
- "-name source,debug-threads=on "
- "-m %s "
- "-serial file:%s/src_serial "
- "%s %s %s %s %s",
- kvm_opts ? kvm_opts : "",
- machine, machine_opts,
- memory_size, tmpfs,
- arch_opts ? arch_opts : "",
- arch_source ? arch_source : "",
- shmem_opts ? shmem_opts : "",
- args->opts_source ? args->opts_source : "",
- ignore_stderr);
if (!args->only_target) {
+ g_autofree gchar *cmd_source = NULL;
+
+ src_state = (QTestMigrationState) { };
+ src_state.suspend_me = args->suspend_me;
+
+ cmd_source = g_strdup_printf("-accel kvm%s -accel tcg "
+ "-machine %s,%s "
+ "-name source,debug-threads=on "
+ "-m %s "
+ "-serial file:%s/src_serial "
+ "%s %s %s %s %s",
+ kvm_opts ? kvm_opts : "",
+ machine, machine_opts,
+ memory_size, tmpfs,
+ arch_opts ? arch_opts : "",
+ arch_source ? arch_source : "",
+ shmem_opts ? shmem_opts : "",
+ args->opts_source ? args->opts_source :
"",
+ ignore_stderr);
+
*from = qtest_init_with_env(QEMU_ENV_SRC, cmd_source);
qtest_qmp_set_event_callback(*from,
migrate_watch_for_events,
&src_state);
}
+ dst_state = (QTestMigrationState) { };
+
cmd_target = g_strdup_printf("-accel kvm%s -accel tcg "
"-machine %s,%s "
"-name target,debug-threads=on "
@@ -870,7 +874,9 @@ static int test_migrate_start(QTestState **from, QTestState
**to,
* Always enable migration events. Libvirt always uses it, let's try
* to mimic as closer as that.
*/
- migrate_set_capability(*from, "events", true);
+ if (!args->only_target) {
+ migrate_set_capability(*from, "events", true);
+ }
migrate_set_capability(*to, "events", true);
return 0;
--
2.47.0
- [PATCH RFC 00/11] migration/block: disk activation rewrite, Peter Xu, 2024/12/03
- [PATCH RFC 01/11] migration: Add helper to get target runstate, Peter Xu, 2024/12/03
- [PATCH RFC 03/11] migration/block: Apply late-block-active behavior to postcopy, Peter Xu, 2024/12/03
- [PATCH RFC 02/11] migration/block: Make late-block-active the default, Peter Xu, 2024/12/03
- [PATCH RFC 06/11] migration/block: Extend the migration_block_* API to dest side, Peter Xu, 2024/12/03
- [PATCH RFC 05/11] migration/block: Merge block reactivations for fail/cancel, Peter Xu, 2024/12/03
- [PATCH RFC 04/11] migration/block: Fix possible race with block_inactive, Peter Xu, 2024/12/03
- [PATCH RFC 08/11] tests/qtest/migration: Move more code under only_target,
Peter Xu <=
- [PATCH RFC 10/11] tests/qtest/migration: Support cleaning up only one side of migration, Peter Xu, 2024/12/03
- [PATCH RFC 09/11] tests/qtest/migration: Don't use hardcoded strings for -serial, Peter Xu, 2024/12/03
- [PATCH RFC 07/11] migration/block: Apply the migration_block_* API to postcopy, Peter Xu, 2024/12/03
- [PATCH RFC 11/11] tests/qtest/migration: Test successive migrations, Peter Xu, 2024/12/03
- Re: [PATCH RFC 00/11] migration/block: disk activation rewrite, Peter Xu, 2024/12/04