mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
migration: Add qtest for migration over RDMA
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 detect existing RoCE link before running the test. Test will be skipped if there is no available RoCE link. # Start of rdma tests # Running /x86_64/migration/precopy/rdma/plain ok 1 /x86_64/migration/precopy/rdma/plain # SKIP No rdma link available # To enable the test: # Run 'scripts/rdma-migration-helper.sh setup' with root to setup a new rdma/rxe link and rerun the test # Optional: run 'scripts/rdma-migration-helper.sh clean' to revert the 'setup' # End of rdma tests Cc: Philippe Mathieu-Daudé <philmd@linaro.org> Cc: Stefan Hajnoczi <stefanha@gmail.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> Message-ID: <20250311024221.363421-1-lizhijian@fujitsu.com> [add 'head -1' to script, reformat test message] Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
parent
5e7ca4a7d7
commit
7d9849c3c4
3 changed files with 137 additions and 0 deletions
|
@ -3538,6 +3538,7 @@ R: Li Zhijian <lizhijian@fujitsu.com>
|
||||||
R: Peter Xu <peterx@redhat.com>
|
R: Peter Xu <peterx@redhat.com>
|
||||||
S: Odd Fixes
|
S: Odd Fixes
|
||||||
F: migration/rdma*
|
F: migration/rdma*
|
||||||
|
F: scripts/rdma-migration-helper.sh
|
||||||
|
|
||||||
Migration dirty limit and dirty page rate
|
Migration dirty limit and dirty page rate
|
||||||
M: Hyman Huang <yong.huang@smartx.com>
|
M: Hyman Huang <yong.huang@smartx.com>
|
||||||
|
|
70
scripts/rdma-migration-helper.sh
Executable file
70
scripts/rdma-migration-helper.sh
Executable file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copied from blktests
|
||||||
|
get_ipv4_addr()
|
||||||
|
{
|
||||||
|
ip -4 -o addr show dev "$1" |
|
||||||
|
sed -n 's/.*[[:blank:]]inet[[:blank:]]*\([^[:blank:]/]*\).*/\1/p' |
|
||||||
|
head -1 | tr -d '\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
# existing rdma interfaces
|
||||||
|
rdma_interfaces()
|
||||||
|
{
|
||||||
|
rdma link show | sed -nE 's/^link .* netdev ([^ ]+).*$/\1 /p'
|
||||||
|
}
|
||||||
|
|
||||||
|
# existing valid ipv4 interfaces
|
||||||
|
ipv4_interfaces()
|
||||||
|
{
|
||||||
|
ip -o addr show | awk '/inet / {print $2}' | grep -v -w lo
|
||||||
|
}
|
||||||
|
|
||||||
|
rdma_rxe_detect()
|
||||||
|
{
|
||||||
|
for r in $(rdma_interfaces)
|
||||||
|
do
|
||||||
|
ipv4_interfaces | grep -qw $r && get_ipv4_addr $r && return
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
rdma_rxe_setup()
|
||||||
|
{
|
||||||
|
for i in $(ipv4_interfaces)
|
||||||
|
do
|
||||||
|
rdma_interfaces | grep -qw $i && continue
|
||||||
|
rdma link add "${i}_rxe" type rxe netdev "$i" && {
|
||||||
|
echo "Setup new rdma/rxe ${i}_rxe for $i with $(get_ipv4_addr $i)"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Failed to setup any new rdma/rxe link" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
rdma_rxe_clean()
|
||||||
|
{
|
||||||
|
modprobe -r rdma_rxe
|
||||||
|
}
|
||||||
|
|
||||||
|
operation=${1:-detect}
|
||||||
|
|
||||||
|
command -v rdma >/dev/null || {
|
||||||
|
echo "Command 'rdma' is not available, please install it first." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$operation" == "setup" ] || [ "$operation" == "clean" ]; then
|
||||||
|
[ "$UID" == 0 ] || {
|
||||||
|
echo "Root privilege is required to setup/clean a rdma/rxe link" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
rdma_rxe_"$operation"
|
||||||
|
elif [ "$operation" == "detect" ]; then
|
||||||
|
rdma_rxe_detect
|
||||||
|
else
|
||||||
|
echo "Usage: $0 [setup | detect | clean]"
|
||||||
|
fi
|
|
@ -99,6 +99,68 @@ static void test_precopy_unix_dirty_ring(void)
|
||||||
test_precopy_common(&args);
|
test_precopy_common(&args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_RDMA
|
||||||
|
|
||||||
|
#define RDMA_MIGRATION_HELPER "scripts/rdma-migration-helper.sh"
|
||||||
|
static int new_rdma_link(char *buffer)
|
||||||
|
{
|
||||||
|
char cmd[256];
|
||||||
|
bool verbose = g_getenv("QTEST_LOG");
|
||||||
|
|
||||||
|
snprintf(cmd, sizeof(cmd), "%s detect %s", RDMA_MIGRATION_HELPER,
|
||||||
|
verbose ? "" : "2>/dev/null");
|
||||||
|
|
||||||
|
FILE *pipe = popen(cmd, "r");
|
||||||
|
if (pipe == NULL) {
|
||||||
|
perror("Failed to run script");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
while (fgets(buffer + idx, 128 - idx, pipe) != NULL) {
|
||||||
|
idx += strlen(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int status = pclose(pipe);
|
||||||
|
if (status == -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] = {};
|
||||||
|
|
||||||
|
if (new_rdma_link(buffer)) {
|
||||||
|
g_test_skip("No rdma link available\n"
|
||||||
|
"# To enable the test:\n"
|
||||||
|
"# Run \'" RDMA_MIGRATION_HELPER " setup\' with root to "
|
||||||
|
"setup a new rdma/rxe link and rerun the test\n"
|
||||||
|
"# Optional: run 'scripts/rdma-migration-helper.sh clean' "
|
||||||
|
"to revert the 'setup'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: query a free port instead of hard code.
|
||||||
|
* 29200=('R'+'D'+'M'+'A')*100
|
||||||
|
**/
|
||||||
|
g_autofree char *uri = g_strdup_printf("rdma:%s:29200", buffer);
|
||||||
|
|
||||||
|
MigrateCommon args = {
|
||||||
|
.listen_uri = uri,
|
||||||
|
.connect_uri = uri,
|
||||||
|
};
|
||||||
|
|
||||||
|
test_precopy_common(&args);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void test_precopy_tcp_plain(void)
|
static void test_precopy_tcp_plain(void)
|
||||||
{
|
{
|
||||||
MigrateCommon args = {
|
MigrateCommon args = {
|
||||||
|
@ -1124,6 +1186,10 @@ static void migration_test_add_precopy_smoke(MigrationTestEnv *env)
|
||||||
test_multifd_tcp_uri_none);
|
test_multifd_tcp_uri_none);
|
||||||
migration_test_add("/migration/multifd/tcp/plain/cancel",
|
migration_test_add("/migration/multifd/tcp/plain/cancel",
|
||||||
test_multifd_tcp_cancel);
|
test_multifd_tcp_cancel);
|
||||||
|
#ifdef CONFIG_RDMA
|
||||||
|
migration_test_add("/migration/precopy/rdma/plain",
|
||||||
|
test_precopy_rdma_plain);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void migration_test_add_precopy(MigrationTestEnv *env)
|
void migration_test_add_precopy(MigrationTestEnv *env)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue