From nobody Sat Apr 11 23:02:54 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1773061761; cv=none; d=zohomail.com; s=zohoarc; b=UqpXHHIZ45bkg4SpeUPMOUqPGfASf5RUBN9dm+kvzuRT3GdSZBrP22cY/gdUrL8n0w8glshTDSPkh0Td4xgOvhWXnXh1j//Td90NF2Ux5rwLF460WHn/NyqysZXH55T+AFwCvwuW3vRQ/mxQQSj12KTLvIplKa/O0K32tGsn5fY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773061761; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ONjOhrkIipknNUMs3BCgGta9cnMQP7SnPVvPz17p4uk=; b=JcZljT1XhTPfi6WLn1F4eVp1uFDbfaHbvxm27izIgutX9hDF8hzda6Am8GZe9Lijh2tNoN4dDPLyFjVGkkp0c1Ab7ESh5wwbeGfTanQUEBoQJQjjYZ2zbqSQFIswGe4DShzzua93DYQ5W3pZXSBa6fPTeWXTPZzE5HYQNI6nJY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773061761926869.6450103538783; Mon, 9 Mar 2026 06:09:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vzaLl-0007Lk-Dc; Mon, 09 Mar 2026 09:08:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vzaLR-00071Z-22 for qemu-devel@nongnu.org; Mon, 09 Mar 2026 09:08:25 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vzaLO-0008C6-Sv for qemu-devel@nongnu.org; Mon, 09 Mar 2026 09:08:24 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EF6314D221; Mon, 9 Mar 2026 13:07:57 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C147D3EEF2; Mon, 9 Mar 2026 13:07:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YGxJISzGrmlJcAAAD6G6ig (envelope-from ); Mon, 09 Mar 2026 13:07:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1773061678; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ONjOhrkIipknNUMs3BCgGta9cnMQP7SnPVvPz17p4uk=; b=o76J9VBUW6fSd+WUBsLBeuSSeu9WOFbz+qF9aeM9hOtnNlXbl8Rjsc4EUSiL6pTWrugxRY Kb3wd8QvwtrCH5gXZ4oKb4f3FdmgPSInUqVeoExucB1yvfjghd4aEJdVMlz19RU8VHRmgv 61OzWdu7dqUDrRz8McWKnzmbRh38iQ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1773061678; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ONjOhrkIipknNUMs3BCgGta9cnMQP7SnPVvPz17p4uk=; b=iTPoeAewdhSVWtFgpl29N6qC7ExJB/pvzmDQWjX5iXvik4N6s4njEPbzIn20PftuHt+lAl zQzhbqzYxKvg/HDA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RjvUx0y3; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="p4hER/KG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1773061677; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ONjOhrkIipknNUMs3BCgGta9cnMQP7SnPVvPz17p4uk=; b=RjvUx0y3ag4idEtXI+vEdOeMUqBc4NipS5AFNq0z/0ljgOXCPdNSQf0+/79U/Izef0WpUm j01FZaY39eY1aVre+lBLqWMyUmduQ3H7HCTKf02UUSTe1BgWrvksPNQXo30nUoeK7ChEaF CX6D1WMEtotm93sfqPsmOsyyMjA+7iE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1773061677; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ONjOhrkIipknNUMs3BCgGta9cnMQP7SnPVvPz17p4uk=; b=p4hER/KGuIy3gbG+obXaR1ouV/cznJfbSqSHOnvZyU6/4DDesLi4Nu+Iw4d0NSvkWLMw90 Tso8YrI+1a7y6ACA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Lukas Straub Subject: [PULL 14/22] migration-test: Add COLO migration unit test Date: Mon, 9 Mar 2026 10:07:19 -0300 Message-ID: <20260309130730.20526-15-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260309130730.20526-1-farosas@suse.de> References: <20260309130730.20526-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FREEMAIL_CC(0.00)[redhat.com,web.de]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[web.de] X-Rspamd-Queue-Id: EF6314D221 X-Spam-Score: -3.01 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1773061763184158500 Content-Type: text/plain; charset="utf-8" From: Lukas Straub Add a COLO migration test for COLO migration and failover. Reviewed-by: Fabiano Rosas Tested-by: Fabiano Rosas Reviewed-by: Peter Xu Signed-off-by: Lukas Straub Link: https://lore.kernel.org/qemu-devel/20260302-colo_unit_test_multifd-v1= 1-13-d653fb3b1d80@web.de [remove license boilerplate] Signed-off-by: Fabiano Rosas --- MAINTAINERS | 1 + tests/qtest/meson.build | 7 +- tests/qtest/migration-test.c | 1 + tests/qtest/migration/colo-tests.c | 194 +++++++++++++++++++++++++++++ tests/qtest/migration/framework.h | 5 + 5 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/migration/colo-tests.c diff --git a/MAINTAINERS b/MAINTAINERS index d8dc4c8d7b..5469cd373a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3886,6 +3886,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 =20 COLO Proxy diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index ba9f59d2f8..be4fa627b5 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -372,6 +372,11 @@ if gnutls.found() endif endif =20 +migration_colo_files =3D [] +if get_option('replication').allowed() + migration_colo_files =3D [files('migration/colo-tests.c')] +endif + qtests =3D { 'aspeed_hace-test': files('aspeed-hace-utils.c', 'aspeed_hace-test.c'), 'aspeed_smc-test': files('aspeed-smc-utils.c', 'aspeed_smc-test.c'), @@ -383,7 +388,7 @@ qtests =3D { '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 0893687174..e582f05c7d 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); =20 ret =3D g_test_run(); =20 diff --git a/tests/qtest/migration/colo-tests.c b/tests/qtest/migration/col= o-tests.c new file mode 100644 index 0000000000..bc20c92d16 --- /dev/null +++ b/tests/qtest/migration/colo-tests.c @@ -0,0 +1,194 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * QTest testcases for COLO migration + * + * Copyright (c) 2025 Lukas Straub + */ + +#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 =3D NULL; + + /* + * For the COLO test, both VMs will run in parallel. Thus both VMs wan= t to + * open the image read/write at the same time. Using read-only=3Don is= not + * possible here, because ide-hd does not support read-only backing im= age. + * + * So use -snapshot, where each qemu instance creates its own writable + * snapshot internally while leaving the real image read-only. + */ + args->start.opts_source =3D "-snapshot"; + args->start.opts_target =3D "-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 =3D true; + + /* + * Test with yank with out of band capability since that is how it is + * used in production. + */ + args->start.oob =3D true; + args->start.caps[MIGRATION_CAPABILITY_X_COLO] =3D 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 =3D 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 =3D 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-c= md', " + "'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 =3D "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 =3D "defer"; + args->start_hook =3D hook_start_multifd; + args->start.caps[MIGRATION_CAPABILITY_MULTIFD] =3D true; + test_colo_common(args, failover_during_checkpoint, primary_failover); +} + +static void test_colo_plain_primary_failover(char *name, MigrateCommon *ar= gs) +{ + 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 *arg= s) +{ + test_colo_plain_common(args, true, true); +} + +static void test_colo_plain_secondary_failover_checkpoint(char *name, + MigrateCommon *a= rgs) +{ + test_colo_plain_common(args, true, false); +} + +static void test_colo_multifd_primary_failover_checkpoint(char *name, + MigrateCommon *a= rgs) +{ + 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->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_checkpoin= t", + test_colo_plain_secondary_failover_checkpoint); + + migration_test_add("/migration/colo/multifd/primary_failover_checkpoin= t", + test_colo_multifd_primary_failover_checkpoint); + migration_test_add("/migration/colo/multifd/secondary_failover_checkpo= int", + test_colo_multifd_secondary_failover_checkpoint); +} diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/fram= ework.h index 40984d0493..80eef75893 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 =20 #endif /* TEST_FRAMEWORK_H */ --=20 2.51.0