[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#793786: initramfs-tools: fix the broken netconsole feature in initramfs-tools



Control: reopen -1

On Wed, Dec 9, 2015 at 12:39 PM, Ben Hutchings <ben@decadent.org.uk> wrote:
> An initramfs built with MODULES=most (default) always includes
> netconsole.ko (assuming it was enabled in the kernel configuration).
> So
> the netconsole parameter needs to work even if netconsole doesn't
> appear in /conf/modules, and your v3 breaks that.  So I applied your
> v2.  Thanks.

I find current v2 patch will sometimes fail because it load netconsole.ko before
loading network driver.
I made some changes based on patch v3, can confirmed various scenarios,
including "MODULES=most" you mentioned. So here's patch v4.
(also in my github repo's netconsole branch:
https://github.com/rogers0/initramfs-tools/tree/netconsole)

the fix already takes various cases into account:
- MODULES=most (default) or MODULES={dep,list} (popular for embedded devices)
- netconsole param may be inside conf/modules or come with bootloader's config

for "MODULES=most" case , netconsole.ko is included by default, so there's
no need to list it in conf/modules, and netconsole param should be put into
bootloader's config

for "MODULES={dep,list}" case, netconsole param can be either from
conf/modules or bootloader, and the previous one is preferred if both are
specified.

Here're the cases I have tested, and configs are listed below, logs
are also enclosed as attachment.

CaseA (MODULES=list, netconsole param from bootloader, tested on an
armel/orion5x device):
- /etc/initramfs-tools/initramfs.conf:
MODULES=list

- /etc/initramfs-tools/modules:
mv643xx_eth
netconsole
mvmdio
sata_mv
sd_mod
raid1
jfs

CaseB (MODULES=dep, netconsole param from bootloader, tested on an
armel/orion5x device):
- /etc/initramfs-tools/initramfs.conf:
MODULES=dep

- /etc/initramfs-tools/modules:
mv643xx_eth
netconsole
mvmdio

CaseC (MODULES=most, netconsole param from bootloader, tested on x86-64 device):
-/etc/initramfs-tools/initramfs.conf:
MODULES=most

- /etc/initramfs-tools/modules:
# empty

Cheers,
Roger
From 949aa33a0afd8bf576b72459bd1948c9fccf0705 Mon Sep 17 00:00:00 2001
From: Roger Shimizu <rogershimizu@gmail.com>
Date: Sat, 9 Jan 2016 07:16:09 +0900
Subject: [PATCH] support netconsole kernel param either from conf/modules or
 bootloader

need to consider various cases:
- MODULES=most (default) or MODULES={dep,list} (popular for embedded devices)
- netconsole param may be inside conf/modules or come with bootloader's config

for "MODULES=most" case , netconsole.ko is included by default, so there's
no need to list it in conf/modules, and netconsole param should be put into
bootloader's config

for "MODULES={dep,list}" case, netconsole param can be either from
conf/modules or bootloader, and the previous one is preferred if both are
specified.

Closes: #793786
Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
---
 init              | 3 ++-
 scripts/functions | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/init b/init
index 60e76c3..05ff743 100755
--- a/init
+++ b/init
@@ -207,10 +207,11 @@ run_scripts /scripts/init-top
 
 maybe_break modules
 [ "$quiet" != "y" ] && log_begin_msg "Loading essential drivers"
-[ -n "${netconsole}" ] && modprobe netconsole netconsole="${netconsole}"
 load_modules
 [ "$quiet" != "y" ] && log_end_msg
 
+[ -n "${netconsole}" ] && modprobe netconsole netconsole="${netconsole}"
+
 maybe_break premount
 [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
 run_scripts /scripts/init-premount
diff --git a/scripts/functions b/scripts/functions
index 499a430..9c85a15 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -97,6 +97,13 @@ load_modules()
 			if [ "$com" = "#" ]; then
 				continue
 			fi
+			if [ "x${m%%[[:space:]]*}" = "xnetconsole" ]; then
+				[ "x$debug" = "xy" -a -z "$netconsole" ] && exec >/dev/kmsg 2>&1
+				if [ "$m" = "netconsole" -a -n "$netconsole" ]; then
+					modprobe netconsole netconsole="$netconsole"
+					continue
+				fi
+			fi
 			modprobe $m
 		done
 	fi
-- 
2.7.0.rc3

Attachment: netconsole_log.tar.gz
Description: GNU Zip compressed data


Reply to: