Blame SOURCES/0542-dracut-Introduce-force-drivers-parameter-and-force_d.patch

0903d0
From 125bb747c3fd357b95e9833ae4255a370ba3211c Mon Sep 17 00:00:00 2001
0903d0
From: Thomas Renninger <trenn@suse.de>
0903d0
Date: Mon, 8 Sep 2014 12:34:48 +0200
0903d0
Subject: [PATCH] dracut: Introduce --force-drivers parameter and
0903d0
 force_drivers=+ config option
0903d0
0903d0
Which will not only add listed drivers, but also enforce that they are
0903d0
tried to be loaded at early boot time.
0903d0
0903d0
This is needed if drivers which are not autoloaded (e.g. loop and a lot
0903d0
others) shall get loaded via initramfs.
0903d0
0903d0
Cherry-picked from: cea907f6bf2fc97933b59e04f4520ca227251574
0903d0
Resolves: #1577626
0903d0
---
0903d0
 dracut.8.asc      | 13 +++++++++++++
0903d0
 dracut.conf.5.asc |  4 ++++
0903d0
 dracut.sh         | 21 +++++++++++++++++++++
0903d0
 3 files changed, 38 insertions(+)
0903d0
0903d0
diff --git a/dracut.8.asc b/dracut.8.asc
0903d0
index e097e769..5af99fa3 100644
0903d0
--- a/dracut.8.asc
0903d0
+++ b/dracut.8.asc
0903d0
@@ -136,6 +136,19 @@ example:
0903d0
 ----
0903d0
 ===============================
0903d0
 
0903d0
+**--force-drivers** _<list of kernel modules>_::
0903d0
+    See add-drivers above. But in this case it is ensured that the drivers
0903d0
+    are tried to be loaded early via modprobe.
0903d0
++
0903d0
+[NOTE]
0903d0
+===============================
0903d0
+If [LIST] has multiple arguments, then you have to put these in quotes. For
0903d0
+example:
0903d0
+----
0903d0
+# dracut --force-drivers "kmodule1 kmodule2"  ...
0903d0
+----
0903d0
+===============================
0903d0
+
0903d0
 **--omit-drivers** _<list of kernel modules>_::
0903d0
     specify a space-separated list of kernel modules not to add to the
0903d0
     initramfs.
0903d0
diff --git a/dracut.conf.5.asc b/dracut.conf.5.asc
0903d0
index f4ad49d2..90120115 100644
0903d0
--- a/dracut.conf.5.asc
0903d0
+++ b/dracut.conf.5.asc
0903d0
@@ -54,6 +54,10 @@ Space-separated lists have to have a leading and trailing space!
0903d0
     Specify a space-separated list of kernel modules to add to the initramfs.
0903d0
     The kernel modules have to be specified without the ".ko" suffix.
0903d0
 
0903d0
+*force_drivers+=*" __<list of kernel modules>__ "::
0903d0
+    See add_drivers above. But in this case it is ensured that the drivers
0903d0
+    are tried to be loaded early via modprobe.
0903d0
+
0903d0
 *omit_drivers+=*" __<kernel modules>__ "::
0903d0
     Specify a space-separated list of kernel modules not to add to the
0903d0
     initramfs. The kernel modules have to be specified without the ".ko" suffix.
0903d0
diff --git a/dracut.sh b/dracut.sh
0903d0
index 9dadece0..a34ca2a6 100755
0903d0
--- a/dracut.sh
0903d0
+++ b/dracut.sh
0903d0
@@ -81,6 +81,10 @@ Creates initial ramdisk images for preloading modules
0903d0
                          exclusively include in the initramfs.
0903d0
   --add-drivers [LIST]  Specify a space-separated list of kernel
0903d0
                          modules to add to the initramfs.
0903d0
+  --force-drivers [LIST] Specify a space-separated list of kernel
0903d0
+                         modules to add to the initramfs and make sure they
0903d0
+                         are tried to be loaded via modprobe same as passing
0903d0
+                         rd.driver.pre=DRIVER kernel parameter.
0903d0
   --omit-drivers [LIST] Specify a space-separated list of kernel
0903d0
                          modules not to add to the initramfs.
0903d0
   --filesystems [LIST]  Specify a space-separated list of kernel filesystem
0903d0
@@ -308,6 +312,7 @@ rearrange_params()
0903d0
         --long add: \
0903d0
         --long force-add: \
0903d0
         --long add-drivers: \
0903d0
+        --long force-drivers: \
0903d0
         --long omit-drivers: \
0903d0
         --long modules: \
0903d0
         --long omit: \
0903d0
@@ -476,6 +481,7 @@ while :; do
0903d0
         -a|--add)      push add_dracutmodules_l  "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
0903d0
         --force-add)   push force_add_dracutmodules_l  "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
0903d0
         --add-drivers) push add_drivers_l        "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
0903d0
+        --force-drivers) push force_drivers_l    "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
0903d0
         --omit-drivers) push omit_drivers_l      "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
0903d0
         -m|--modules)  push dracutmodules_l      "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
0903d0
         -o|--omit)     push omit_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
0903d0
@@ -928,6 +934,13 @@ if (( ${#add_drivers_l[@]} )); then
0903d0
 fi
0903d0
 add_drivers=${add_drivers/-/_}
0903d0
 
0903d0
+if (( ${#force_drivers_l[@]} )); then
0903d0
+    while pop force_drivers_l val; do
0903d0
+        force_drivers+=" $val "
0903d0
+    done
0903d0
+fi
0903d0
+force_drivers=${force_drivers/-/_}
0903d0
+
0903d0
 if (( ${#omit_drivers_l[@]} )); then
0903d0
     while pop omit_drivers_l val; do
0903d0
         omit_drivers+=" $val "
0903d0
@@ -944,6 +957,7 @@ fi
0903d0
 omit_drivers_corrected=""
0903d0
 for d in $omit_drivers; do
0903d0
     [[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
0903d0
+    [[ " $drivers $force_drivers " == *\ $d\ * ]] && continue
0903d0
     omit_drivers_corrected+="$d|"
0903d0
 done
0903d0
 omit_drivers="${omit_drivers_corrected%|}"
0903d0
@@ -1389,6 +1403,13 @@ if [[ $no_kernel != yes ]]; then
0903d0
     if [[ $add_drivers ]]; then
0903d0
         hostonly='' instmods -c $add_drivers
0903d0
     fi
0903d0
+    if [[ $force_drivers ]]; then
0903d0
+        hostonly='' instmods -c $force_drivers
0903d0
+        rm -f $initdir/etc/cmdline.d/20-force_driver.conf
0903d0
+        for mod in $force_drivers; do
0903d0
+            echo "rd.driver.pre=$mod" >>$initdir/etc/cmdline.d/20-force_drivers.conf
0903d0
+        done
0903d0
+    fi
0903d0
     if [[ $filesystems ]]; then
0903d0
         hostonly='' instmods -c $filesystems
0903d0
     fi