From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Fabiano Rosas <farosas@suse.de>,
Stefan Hajnoczi <stefanha@redhat.com>,
peterx@redhat.com, Li Zhijian <lizhijian@fujitsu.com>,
Jack Wang <jinpu.wang@ionos.com>,
"Michael R. Galaxy" <mrgalaxy@nvidia.com>,
Yu Zhang <yu.zhang@ionos.com>
Subject: [PULL 03/12] qtest/migration/rdma: Add test for rdma migration with ipv6
Date: Tue, 20 May 2025 13:07:42 -0400 [thread overview]
Message-ID: <20250520170751.786787-4-peterx@redhat.com> (raw)
In-Reply-To: <20250520170751.786787-1-peterx@redhat.com>
From: Li Zhijian <lizhijian@fujitsu.com>
Recently, we removed ipv6 restriction[0] from RDMA migration, add a
test for it.
[0] https://lore.kernel.org/qemu-devel/20250326095224.9918-1-jinpu.wang@ionos.com/
Cc: Jack Wang <jinpu.wang@ionos.com>
Cc: Michael R. Galaxy <mrgalaxy@nvidia.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Yu Zhang <yu.zhang@ionos.com>
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20250513012207.2867069-1-lizhijian@fujitsu.com
[peterx: Fix over long lines]
Signed-off-by: Peter Xu <peterx@redhat.com>
---
tests/qtest/migration/precopy-tests.c | 21 ++++++++--
scripts/rdma-migration-helper.sh | 57 ++++++++++++++++++++++-----
2 files changed, 65 insertions(+), 13 deletions(-)
diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/precopy-tests.c
index 5be1cd5742..a62d3c5378 100644
--- a/tests/qtest/migration/precopy-tests.c
+++ b/tests/qtest/migration/precopy-tests.c
@@ -131,12 +131,13 @@ static bool mlock_check(void)
}
#define RDMA_MIGRATION_HELPER "scripts/rdma-migration-helper.sh"
-static int new_rdma_link(char *buffer)
+static int new_rdma_link(char *buffer, bool ipv6)
{
char cmd[256];
bool verbose = g_getenv("QTEST_LOG");
- snprintf(cmd, sizeof(cmd), "%s detect %s", RDMA_MIGRATION_HELPER,
+ snprintf(cmd, sizeof(cmd), "IP_FAMILY=%s %s detect %s",
+ ipv6 ? "ipv6" : "ipv4", RDMA_MIGRATION_HELPER,
verbose ? "" : "2>/dev/null");
FILE *pipe = popen(cmd, "r");
@@ -161,7 +162,7 @@ static int new_rdma_link(char *buffer)
return -1;
}
-static void test_precopy_rdma_plain(void)
+static void __test_precopy_rdma_plain(bool ipv6)
{
char buffer[128] = {};
@@ -170,7 +171,7 @@ static void test_precopy_rdma_plain(void)
return;
}
- if (new_rdma_link(buffer)) {
+ if (new_rdma_link(buffer, ipv6)) {
g_test_skip("No rdma link available\n"
"# To enable the test:\n"
"# Run \'" RDMA_MIGRATION_HELPER " setup\' with root to "
@@ -193,6 +194,16 @@ static void test_precopy_rdma_plain(void)
test_precopy_common(&args);
}
+
+static void test_precopy_rdma_plain(void)
+{
+ __test_precopy_rdma_plain(false);
+}
+
+static void test_precopy_rdma_plain_ipv6(void)
+{
+ __test_precopy_rdma_plain(true);
+}
#endif
static void test_precopy_tcp_plain(void)
@@ -1226,6 +1237,8 @@ static void migration_test_add_precopy_smoke(MigrationTestEnv *env)
#ifdef CONFIG_RDMA
migration_test_add("/migration/precopy/rdma/plain",
test_precopy_rdma_plain);
+ migration_test_add("/migration/precopy/rdma/plain/ipv6",
+ test_precopy_rdma_plain_ipv6);
#endif
}
diff --git a/scripts/rdma-migration-helper.sh b/scripts/rdma-migration-helper.sh
index a39f2fb0e5..d784d1566a 100755
--- a/scripts/rdma-migration-helper.sh
+++ b/scripts/rdma-migration-helper.sh
@@ -8,23 +8,44 @@ get_ipv4_addr()
head -1 | tr -d '\n'
}
+get_ipv6_addr() {
+ ipv6=$(ip -6 -o addr show dev "$1" |
+ sed -n 's/.*[[:blank:]]inet6[[:blank:]]*\([^[:blank:]/]*\).*/\1/p' |
+ head -1 | tr -d '\n')
+
+ [ $? -eq 0 ] || return
+
+ if [[ "$ipv6" =~ ^fe80: ]]; then
+ echo -n "[$ipv6%$1]"
+ else
+ echo -n "[$ipv6]"
+ fi
+}
+
# existing rdma interfaces
rdma_interfaces()
{
- rdma link show | sed -nE 's/^link .* netdev ([^ ]+).*$/\1 /p'
+ rdma link show | sed -nE 's/^link .* netdev ([^ ]+).*$/\1 /p' |
+ grep -Ev '^(lo|tun|tap)'
}
# existing valid ipv4 interfaces
ipv4_interfaces()
{
- ip -o addr show | awk '/inet / {print $2}' | grep -v -w lo
+ ip -o addr show | awk '/inet / {print $2}' | grep -Ev '^(lo|tun|tap)'
+}
+
+ipv6_interfaces()
+{
+ ip -o addr show | awk '/inet6 / {print $2}' | grep -Ev '^(lo|tun|tap)'
}
rdma_rxe_detect()
{
+ family=$1
for r in $(rdma_interfaces)
do
- ipv4_interfaces | grep -qw $r && get_ipv4_addr $r && return
+ "$family"_interfaces | grep -qw $r && get_"$family"_addr $r && return
done
return 1
@@ -32,16 +53,23 @@ rdma_rxe_detect()
rdma_rxe_setup()
{
- for i in $(ipv4_interfaces)
+ family=$1
+ for i in $("$family"_interfaces)
do
- rdma_interfaces | grep -qw $i && continue
+ if rdma_interfaces | grep -qw $i; then
+ echo "$family: Reuse the existing rdma/rxe ${i}_rxe" \
+ "for $i with $(get_"$family"_addr $i)"
+ return
+ fi
+
rdma link add "${i}_rxe" type rxe netdev "$i" && {
- echo "Setup new rdma/rxe ${i}_rxe for $i with $(get_ipv4_addr $i)"
+ echo "$family: Setup new rdma/rxe ${i}_rxe" \
+ "for $i with $(get_"$family"_addr $i)"
return
}
done
- echo "Failed to setup any new rdma/rxe link" >&2
+ echo "$family: Failed to setup any new rdma/rxe link" >&2
return 1
}
@@ -50,6 +78,12 @@ rdma_rxe_clean()
modprobe -r rdma_rxe
}
+IP_FAMILY=${IP_FAMILY:-ipv4}
+if [ "$IP_FAMILY" != "ipv6" ] && [ "$IP_FAMILY" != "ipv4" ]; then
+ echo "Unknown ip family '$IP_FAMILY', only ipv4 or ipv6 is supported." >&2
+ exit 1
+fi
+
operation=${1:-detect}
command -v rdma >/dev/null || {
@@ -62,9 +96,14 @@ if [ "$operation" == "setup" ] || [ "$operation" == "clean" ]; then
echo "Root privilege is required to setup/clean a rdma/rxe link" >&2
exit 1
}
- rdma_rxe_"$operation"
+ if [ "$operation" == "setup" ]; then
+ rdma_rxe_setup ipv4
+ rdma_rxe_setup ipv6
+ else
+ rdma_rxe_clean
+ fi
elif [ "$operation" == "detect" ]; then
- rdma_rxe_detect
+ rdma_rxe_detect "$IP_FAMILY"
else
echo "Usage: $0 [setup | detect | clean]"
fi
--
2.49.0
next prev parent reply other threads:[~2025-05-20 17:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 17:07 [PULL 00/12] Migration 20250520 patches Peter Xu
2025-05-20 17:07 ` [PULL 01/12] scripts/vmstate-static-checker.py: Add new hpet entry for num_timers Peter Xu
2025-05-20 17:07 ` [PULL 02/12] qtest/migration/rdma: Enforce RLIMIT_MEMLOCK >= 128MB requirement Peter Xu
2025-05-20 17:07 ` Peter Xu [this message]
2025-05-20 17:07 ` [PULL 04/12] ci: Re-enable python subtests in qtest migration suite Peter Xu
2025-05-20 17:07 ` [PULL 05/12] ci: Fix build-previous-qemu when the version tag is absent Peter Xu
2025-05-20 17:07 ` [PULL 06/12] ci: Reduce the size of artifacts for build-previous-qemu Peter Xu
2025-05-20 17:07 ` [PULL 07/12] migration: write zero pages when postcopy enabled Peter Xu
2025-05-20 17:07 ` [PULL 08/12] migration: enable multifd and postcopy together Peter Xu
2025-05-20 17:07 ` [PULL 09/12] tests/qtest/migration: add postcopy tests with multifd Peter Xu
2025-05-20 17:07 ` [PULL 10/12] migration/multifd: Don't send device state packets with zerocopy flag Peter Xu
2025-05-20 17:07 ` [PULL 11/12] migration: Allow caps to be set when preempt or multifd cap enabled Peter Xu
2025-05-20 17:07 ` [PULL 12/12] migration/hmp: Add "info migrate -a", reorg the dump Peter Xu
2025-05-22 18:47 ` [PULL 00/12] Migration 20250520 patches Stefan Hajnoczi
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=20250520170751.786787-4-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=jinpu.wang@ionos.com \
--cc=lizhijian@fujitsu.com \
--cc=mrgalaxy@nvidia.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=yu.zhang@ionos.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).