From nobody Sun Nov 16 11:02:55 2025 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=1741371423; cv=none; d=zohomail.com; s=zohoarc; b=lJnxK2OGQdH2735fPRxBTATixblZIVErR7BnDCliOX0VGpc1HVmsyyaDQDbY/oXiWvfyMui4+G+aDZ0WPhJBEJUkqnHH9tkzYBUPCPMacJHdswV2atzYW1wk+rLkiZliz41UFMpFDkSVnz4wqRDL5QZgnSkiyLorG2XzzV9tNl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741371423; 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=nitnp15hL2jUHMEDBolqcEtudwr+GxP9TWOY8/DrRj0=; b=O22X9adoTwvJJ7lNuGr1QiWrDQnNcS2z+kicS+0lwEszqoIrV/HOeHS6uVwnwGNhb+vSbDf5vYfwwi2ppSH/faX/2/VrgkK4cEhh7YmZr+CwGkC+bcb6et2HT/mNSlxUdUIZjOU81o0z5yscCqwdwWFVaClsmeCNVmirGvjAGHY= 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 1741371423444897.95403851081; Fri, 7 Mar 2025 10:17:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqcFB-0000kj-B2; Fri, 07 Mar 2025 13:16:21 -0500 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 1tqcFA-0000k7-8U for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:16:20 -0500 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqcF8-0004x9-22 for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:16:19 -0500 Received: from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id 015831F395; Fri, 7 Mar 2025 18:16:11 +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 A122513A22; Fri, 7 Mar 2025 18:16:09 +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 yJqyF+k3y2dNcgAAD6G6ig (envelope-from ); Fri, 07 Mar 2025 18:16:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1741371371; 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=nitnp15hL2jUHMEDBolqcEtudwr+GxP9TWOY8/DrRj0=; b=DWOr1IaAaNxiiax4BcvKMMsctEPDz8MTyvgyBxPvkgQxmmaNlQ3WPjj3AocSTpZKErwqHr G7c804hmrF7B6DOG5sJvZ7pa+MBhEzqYVkCMiiPu67B5fvEs0WqIf8IV6PriwfZhWXrQhV dQFJQhC90dno+QV5tAVyHaal6H0x+4g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1741371371; 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=nitnp15hL2jUHMEDBolqcEtudwr+GxP9TWOY8/DrRj0=; b=O7GCwntSicCRuA3fvmD4bY3zxJ5nO08U45G7IFIy+ula/HX/Dko09vaNEsU7w/R5d6oOVT dVi63Guna5hfVsAQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1741371371; 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=nitnp15hL2jUHMEDBolqcEtudwr+GxP9TWOY8/DrRj0=; b=DWOr1IaAaNxiiax4BcvKMMsctEPDz8MTyvgyBxPvkgQxmmaNlQ3WPjj3AocSTpZKErwqHr G7c804hmrF7B6DOG5sJvZ7pa+MBhEzqYVkCMiiPu67B5fvEs0WqIf8IV6PriwfZhWXrQhV dQFJQhC90dno+QV5tAVyHaal6H0x+4g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1741371371; 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=nitnp15hL2jUHMEDBolqcEtudwr+GxP9TWOY8/DrRj0=; b=O7GCwntSicCRuA3fvmD4bY3zxJ5nO08U45G7IFIy+ula/HX/Dko09vaNEsU7w/R5d6oOVT dVi63Guna5hfVsAQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Li Zhijian Subject: [PULL 8/8] migration: Add qtest for migration over RDMA Date: Fri, 7 Mar 2025 15:15:51 -0300 Message-Id: <20250307181551.19887-9-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20250307181551.19887-1-farosas@suse.de> References: <20250307181551.19887-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 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)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 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.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 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) X-ZM-MESSAGEID: 1741371425594019100 Content-Type: text/plain; charset="utf-8" From: Li Zhijian This qtest requires there is a RDMA(RoCE) link in the host. In order to make the test work smoothly, introduce a scripts/rdma-migration-helper.sh to - setup a new Soft-RoCE(aka RXE) if it's root - detect existing RoCE link Test will be skipped if there is no available RoCE link. # Start of rdma tests # Running /x86_64/migration/precopy/rdma/plain Command 'rdma' is not available, please install it first. # To enable the test: # (1) Run 'scripts/rdma-migration-helper.sh setup' with root and rerun the= test # or # (2) Run the test with root privilege # ok 1 /x86_64/migration/precopy/rdma/plain # SKIP No rdma link available # End of rdma tests Note: Remove the newly added RXE link by executing 'modprobe -r rdma_rxe' or by specifying 'clean' within this script. Reviewed-by: Peter Xu Signed-off-by: Li Zhijian Message-ID: <20250305062825.772629-7-lizhijian@fujitsu.com> [reformated the message to be under 90 characters] Signed-off-by: Fabiano Rosas --- MAINTAINERS | 1 + scripts/rdma-migration-helper.sh | 48 +++++++++++++++++++ tests/qtest/migration/precopy-tests.c | 69 +++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100755 scripts/rdma-migration-helper.sh diff --git a/MAINTAINERS b/MAINTAINERS index 5df6020ed5..56e85adcfb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3517,6 +3517,7 @@ R: Li Zhijian R: Peter Xu S: Odd Fixes F: migration/rdma* +F: scripts/rdma-migration-helper.sh =20 Migration dirty limit and dirty page rate M: Hyman Huang diff --git a/scripts/rdma-migration-helper.sh b/scripts/rdma-migration-help= er.sh new file mode 100755 index 0000000000..08e29a52eb --- /dev/null +++ b/scripts/rdma-migration-helper.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copied from blktests +get_ipv4_addr() +{ + ip -4 -o addr show dev "$1" | + sed -n 's/.*[[:blank:]]inet[[:blank:]]*\([^[:blank:]/]*\).*/\1/p' | + tr -d '\n' +} + +has_soft_rdma() +{ + rdma link | grep -q " netdev $1[[:blank:]]*\$" +} + +rdma_rxe_setup_detect() +{ + ( + cd /sys/class/net && + for i in *; do + [ -e "$i" ] || continue + [ "$i" =3D "lo" ] && continue + [ "$(<"$i/addr_len")" =3D 6 ] || continue + [ "$(<"$i/carrier")" =3D 1 ] || continue + + has_soft_rdma "$i" && break + [ "$operation" =3D "setup" ] && + rdma link add "${i}_rxe" type rxe netdev "$i" && break + done + has_soft_rdma "$i" || return + get_ipv4_addr "$i" + ) +} + +operation=3D${1:-setup} + +command -v rdma >/dev/null || { + echo "Command 'rdma' is not available, please install it first." >&2 + exit 1 +} + +if [ "$operation" =3D=3D "setup" ] || [ "$operation" =3D=3D "detect" ]; th= en + rdma_rxe_setup_detect +elif [ "$operation" =3D=3D "clean" ]; then + modprobe -r rdma_rxe +else + echo "Usage: $0 [setup | detect | clean]" +fi diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/= precopy-tests.c index ba273d10b9..f1fe34020d 100644 --- a/tests/qtest/migration/precopy-tests.c +++ b/tests/qtest/migration/precopy-tests.c @@ -99,6 +99,71 @@ static void test_precopy_unix_dirty_ring(void) test_precopy_common(&args); } =20 +#ifdef CONFIG_RDMA + +#define RDMA_MIGRATION_HELPER "scripts/rdma-migration-helper.sh" +static int new_rdma_link(char *buffer, bool verbose) +{ + const char *argument =3D (geteuid() =3D=3D 0) ? "setup" : "detect"; + char cmd[1024]; + + snprintf(cmd, sizeof(cmd), "%s %s %s", RDMA_MIGRATION_HELPER, argument, + verbose ? "" : "2>/dev/null"); + + FILE *pipe =3D popen(cmd, "r"); + if (pipe =3D=3D NULL) { + perror("Failed to run script"); + return -1; + } + + int idx =3D 0; + while (fgets(buffer + idx, 128 - idx, pipe) !=3D NULL) { + idx +=3D strlen(buffer); + } + + int status =3D pclose(pipe); + if (status =3D=3D -1) { + perror("Error reported by pclose()"); + return -1; + } else if (WIFEXITED(status)) { + return WEXITSTATUS(status); + } + + return -1; +} + +static void test_precopy_rdma_plain(void) +{ + char buffer[128] =3D {}; + bool verbose =3D g_getenv("QTEST_LOG"); + + if (new_rdma_link(buffer, verbose)) { + g_test_skip("No rdma link available"); + if (verbose) { + g_test_message( + "To enable the test:\n" + "(1) Run \'" RDMA_MIGRATION_HELPER + " setup\' with root and rerun the test\n" + "or\n(2) Run the test with root privilege"); + } + return; + } + + /* + * TODO: query a free port instead of hard code. + * 29200=3D('R'+'D'+'M'+'A')*100 + **/ + g_autofree char *uri =3D g_strdup_printf("rdma:%s:29200", buffer); + + MigrateCommon args =3D { + .listen_uri =3D uri, + .connect_uri =3D uri, + }; + + test_precopy_common(&args); +} +#endif + static void test_precopy_tcp_plain(void) { MigrateCommon args =3D { @@ -1124,6 +1189,10 @@ static void migration_test_add_precopy_smoke(Migrati= onTestEnv *env) test_multifd_tcp_uri_none); migration_test_add("/migration/multifd/tcp/plain/cancel", test_multifd_tcp_cancel); +#ifdef CONFIG_RDMA + migration_test_add("/migration/precopy/rdma/plain", + test_precopy_rdma_plain); +#endif } =20 void migration_test_add_precopy(MigrationTestEnv *env) --=20 2.35.3