From: Fabiano Rosas <farosas@suse.de>
To: Lukas Straub <lukasstraub2@web.de>, qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>, Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Zhang Chen <zhangckid@gmail.com>,
Hailiang Zhang <zhanghailiang@xfusion.com>,
Markus Armbruster <armbru@redhat.com>,
Li Zhijian <lizhijian@fujitsu.com>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
Lukas Straub <lukasstraub2@web.de>
Subject: Re: [PATCH v3 06/10] migration-test: Add COLO migration unit test
Date: Wed, 28 Jan 2026 09:32:31 -0300 [thread overview]
Message-ID: <87sebpgbog.fsf@suse.de> (raw)
In-Reply-To: <20260125-colo_unit_test_multifd-v3-6-ae926ccd8eae@web.de>
Lukas Straub <lukasstraub2@web.de> writes:
> Add a COLO migration test for COLO migration and failover.
>
> Signed-off-by: Lukas Straub <lukasstraub2@web.de>
> ---
> MAINTAINERS | 1 +
> tests/qtest/meson.build | 7 +-
> tests/qtest/migration-test.c | 1 +
> tests/qtest/migration/colo-tests.c | 199 +++++++++++++++++++++++++++++++++++++
> tests/qtest/migration/framework.h | 5 +
> 5 files changed, 212 insertions(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 883f0a8f4eb92d0bf0f89fcab4674ccc4aed1cc1..2a8b9b2d051883c1b7adce9c1afec80d16a317f8 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3856,6 +3856,7 @@ F: migration/colo*
> F: migration/multifd-colo.*
> F: include/migration/colo.h
> F: include/migration/failover.h
> +F: tests/qtest/migration/colo-tests.c
> F: docs/COLO-FT.txt
>
> COLO Proxy
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index dfb83650c643d884daad53a66034ab7aa8c45509..624f7744ec9bd81c8823075b966bc95f7750a667 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -371,6 +371,11 @@ if gnutls.found()
> endif
> endif
>
> +migration_colo_files = []
> +if get_option('replication').allowed()
> + migration_colo_files = [files('migration/colo-tests.c')]
> +endif
> +
> qtests = {
> 'aspeed_hace-test': files('aspeed-hace-utils.c', 'aspeed_hace-test.c'),
> 'aspeed_smc-test': files('aspeed-smc-utils.c', 'aspeed_smc-test.c'),
> @@ -382,7 +387,7 @@ qtests = {
> 'migration/migration-util.c') + dbus_vmstate1,
> 'erst-test': files('erst-test.c'),
> 'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'],
> - 'migration-test': test_migration_files + migration_tls_files,
> + 'migration-test': test_migration_files + migration_tls_files + migration_colo_files,
> 'pxe-test': files('boot-sector.c'),
> 'pnv-xive2-test': files('pnv-xive2-common.c', 'pnv-xive2-flush-sync.c',
> 'pnv-xive2-nvpg_bar.c'),
> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
> index 08936871741535c926eeac40a7d7c3f461c72fd0..e582f05c7dc2673dbd05a936df8feb6c964b5bbc 100644
> --- a/tests/qtest/migration-test.c
> +++ b/tests/qtest/migration-test.c
> @@ -55,6 +55,7 @@ int main(int argc, char **argv)
> migration_test_add_precopy(env);
> migration_test_add_cpr(env);
> migration_test_add_misc(env);
> + migration_test_add_colo(env);
>
> ret = g_test_run();
>
> diff --git a/tests/qtest/migration/colo-tests.c b/tests/qtest/migration/colo-tests.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..0586970e206f01ed6e7aa3429321aefc1de7be37
> --- /dev/null
> +++ b/tests/qtest/migration/colo-tests.c
> @@ -0,0 +1,199 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * QTest testcases for COLO migration
> + *
> + * Copyright (c) 2025 Lukas Straub <lukasstraub2@web.de>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include "libqtest.h"
> +#include "migration/framework.h"
> +#include "migration/migration-qmp.h"
> +#include "migration/migration-util.h"
> +#include "qemu/module.h"
> +
> +static int test_colo_common(MigrateCommon *args,
> + bool failover_during_checkpoint,
> + bool primary_failover)
> +{
> + QTestState *from, *to;
> + void *data_hook = NULL;
> +
> + /*
> + * For the COLO test, both VMs will run in parallel. Thus both VMs want to
> + * open the image read/write at the same time. Using read-only=on is not
> + * possible here, because ide-hd does not support read-only backing image.
> + *
> + * So use -snapshot, where each qemu instance creates its own writable
> + * snapshot internally while leaving the real image read-only.
> + */
> + args->start.opts_source = "-snapshot";
> + args->start.opts_target = "-snapshot";
> +
> + /*
> + * COLO migration code logs many errors when the migration socket
> + * is shut down, these are expected so we hide them here.
> + */
> + args->start.hide_stderr = true;
> +
> + args->start.oob = true;
> + args->start.caps[MIGRATION_CAPABILITY_X_COLO] = true;
> +
> + if (migrate_start(&from, &to, args->listen_uri, &args->start)) {
> + return -1;
> + }
> +
> + migrate_set_parameter_int(from, "x-checkpoint-delay", 300);
> +
> + if (args->start_hook) {
> + data_hook = args->start_hook(from, to);
> + }
> +
> + migrate_ensure_converge(from);
> + wait_for_serial("src_serial");
> +
> + migrate_qmp(from, to, args->connect_uri, NULL, "{}");
> +
> + wait_for_migration_status(from, "colo", NULL);
> + wait_for_resume(to, get_dst());
> +
> + wait_for_serial("src_serial");
> + wait_for_serial("dest_serial");
> +
> + /* wait for 3 checkpoints */
> + for (int i = 0; i < 3; i++) {
> + qtest_qmp_eventwait(to, "RESUME");
> + wait_for_serial("src_serial");
> + wait_for_serial("dest_serial");
> + }
> +
> + if (failover_during_checkpoint) {
> + qtest_qmp_eventwait(to, "STOP");
> + }
> + if (primary_failover) {
> + qtest_qmp_assert_success(from, "{'exec-oob': 'yank', 'id': 'yank-cmd', "
> + "'arguments': {'instances':"
> + "[{'type': 'migration'}]}}");
> + qtest_qmp_assert_success(from, "{'execute': 'x-colo-lost-heartbeat'}");
> + wait_for_serial("src_serial");
> + } else {
> + qtest_qmp_assert_success(to, "{'exec-oob': 'yank', 'id': 'yank-cmd', "
> + "'arguments': {'instances':"
> + "[{'type': 'migration'}]}}");
> + qtest_qmp_assert_success(to, "{'execute': 'x-colo-lost-heartbeat'}");
> + wait_for_serial("dest_serial");
> + }
> +
> + if (args->end_hook) {
> + args->end_hook(from, to, data_hook);
> + }
> +
> + migrate_end(from, to, !primary_failover);
> +
> + return 0;
> +}
> +
> +static void test_colo_plain_common(MigrateCommon *args,
> + bool failover_during_checkpoint,
> + bool primary_failover)
> +{
> + args->listen_uri = "tcp:127.0.0.1:0";
> + test_colo_common(args, failover_during_checkpoint, primary_failover);
> +}
> +
> +static void *hook_start_multifd(QTestState *from, QTestState *to)
> +{
> + return migrate_hook_start_precopy_tcp_multifd_common(from, to, "none");
> +}
> +
> +static void test_colo_multifd_common(MigrateCommon *args,
> + bool failover_during_checkpoint,
> + bool primary_failover)
> +{
> + args->listen_uri = "defer";
> + args->start_hook = hook_start_multifd;
> + args->start.caps[MIGRATION_CAPABILITY_MULTIFD] = true;
> + test_colo_common(args, failover_during_checkpoint, primary_failover);
> +}
> +
> +static void test_colo_plain_primary_failover(char *name, MigrateCommon *args)
> +{
> + test_colo_plain_common(args, false, true);
> +}
> +
> +static void test_colo_plain_secondary_failover(char *name, MigrateCommon *args)
> +{
> + test_colo_plain_common(args, false, false);
> +}
> +
> +static void test_colo_multifd_primary_failover(char *name, MigrateCommon *args)
> +{
> + test_colo_multifd_common(args, false, true);
> +}
> +
> +static void test_colo_multifd_secondary_failover(char *name,
> + MigrateCommon *args)
> +{
> + test_colo_multifd_common(args, false, false);
> +}
> +
> +static void test_colo_plain_primary_failover_checkpoint(char *name,
> + MigrateCommon *args)
> +{
> + test_colo_plain_common(args, true, true);
> +}
> +
> +static void test_colo_plain_secondary_failover_checkpoint(char *name,
> + MigrateCommon *args)
> +{
> + test_colo_plain_common(args, true, false);
> +}
> +
> +static void test_colo_multifd_primary_failover_checkpoint(char *name,
> + MigrateCommon *args)
> +{
> + test_colo_multifd_common(args, true, true);
> +}
> +
> +static void test_colo_multifd_secondary_failover_checkpoint(char *name,
> + MigrateCommon *args)
> +{
> + test_colo_multifd_common(args, true, false);
> +}
> +
> +void migration_test_add_colo(MigrationTestEnv *env)
> +{
> + if (!env->has_kvm) {
> + g_test_skip("COLO requires KVM accelerator");
> + return;
> + }
> +
> + if (!env->full_set) {
> + return;
> + }
> +
> + migration_test_add("/migration/colo/plain/primary_failover",
> + test_colo_plain_primary_failover);
> + migration_test_add("/migration/colo/plain/secondary_failover",
> + test_colo_plain_secondary_failover);
> +
> + migration_test_add("/migration/colo/multifd/primary_failover",
> + test_colo_multifd_primary_failover);
> + migration_test_add("/migration/colo/multifd/secondary_failover",
> + test_colo_multifd_secondary_failover);
> +
> + migration_test_add("/migration/colo/plain/primary_failover_checkpoint",
> + test_colo_plain_primary_failover_checkpoint);
> + migration_test_add("/migration/colo/plain/secondary_failover_checkpoint",
> + test_colo_plain_secondary_failover_checkpoint);
> +
> + migration_test_add("/migration/colo/multifd/primary_failover_checkpoint",
> + test_colo_multifd_primary_failover_checkpoint);
> + migration_test_add("/migration/colo/multifd/secondary_failover_checkpoint",
> + test_colo_multifd_secondary_failover_checkpoint);
> +}
> diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h
> index 40984d04930da2d181326d9f6a742bde49018103..80eef758932ce9c301ed6c0f6383d18756144870 100644
> --- a/tests/qtest/migration/framework.h
> +++ b/tests/qtest/migration/framework.h
> @@ -264,5 +264,10 @@ void migration_test_add_file(MigrationTestEnv *env);
> void migration_test_add_precopy(MigrationTestEnv *env);
> void migration_test_add_cpr(MigrationTestEnv *env);
> void migration_test_add_misc(MigrationTestEnv *env);
> +#ifdef CONFIG_REPLICATION
> +void migration_test_add_colo(MigrationTestEnv *env);
> +#else
> +static inline void migration_test_add_colo(MigrationTestEnv *env) {};
> +#endif
>
> #endif /* TEST_FRAMEWORK_H */
It survived my stress run. It hit once the race at migration_shutdown()
where current_migration is already freed, but we can ignore that because
it's preexisting.
Tested-by: Fabiano Rosas <farosas@suse.de>
next prev parent reply other threads:[~2026-01-28 12:40 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-25 20:40 [PATCH v3 00/10] migration: Add COLO multifd support and COLO migration unit test Lukas Straub
2026-01-25 20:40 ` [PATCH v3 01/10] MAINTAINERS: Add myself as maintainer for COLO migration framework Lukas Straub
2026-01-25 20:40 ` [PATCH v3 02/10] MAINTAINERS: Remove Hailiang Zhang from " Lukas Straub
2026-01-25 20:40 ` [PATCH v3 03/10] Move ram state receive into multifd_ram_state_recv() Lukas Straub
2026-01-26 12:51 ` Fabiano Rosas
2026-01-25 20:40 ` [PATCH v3 04/10] multifd: Add COLO support Lukas Straub
2026-01-26 10:36 ` Zhang Chen
2026-01-26 11:13 ` Lukas Straub
2026-01-26 14:33 ` Fabiano Rosas
2026-01-26 19:33 ` Lukas Straub
2026-01-26 21:37 ` Fabiano Rosas
2026-01-27 20:36 ` Peter Xu
2026-01-28 12:30 ` Fabiano Rosas
2026-01-28 14:09 ` Peter Xu
2026-01-28 20:02 ` Fabiano Rosas
2026-02-03 9:47 ` Lukas Straub
2026-01-25 20:40 ` [PATCH v3 05/10] colo: Fix crash during device vmstate load Lukas Straub
2026-01-27 20:38 ` Peter Xu
2026-01-30 12:49 ` Lukas Straub
2026-02-02 14:12 ` Peter Xu
2026-02-03 9:25 ` Lukas Straub
2026-01-25 20:40 ` [PATCH v3 06/10] migration-test: Add COLO migration unit test Lukas Straub
2026-01-26 14:40 ` Fabiano Rosas
2026-01-27 20:49 ` Peter Xu
2026-01-30 10:24 ` Lukas Straub
2026-02-02 14:26 ` Peter Xu
2026-02-03 9:18 ` Lukas Straub
2026-02-03 21:21 ` Peter Xu
2026-02-06 19:11 ` Lukas Straub
2026-01-28 12:32 ` Fabiano Rosas [this message]
2026-01-25 20:40 ` [PATCH v3 07/10] Convert colo main documentation to restructuredText Lukas Straub
2026-01-25 20:40 ` [PATCH v3 08/10] qemu-colo.rst: Miscellaneous changes Lukas Straub
2026-01-26 10:21 ` Zhang Chen
2026-01-26 10:56 ` Lukas Straub
2026-01-25 20:40 ` [PATCH v3 09/10] qemu-colo.rst: Add my copyright Lukas Straub
2026-01-26 10:23 ` Zhang Chen
2026-01-25 20:40 ` [PATCH v3 10/10] qemu-colo.rst: Simplify the block replication setup Lukas Straub
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sebpgbog.fsf@suse.de \
--to=farosas@suse.de \
--cc=armbru@redhat.com \
--cc=dave@treblig.org \
--cc=lizhijian@fujitsu.com \
--cc=lukasstraub2@web.de \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhangckid@gmail.com \
--cc=zhanghailiang@xfusion.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.