Skip to content

Commit db7835c

Browse files
authored
Merge pull request openshift#76414 from openshift-cherrypick-robot/cherry-pick-76114-to-enterprise-4.16
[enterprise-4.16] TELCODOCS-1827: Document symlinks for in-tree dependencies
2 parents 2d5826e + cde4dfe commit db7835c

4 files changed

+66
-16
lines changed

hardware_enablement/kmm-kernel-module-management.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ include::modules/kmm-replacing-in-tree-modules-with-out-of-tree-modules.adoc[lev
5555
* link:https://fastbitlab.com/building-a-linux-kernel-module/[Building a linux kernel module]
5656
5757
include::modules/kmm-example-module-cr.adoc[leveloffset=+2]
58+
59+
// Added for TELCODOCS-1827
60+
include::modules/kmm-symbolic-links-for-in-tree-dependencies.adoc[leveloffset=+1]
61+
5862
include::modules/kmm-creating-kmod-image.adoc[leveloffset=+1]
5963
include::modules/kmm-running-depmod.adoc[leveloffset=+2]
6064

modules/kmm-running-depmod.adoc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ You must have a Red Hat subscription to download the `kernel-devel` package.
2020
+
2121
[source,terminal]
2222
----
23-
$ depmod -b /opt ${KERNEL_VERSION}+`.
23+
$ depmod -b /opt ${KERNEL_FULL_VERSION}+`.
2424
----
2525

26-
27-
2826
[id="example-dockerfile_{context}"]
2927
== Example Dockerfile
3028

@@ -42,15 +40,15 @@ data:
4240
dockerfile: |
4341
ARG DTK_AUTO
4442
FROM ${DTK_AUTO} as builder
45-
ARG KERNEL_VERSION
43+
ARG KERNEL_FULL_VERSION
4644
WORKDIR /usr/src
4745
RUN ["git", "clone", "https://github.com/rh-ecosystem-edge/kernel-module-management.git"]
4846
WORKDIR /usr/src/kernel-module-management/ci/kmm-kmod
49-
RUN KERNEL_SRC_DIR=/lib/modules/${KERNEL_VERSION}/build make all
47+
RUN KERNEL_SRC_DIR=/lib/modules/${KERNEL_FULL_VERSION}/build make all
5048
FROM registry.redhat.io/ubi9/ubi-minimal
51-
ARG KERNEL_VERSION
49+
ARG KERNEL_FULL_VERSION
5250
RUN microdnf install kmod
53-
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_a.ko /opt/lib/modules/${KERNEL_VERSION}/
54-
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_b.ko /opt/lib/modules/${KERNEL_VERSION}/
55-
RUN depmod -b /opt ${KERNEL_VERSION}
51+
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_a.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
52+
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_b.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
53+
RUN depmod -b /opt ${KERNEL_FULL_VERSION}
5654
----
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * hardware_enablement/kmm-kernel-module-management.adoc
4+
5+
:_mod-docs-content-type: CONCEPT
6+
[id="kmm-symbolic-links-for-in-tree-dependencies_{context}"]
7+
8+
= Symbolic links for in-tree dependencies
9+
10+
Some kernel modules depend on other kernel modules that are shipped with the node's operating system. To avoid copying those dependencies into the kmod image, Kernel Module Management (KMM) mounts `/usr/lib/modules` into both the build and the worker pod's filesystems.
11+
12+
By creating a symlink from `/opt/usr/lib/modules/<kernel_version>/<symlink_name>` to `/usr/lib/modules/<kernel_version>`, `depmod` can use the in-tree kmods on the building node's filesystem to resolve dependencies.
13+
14+
At runtime, the worker pod extracts the entire image, including the `<symlink_name>` symbolic link. That symbolic link points to `/usr/lib/modules/<kernel_version>` in the worker pod, which is mounted from the node's filesystem. `modprobe` can then follow that link and load the in-tree dependencies as needed.
15+
16+
In the following example, `host` is the symbolic link name under `/opt/usr/lib/modules/<kernel_version>`:
17+
18+
[source,dockerfile]
19+
----
20+
ARG DTK_AUTO
21+
22+
FROM ${DTK_AUTO} as builder
23+
24+
#
25+
# Build steps
26+
#
27+
28+
FROM ubi9/ubi
29+
30+
ARG KERNEL_FULL_VERSION
31+
32+
RUN dnf update && dnf install -y kmod
33+
34+
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_a.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
35+
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_b.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
36+
37+
# Create the symbolic link
38+
RUN ln -s /lib/modules/${KERNEL_FULL_VERSION} /opt/lib/modules/${KERNEL_FULL_VERSION}/host
39+
40+
RUN depmod -b /opt ${KERNEL_FULL_VERSION}
41+
----
42+
43+
[NOTE]
44+
====
45+
`depmod` generates dependency files based on the kernel modules present on the node that runs the kmod image build.
46+
47+
On the node on which KMM loads the kernel modules, `modprobe` expects the files to be present under `/usr/lib/modules/<kernel_version>`, and the same filesystem layout. It is highly recommended that the build and the target nodes share the same operating system and release.
48+
====

modules/kmm-using-driver-toolkit.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ The value is automatically set by KMM when creating the `Build` resource. See th
2525
----
2626
ARG DTK_AUTO
2727
FROM ${DTK_AUTO} as builder
28-
ARG KERNEL_VERSION
28+
ARG KERNEL_FULL_VERSION
2929
WORKDIR /usr/src
3030
RUN ["git", "clone", "https://github.com/rh-ecosystem-edge/kernel-module-management.git"]
3131
WORKDIR /usr/src/kernel-module-management/ci/kmm-kmod
32-
RUN KERNEL_SRC_DIR=/lib/modules/${KERNEL_VERSION}/build make all
33-
FROM registry.redhat.io/ubi9/ubi-minimal
34-
ARG KERNEL_VERSION
32+
RUN KERNEL_SRC_DIR=/lib/modules/${KERNEL_FULL_VERSION}/build make all
33+
FROM ubi9/ubi-minimal
34+
ARG KERNEL_FULL_VERSION
3535
RUN microdnf install kmod
36-
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_a.ko /opt/lib/modules/${KERNEL_VERSION}/
37-
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_b.ko /opt/lib/modules/${KERNEL_VERSION}/
38-
RUN depmod -b /opt ${KERNEL_VERSION}
36+
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_a.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
37+
COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_b.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
38+
RUN depmod -b /opt ${KERNEL_FULL_VERSION}
3939
----

0 commit comments

Comments
 (0)