Skip to content

Commit 1542190

Browse files
committed
RDMA Core: make libibverbs plugins relocatable
Allow overriding the libibverbs configuration directory setting the environment variable VERBS_CONFIG_DIR. Set VERBS_CONFIG_DIR in the scram tool to point to the libibverbs configuration directory. Include the libibverbs configuration directory in the package. Update the libibverbs configuration to include the full path to the plugins, and relocate them in the post-install section. Include the user binaries in the package.
1 parent 4ddee0e commit 1542190

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

rdma-core-VERBS_CONFIG_DIR.patch

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff --git a/libibverbs/dynamic_driver.c b/libibverbs/dynamic_driver.c
2+
index 7fa4233..c2ff2bb 100644
3+
--- a/libibverbs/dynamic_driver.c
4+
+++ b/libibverbs/dynamic_driver.c
5+
@@ -115,27 +115,33 @@ static void read_config_file(const char *path)
6+
7+
static void read_config(void)
8+
{
9+
+ char *verbs_config_dir;
10+
DIR *conf_dir;
11+
struct dirent *dent;
12+
char *path;
13+
14+
- conf_dir = opendir(IBV_CONFIG_DIR);
15+
+ verbs_config_dir = getenv("VERBS_CONFIG_DIR");
16+
+ if (!verbs_config_dir) {
17+
+ verbs_config_dir = IBV_CONFIG_DIR;
18+
+ }
19+
+
20+
+ conf_dir = opendir(verbs_config_dir);
21+
if (!conf_dir) {
22+
fprintf(stderr,
23+
PFX "Warning: couldn't open config directory '%s'.\n",
24+
- IBV_CONFIG_DIR);
25+
+ verbs_config_dir);
26+
return;
27+
}
28+
29+
while ((dent = readdir(conf_dir))) {
30+
struct stat buf;
31+
32+
- if (asprintf(&path, "%s/%s", IBV_CONFIG_DIR, dent->d_name) <
33+
+ if (asprintf(&path, "%s/%s", verbs_config_dir, dent->d_name) <
34+
0) {
35+
fprintf(stderr,
36+
PFX
37+
"Warning: couldn't read config file %s/%s.\n",
38+
- IBV_CONFIG_DIR, dent->d_name);
39+
+ verbs_config_dir, dent->d_name);
40+
goto out;
41+
}
42+

rdma-core.spec

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
## INITENV +PATH LD_LIBRARY_PATH %{i}/lib64
33

44
Source: https://github.com/linux-rdma/%{n}/releases/download/v%{realversion}/rdma-core-%{realversion}.tar.gz
5+
Patch: rdma-core-VERBS_CONFIG_DIR
56
BuildRequires: cmake ninja
67

78
%prep
89
%setup -q -n %{n}-%{realversion}
10+
%patch -p1
911

1012
%build
1113
rm -rf build
@@ -33,10 +35,19 @@ ninja -v %{makeprocesses} install
3335
# remove pkg-config to avoid rpm-generated dependency on /usr/bin/pkg-config
3436
rm -rf %{i}/lib64/pkgconfig
3537

36-
# keep only the libraries and include files
37-
rm -rf %{i}/bin
38-
rm -rf %{i}/etc
38+
# keep only the user binaries, libibverbs configuration, libraries and include files
39+
rm -rf %{i}/etc/infiniband-diags
40+
rm -rf %{i}/etc/init.d
41+
rm -rf %{i}/etc/modprobe.d
42+
rm -rf %{i}/etc/rdma
3943
rm -rf %{i}/lib
4044
rm -rf %{i}/libexec
4145
rm -rf %{i}/sbin
42-
rm -rf %{i}/share
46+
rm -rf %{i}/share/perl5
47+
48+
# update the libibverbs plugins with the full path
49+
sed -e's#driver \(\w\+\)#driver %{i}/lib64/libibverbs/lib\1#' -i %{i}/etc/libibverbs.d/*
50+
51+
%post
52+
# relocate the libibverbs plugins path
53+
%{relocateConfig}etc/libibverbs.d/*

scram-tools.file/tools/rdma-core/rdma-core.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
<environment name="LIBDIR" default="$RDMA_CORE_BASE/lib64"/>
66
<environment name="INCLUDE" default="$RDMA_CORE_BASE/include"/>
77
</client>
8+
<runtime name="PATH" value="$RDMA_CORE_BASE/bin" type="path"/>
89
<runtime name="ROOT_INCLUDE_PATH" value="$INCLUDE" type="path"/>
10+
<runtime name="VERBS_CONFIG_DIR" value="$RDMA_CORE_BASE/etc/libibverbs.d" type="path"/>
911
</tool>

0 commit comments

Comments
 (0)