All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabian Vogt <fvogt-IBi9RG/b67k@public.gmane.org>
To: "initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH] Correctly handle module aliases
Date: Thu, 21 Jan 2016 17:13:07 +0100	[thread overview]
Message-ID: <40374262.eB5p3XdtTH@linux-lm3i.site> (raw)

Handle module aliases correctly to not generate unbootable
initrds with different kernel versions when modules were renamed
or replaced.

Signed-off-by: Fabian Vogt <fvogt-IBi9RG/b67k@public.gmane.org>
---

This is the case for mpt3sas -> mpt2sas migration in kernel 4.4,
which caused issues like https://bugzilla.opensuse.org/show_bug.cgi?id=962694

 dracut.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/dracut.sh b/dracut.sh
index 98dbe0b..ae8772b 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -1195,6 +1195,27 @@ if [[ $hostonly ]]; then
     while read m rest || [ -n "$m" ]; do
         host_modules["$m"]=1
     done </proc/modules
+
+    # Explanation of the following section:
+    # Since kernel 4.4, mpt3sas is a complete replacement for mpt2sas.
+    # mpt3sas has an alias to mpt2sas now, but since mpt3sas isn't loaded
+    # when generating the initrd from kernel < 4.4, it's not included.
+    # The other direction has the same issue:
+    # When generating the initrd from kernel >= 4.4, mpt2sas isn't loaded,
+    # so it's not included.
+    # Both ways result in an unbootable initrd.
+
+    # also add aliases of loaded modules
+    for mod in "${!host_modules[@]}"; do
+        aliases=$(modinfo -F alias "$mod" 2>&1)
+        for alias in $aliases; do
+            host_modules["$alias"]=1
+        done
+        # mod might be an alias in the target kernel, find the real module
+        mod_filename=$(modinfo -k "$kernel" "$mod" -F filename)
+        [ $? -ne 0 ] && continue
+        host_modules["$(basename -s .ko "$mod_filename")"]=1
+    done
 fi
 
 unset m
-- 
2.7.0

             reply	other threads:[~2016-01-21 16:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 16:13 Fabian Vogt [this message]
     [not found] ` <40374262.eB5p3XdtTH-Bm6d+KqpjsTpRLhIRNQA6g@public.gmane.org>
2016-01-21 17:02   ` [PATCH] Correctly handle module aliases Dracut GitHub Import Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40374262.eB5p3XdtTH@linux-lm3i.site \
    --to=fvogt-ibi9rg/b67k@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.