From: Pratyush Anand <panand-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Pratyush Anand <panand-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Don Zickus <dzickus-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH RFC dracut] watchdog: install module for active watchdog
Date: Fri, 26 Feb 2016 19:22:18 +0530 [thread overview]
Message-ID: <84fb272d0cfa043a19256ce4231c72c73268cca1.1456494446.git.panand@redhat.com> (raw)
Recently following patches have been added in upstream Linux kernel, which
(1) fixes parent of watchdog_device so that
/sys/class/watchdog/watchdogn/device is populated. (2) adds some sysfs
device attributes so that different watchdog status can be read.
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6551881c86c791237a3bebf11eb3bd70b60ea782
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=906d7a5cfeda508e7361f021605579a00cd82815
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=33b711269ade3f6bc9d9d15e4343e6fa922d999b
With the above support, now we can find out whether a watchdog is active or
not. If it is active, we can also find out the driver/module responsible
for that watchdog device.
Proposed patch uses above support and then adds module of active watchdog
in initramfs generated by dracut for --hostonly mode.
If an user does not want to add this support then he/she may pass --nowdt
with dracut command.
Testing:
-- When watchdog is active and --nowdt was passed, watchdog modules were not
added
# cat /sys/class/watchdog/watchdog0/identity
iTCO_wdt
# cat /sys/class/watchdog/watchdog0/state
active
# dracut --hostonly --nowdt --hostonly-cmdline initramfs-test.img -a watchdog
# lsinitrd initramfs-test.img | grep iTCO
# lsinitrd -f usr/lib/dracut/active-watchdogs initramfs-test.img
-- When watchdog is active and --nowdt was not passed, watchdog modules were
added
# dracut --hostonly --hostonly-cmdline initramfs-test.img -a watchdog
# lsinitrd initramfs-test.img | grep iTCO
-rw-r--r-- 1 root root 9100 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_vendor_support.ko
-rw-r--r-- 1 root root 19252 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_wdt.ko
# lsinitrd -f usr/lib/dracut/active-watchdogs initramfs-test.img
iTCO_wdt
-- When watchdog is inactive then watchdog modules were not added
# cat /sys/class/watchdog/watchdog0/state
inactive
# dracut --hostonly --nowdt --hostonly-cmdline initramfs-test.img -a watchdog
# lsinitrd initramfs-test.img | grep iTCO
# lsinitrd -f usr/lib/dracut/active-watchdogs initramfs-test.img
# dracut --hostonly --hostonly-cmdline initramfs-test.img -a watchdog
# lsinitrd initramfs-test.img | grep iTCO
# lsinitrd -f usr/lib/dracut/active-watchdogs initramfs-test.img
Signed-off-by: Pratyush Anand <panand-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Don Zickus <dzickus-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
Hi Harald,
I am not subscribed to initramfs mailing list, so kindly keep me in CC for
replies.
~Pratyush
dracut-bash-completion.sh | 2 +-
dracut.8.asc | 3 +++
dracut.conf.5.asc | 3 +++
dracut.sh | 6 +++++-
modules.d/04watchdog/module-setup.sh | 37 ++++++++++++++++++++++++++++++++++++
5 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/dracut-bash-completion.sh b/dracut-bash-completion.sh
index 09330a673230..3d6519a71cd4 100644
--- a/dracut-bash-completion.sh
+++ b/dracut-bash-completion.sh
@@ -40,7 +40,7 @@ _dracut() {
--fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
--kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
--kernel-cmdline --sshkey --persistent-policy --install-optional
- --loginstall --uefi-stub --kernel-image
+ --loginstall --uefi-stub --kernel-image --nowdt
'
)
diff --git a/dracut.8.asc b/dracut.8.asc
index aee84c45a1c5..65519154af6d 100644
--- a/dracut.8.asc
+++ b/dracut.8.asc
@@ -237,6 +237,9 @@ example:
**--nofscks**::
inhibit installation of any fsck tools
+**--nowdt**::
+ inhibit installation of module for any active watchdog
+
**--strip**::
strip binaries in the initramfs (default)
diff --git a/dracut.conf.5.asc b/dracut.conf.5.asc
index 0460d4fff8d4..755b90bbbe14 100644
--- a/dracut.conf.5.asc
+++ b/dracut.conf.5.asc
@@ -139,6 +139,9 @@ provide a valid _/etc/fstab_.
*nofscks=*"__{yes|no}__"::
If specified, inhibit installation of any fsck tools.
+*nowdt=*"__{yes|no}__"::
+ If specified, inhibit installation of module for any active watchdog.
+
*ro_mnt=*"__{yes|no}__"::
Mount _/_ and _/usr_ read-only by default.
diff --git a/dracut.sh b/dracut.sh
index 98dbe0bcc259..6acd48e9ced2 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -120,6 +120,7 @@ Creates initial ramdisk images for preloading modules
--nolvmconf Do not include local /etc/lvm/lvm.conf
--fscks [LIST] Add a space-separated list of fsck helpers.
--nofscks Inhibit installation of any fsck helpers.
+ --nowdt Inhibit installation of module for any active watchdog
--ro-mnt Mount / and /usr read-only by default.
-h, --help This message
--debug Output debug information of the build process
@@ -304,6 +305,7 @@ rearrange_params()
--long device: \
--long add-device: \
--long nofscks: \
+ --long nowdt: \
--long ro-mnt \
--long kmoddir: \
--long conf: \
@@ -478,6 +480,7 @@ while :; do
--add-device|--device) add_device_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
--kernel-cmdline) kernel_cmdline_l+=("$2"); PARMS_TO_STORE+=" '$2'"; shift;;
--nofscks) nofscks_l="yes";;
+ --nowdt) nowdt_l="yes";;
--ro-mnt) ro_mnt_l="yes";;
-k|--kmoddir) drivers_dir_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
-c|--conf) conffile="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
@@ -740,6 +743,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
[[ $compress_l ]] && compress=$compress_l
[[ $show_modules_l ]] && show_modules=$show_modules_l
[[ $nofscks_l ]] && nofscks="yes"
+[[ $nowdt_l ]] && nowdt="yes"
[[ $ro_mnt_l ]] && ro_mnt="yes"
[[ $early_microcode_l ]] && early_microcode=$early_microcode_l
[[ $early_microcode ]] || early_microcode=no
@@ -1276,7 +1280,7 @@ export initdir dracutbasedir \
mods_to_load \
fw_dir drivers_dir debug no_kernel kernel_only \
omit_drivers mdadmconf lvmconf root_dev \
- use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
+ use_fstab fstab_lines libdirs fscks nofscks nowdt ro_mnt \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug host_fs_types host_devs swap_devs sshkey add_fstab \
DRACUT_VERSION udevdir prefix filesystems drivers \
diff --git a/modules.d/04watchdog/module-setup.sh b/modules.d/04watchdog/module-setup.sh
index 576c589c198d..b6443dd60c94 100755
--- a/modules.d/04watchdog/module-setup.sh
+++ b/modules.d/04watchdog/module-setup.sh
@@ -27,3 +27,40 @@ install() {
inst_multiple -o wdctl
}
+installkernel() {
+ if [[ $hostonly ]] && [[ $nowdt != "yes" ]]; then
+ wdtcls=/sys/class/watchdog
+ cd $wdtcls
+ for dir in */; do
+ cd $dir
+ active=`[ -f state ] && cat state`
+ if [ "$active" = "active" ]; then
+ # applications like kdump need to know that
+ # which watchdog modules have been added
+ # into initramfs
+ echo `cat identity` >> "$initdir/lib/dracut/active-watchdogs"
+ # device/modalias will return driver of this device
+ wdtdrv=`cat device/modalias`
+ # There can be more than one module represented by same
+ # modalias. Currently load all of them.
+ # TODO: Need to find a way to avoid any unwanted module
+ # represented by modalias
+ wdtdrv=`modprobe -R $wdtdrv | tr "\n" "," | sed 's/.$//'`
+ instmods $wdtdrv
+ # however in some cases, we also need to check that if
+ # there is a specific driver for the parent bus/device.
+ # In such cases we also need to enable driver for parent
+ # bus/device.
+ wdtppath="device/..";
+ while [ -f "$wdtppath/modalias" ]
+ do
+ wdtpdrv=`cat $wdtppath/modalias`
+ wdtpdrv=`modprobe -R $wdtpdrv | tr "\n" "," | sed 's/.$//'`
+ instmods $wdtpdrv
+ wdtppath="$wdtppath/.."
+ done
+ fi
+ cd ..
+ done
+ fi
+}
--
2.5.0
next reply other threads:[~2016-02-26 13:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 13:52 Pratyush Anand [this message]
[not found] ` <84fb272d0cfa043a19256ce4231c72c73268cca1.1456494446.git.panand-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-02-26 14:03 ` [PATCH RFC dracut] watchdog: install module for active watchdog 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=84fb272d0cfa043a19256ce4231c72c73268cca1.1456494446.git.panand@redhat.com \
--to=panand-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=dzickus-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=harald-H+wXaHxf7aLQT0dZR+AlfA@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).