Mesa (main): ci: Load KVM kernel module for LAVA runners

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 22 17:36:27 UTC 2022


Module: Mesa
Branch: main
Commit: 86ce26f1fc8d3ace29158670b89340c7a228ed81
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=86ce26f1fc8d3ace29158670b89340c7a228ed81

Author: Cristian Ciocaltea <cristian.ciocaltea at collabora.com>
Date:   Tue Feb 22 16:49:28 2022 +0200

ci: Load KVM kernel module for LAVA runners

If 'HWCI_KVM' enviroment variable is set, load the KVM kernel module
specific to the detected CPU virtualisation extensions: vmx for Intel
VT and svm for AMD-V.

As an additional optimization, handle HWCI_KERNEL_MODULES probing in the
main shell process instead of creating an unnecessary subshell.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea at collabora.com>
Reviewed-by: Guilherme Gallo <guilherme.gallo at collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15208>

---

 .gitlab-ci/common/generate-env.sh |  1 +
 .gitlab-ci/common/init-stage2.sh  | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci/common/generate-env.sh b/.gitlab-ci/common/generate-env.sh
index 58e92490381..92d0a89a861 100755
--- a/.gitlab-ci/common/generate-env.sh
+++ b/.gitlab-ci/common/generate-env.sh
@@ -61,6 +61,7 @@ for var in \
     GTEST_SKIPS \
     HWCI_FREQ_MAX \
     HWCI_KERNEL_MODULES \
+    HWCI_KVM \
     HWCI_START_XORG \
     HWCI_TEST_SCRIPT \
     IR3_SHADER_DEBUG \
diff --git a/.gitlab-ci/common/init-stage2.sh b/.gitlab-ci/common/init-stage2.sh
index fe46338b78a..c85e52cc78a 100755
--- a/.gitlab-ci/common/init-stage2.sh
+++ b/.gitlab-ci/common/init-stage2.sh
@@ -8,7 +8,23 @@
 set -ex
 
 # Set up any devices required by the jobs
-[ -z "$HWCI_KERNEL_MODULES" ] || (echo -n $HWCI_KERNEL_MODULES | xargs -d, -n1 /usr/sbin/modprobe)
+[ -z "$HWCI_KERNEL_MODULES" ] || {
+    echo -n $HWCI_KERNEL_MODULES | xargs -d, -n1 /usr/sbin/modprobe
+}
+
+# Load the KVM module specific to the detected CPU virtualization extensions:
+# - vmx for Intel VT
+# - svm for AMD-V
+if [ "$HWCI_KVM" = "true" ]; then
+    unset KVM_KERNEL_MODULE
+    grep -qs '\bvmx\b' /proc/cpuinfo && KVM_KERNEL_MODULE=kvm_intel || {
+        grep -qs '\bsvm\b' /proc/cpuinfo && KVM_KERNEL_MODULE=kvm_amd
+    }
+
+    [ -z "${KVM_KERNEL_MODULE}" ] && \
+        echo "WARNING: Failed to detect CPU virtualization extensions" || \
+        modprobe ${KVM_KERNEL_MODULE}
+fi
 
 # Fix prefix confusion: the build installs to $CI_PROJECT_DIR, but we expect
 # it in /install



More information about the mesa-commit mailing list