[kexec-tools] add dracut_args option to kdump.conf
Baoquan He
baoquan at fedoraproject.org
Sat Apr 27 02:46:36 UTC 2013
commit fe96b47828e52edcba2868790baee5b77fb47092
Author: dyoung at redhat.com <dyoung at redhat.com>
Date: Mon Apr 15 10:12:05 2013 +0800
add dracut_args option to kdump.conf
mkdumprd call dracut to rebuilding kdump initrd, sometimes passing extra
dracut args is helpful. For example user can enable debug output with
--debug, --printsize to print roughly increased initramfs size by each module,
--omit-drivers to omit kernel modules, etc.
This patch enables dracut_args option for passing extra args to dracut.
Also it modifies add_dracut_arg() to treat a string with-in quote as single
string because for dracut options which has its own args, the args need to be
quoted and space seperated.
If add_dracut_arg() gets an string read from kdump.conf and if that string
contains double quotes, then while converting to positional parameters
those double quotes are not interpreted. Hence if /etc/kdump.conf contains
following.
dracut_args --add-drivers "driver1 driver2"
then add_dracut_args() sees following positional parameters
$1= --add-drivers
$2= "driver1
$3= driver2"
Notice, double quotes have been ignored and parameters have been broken
based on white space.
Modify add_dracut_arg() to look for parameters starting with " and
if one is found, it tries to merge all the next parameters till one
is found with ending double quote. Hence effectively simulating
following behavior.
$1= --add-drivers
$2= "driver1 driver2"
[v1->v2]: address quoted substring in dracut_args, also handle the leading
and ending spaces in substring.
[v2->v3]: fix dracut arguments seperator in kdump.conf.
[v3->v4]: improve changelog, thanks vivek.
[v4->v5]: make the manpage more verbose [vivek].
Tested with below dracut_args test cases:
1. dracut_args --add-drivers "pcspkr virtio_net" --omit-drivers "sdhci-pci hid-logitech-dj e1000"
2. dracut_args --add-drivers " pcspkr virtio_net " --omit-drivers "sdhci-pci hid-logitech-dj e1000"
Signed-off-by: Dave Young <dyoung at redhat.com>
Acked-by: Vivek Goyal <vgoyal at redhat.com>
kdump.conf | 5 +++++
kdump.conf.5 | 6 ++++++
kdumpctl | 2 +-
mkdumprd | 25 ++++++++++++++++++++++++-
4 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/kdump.conf b/kdump.conf
index de3ad4a..c5cfb4a 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -119,6 +119,10 @@
# Specifying 1 means though block target is unresettable, user
# understand this situation and want to try dumping. By default,
# it's set to 0, means not to try a destined failure.
+#
+# dracut_args <arg(s)>
+# - Pass extra dracut options when rebuilding kdump
+# initrd.
#raw /dev/vg/lv_kdump
#ext4 /dev/vg/lv_kdump
@@ -136,3 +140,4 @@ path /var/crash
#extra_modules gfs2
#default shell
#force_rebuild 1
+#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"
diff --git a/kdump.conf.5 b/kdump.conf.5
index 9e498c5..6f88370 100644
--- a/kdump.conf.5
+++ b/kdump.conf.5
@@ -171,6 +171,12 @@ to try dumping. By default, it's set to 0, means not to try a destined failure.
.RE
+.B dracut_args <arg(s)>
+.RS
+Kdump uses dracut to generate initramfs for second kernel. This option
+allows a user to pass arguments to dracut directly.
+.RE
+
.SH DEPRECATED OPTIONS
.B net <nfs mount>|<user at server>
diff --git a/kdumpctl b/kdumpctl
index 9b102e5..fad323c 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -86,7 +86,7 @@ function check_config()
case "$config_opt" in
\#* | "")
;;
- raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild)
+ raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|dracut_args)
[ -z "$config_val" ] && {
echo "Invalid kdump config value for option $config_opt."
return 1;
diff --git a/mkdumprd b/mkdumprd
index 0be02f6..24e5d98 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -45,9 +45,29 @@ get_persistent_dev() {
}
add_dracut_arg() {
+ local arg qarg is_quoted=0
while [ $# -gt 0 ];
do
- dracut_args+=("$1")
+ arg="${1//\'/\"}"
+ #Handle quoted substring properly for passing it to dracut_args array.
+ if [ $is_quoted -eq 0 ]; then
+ if [[ "$arg" == "\"" ]] || [[ $arg != ${arg#\"} ]]; then
+ is_quoted=1
+ arg=${arg#\"}
+ fi
+ fi
+ if [ $is_quoted -eq 1 ]; then
+ qarg="$qarg $arg"
+ if [[ "$arg" == "\"" ]] || [[ $arg != ${arg%\"} ]]; then
+ is_quoted=0
+ arg=${qarg%\"}
+ qarg=""
+ else
+ shift
+ continue
+ fi
+ fi
+ dracut_args+=("$arg")
shift
done
}
@@ -500,6 +520,9 @@ do
core_collector)
verify_core_collector "$config_val"
;;
+ dracut_args)
+ add_dracut_arg $config_val
+ ;;
*)
if [ -n $(echo $config_opt | grep "^#.*$") ]
then
More information about the scm-commits
mailing list