[PATCH] Don't iterate the whole /sys/devices just to find drm device
by Kairui Song
On some large systems, /sys/devices is huge and it's not a wise idea to
iterate it. `find` may cause tremendous contention on the kernfs_mutex
when there are already stress on /sys, and it will perform very very
poorly.
Simply check if drm class presents should be good enough.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
dracut-module-setup.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index ac0f196..ce05de7 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -58,7 +58,7 @@ depends() {
_dep="$_dep znet"
fi
- if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then
+ if [ -n "$( ls -A /sys/class/drm 2>/dev/null )" ] || [ -d /sys/module/hyperv_fb ]; then
add_opt_module drm
fi
--
2.29.2
2 hours, 33 minutes
[PATCH v2 1/2] Implement IP netmask calculation to replace "ipcalc -m"
by Coiby Xu
Recently, dracut-network drops depedency on dhcp-client which requires
ipcalc. Thus the dependency chain
"kexec-tools -> dracut-network -> dhcp-client -> ipcalc"
is broken. When NIC is configured to a static IP, kexec-tools depended
on "ipcalc -m" to get netmask. This commit implements the shell
equivalent of "ipcalc -m".
The following test code shows cal_netmask_by_prefix is consistent with
"ipcalc -m",
#!/bin/bash
. dracut-module-setup.sh
for i in {0..128}; do
mask_expected=$(ipcalc -m fe::/$i| cut -d"=" -f2)
mask_actual=$(cal_netmask_by_prefix $i true)
if [[ "$mask_expected" != "$mask_actual" ]]; then
echo $i, "expected=", $mask_expected, "acutal=", $mask_actual
fi
done
for i in {0..32}; do
mask_expected=$(ipcalc -m 8.8.8.8/$i| cut -d"=" -f2)
mask_actual=$(cal_netmask_by_prefix $i false)
if [[ "$mask_expected" != "$mask_actual" ]]; then
echo $i, "expected=", $mask_expected, "acutal=", $mask_actual
fi
done
Reported-by: Jie Li <jieli(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
v1 -> v2:
1. Check subshell exit code when calling cal_netmask_by_prefix
2. Stop using die when bad prefix is passed to cal_netmask_by_prefix
3. Remove trailing spaces
---
dracut-module-setup.sh | 115 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 113 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 8316589..ea6f7ea 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -121,17 +121,123 @@ kdump_setup_dns() {
done < "/etc/resolv.conf"
}
+# $1: repeat times
+# $2: string to be repeated
+# $3: separator
+repeatedly_join_str() {
+ local _count="$1"
+ local _str="$2"
+ local _separator="$3"
+ local i _res
+
+ if [[ "$_count" -le 0 ]]; then
+ echo -n ""
+ return
+ fi
+
+ i=0
+ _res="$_str"
+ ((_count--))
+
+ while [[ "$i" -lt "$_count" ]]; do
+ ((i++))
+ _res="${_res}${_separator}${_str}"
+ done
+ echo -n "$_res"
+}
+
+# $1: prefix
+# $2: ipv6 or not
+# Given a prefix, calculate the netmask (equivalent of "ipcalc -m")
+# by concatenating three parts,
+# 1) the groups with all bits set 1
+# 2) a group with partial bits set to 0
+# 3) the groups with all bits set to 0
+cal_netmask_by_prefix() {
+ local _prefix="$1"
+ local _ipv6="$2"
+ local _bits_per_octet=8
+ local _count _res _octets_per_group _octets_total _seperator _total_groups
+ local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits
+
+ if [[ "$_prefix" -lt 0 || ("$_ipv6" && "$_prefix" -gt 128) || \
+ (!"$_ipv6" && "$_prefix" -gt 32) ]]; then
+ derror "Bad prefix:$_prefix for calculating netmask"
+ exit 1
+ fi
+
+ if "$_ipv6"; then
+ _octets_per_group=2
+ _octets_total=16
+ _seperator=":"
+ else
+ _octets_per_group=1
+ _octets_total=4
+ _seperator="."
+ fi
+
+ _total_groups=$((_octets_total/_octets_per_group))
+ _bits_per_group=$((_octets_per_group * _bits_per_octet))
+ _max_group_value=$(((1 << _bits_per_group) - 1))
+
+ if "$_ipv6"; then
+ _max_group_value_repr=$(printf "%x" $_max_group_value)
+ else
+ _max_group_value_repr="$_max_group_value"
+ fi
+
+ _count=$((_prefix/_octets_per_group/_bits_per_octet))
+ _first_part=$(repeatedly_join_str "$_count" "$_max_group_value_repr" "$_seperator")
+ _res="$_first_part"
+
+ _tmp=$((_octets_total*_bits_per_octet-_prefix))
+ _zero_bits=$(expr $_tmp % $_bits_per_group)
+ if [[ "$_zero_bits" -ne 0 ]]; then
+ _second_part=$((_max_group_value >> _zero_bits << _zero_bits))
+ if "$_ipv6"; then
+ _second_part=$(printf "%x" $_second_part)
+ fi
+ ((_count++))
+ if [[ -z "$_first_part" ]]; then
+ _res="$_second_part"
+ else
+ _res="${_first_part}${_seperator}${_second_part}"
+ fi
+ fi
+
+ _count=$((_total_groups-_count))
+ if [[ "$_count" -eq 0 ]]; then
+ echo -n "$_res"
+ return
+ fi
+
+ if "$_ipv6" && [[ "$_count" -gt 1 ]] ; then
+ # use condensed notion for IPv6
+ _third_part=":"
+ else
+ _third_part=$(repeatedly_join_str "$_count" "0" "$_seperator")
+ fi
+
+ if [[ -z "$_res" ]] && ! "$_ipv6" ; then
+ echo -n "${_third_part}"
+ else
+ echo -n "${_res}${_seperator}${_third_part}"
+ fi
+}
+
#$1: netdev name
#$2: srcaddr
#if it use static ip echo it, or echo null
kdump_static_ip() {
local _netdev="$1" _srcaddr="$2" _ipv6_flag
- local _netmask _gateway _ipaddr _target _nexthop
+ local _netmask _gateway _ipaddr _target _nexthop _prefix
+ local _ipv6=false
_ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}")
if is_ipv6_address $_srcaddr; then
_ipv6_flag="-6"
+ _ipv6=true
fi
if [ -n "$_ipaddr" ]; then
@@ -144,7 +250,12 @@ kdump_static_ip() {
_srcaddr="[$_srcaddr]"
_gateway="[$_gateway]"
else
- _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
+ _prefix=$(cut -d'/' -f2 <<< "$_ipaddr")
+ _netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6")
+ if [[ "$?" -ne 0 ]]; then
+ derror "Failed to calculate netmask for $_ipaddr"
+ exit 1
+ fi
fi
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fi
--
2.31.0
1 week
[PATCH] kdumpctl: Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not
writable
by Kelvin Fan
The /boot directory on some operating systems might be read-only.
If we cannot write to $KDUMP_BOOTDIR when generating the kdump
initrd, attempt to place the generated initrd at `/var/lib/kdump`
instead.
Signed-off by: Kelvin Fan <kfan(a)redhat.com>
---
kdumpctl | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 24f5cf7..2107e3e 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -152,8 +152,15 @@ rebuild_kdump_initrd()
rebuild_initrd()
{
if [[ ! -w "$KDUMP_BOOTDIR" ]];then
- derror "$KDUMP_BOOTDIR does not have write permission. Can not rebuild $TARGET_INITRD"
- return 1
+ VAR_TARGET_INITRD_DIR="/var/lib/kdump"
+ mkdir -p "$VAR_TARGET_INITRD_DIR"
+ TARGET_INITRD_BASE="$(basename $TARGET_INITRD)"
+ TARGET_INITRD="$VAR_TARGET_INITRD_DIR/$TARGET_INITRD_BASE"
+ dwarn "$KDUMP_BOOTDIR does not have write permission. Rebuilding initrd at $TARGET_INITRD"
+ if [[ ! -w "$VAR_TARGET_INITRD_DIR" ]];then
+ derror "$VAR_TARGET_INITRD_DIR does not have write permission. Cannot rebuild $TARGET_INITRD"
+ return 1
+ fi
fi
if [ $DEFAULT_DUMP_MODE == "fadump" ]; then
@@ -656,6 +663,9 @@ load_kdump()
KEXEC_ARGS="$KEXEC_ARGS -s"
fi
+ # Relabel the target initrd for SELinux.
+ chcon -t boot_t $TARGET_INITRD
+
ddebug "$KEXEC $KEXEC_ARGS $standard_kexec_args --command-line=$KDUMP_COMMANDLINE --initrd=$TARGET_INITRD $KDUMP_KERNEL"
# The '12' represents an intermediate temporary file descriptor
--
2.29.2
1 week, 1 day
[PATCH 0/3] Use a standalone kdump emergency shell
by Kairui Song
Currently kdump use some wrapper around dracut emergency service and
emergency shell, this have many problems:
- If dracut-initqueue failed back to emergency mode due to timeout,
and faiure action is set to dump_to_rootfs, kdump will try start
initqueue again, lead to double timeout error.
- Dracut's emergency shell have many builtin actions, like
perform dracut emergency_action, ask for root password, generate
rdsosreport etc.
This series remove the emergency wrapper, and use a standalone kdump
emergency shell. Kdump will always perform final_action after kdump
shell, so simplified version works fine.
Kairui Song (3):
Don's try to restart dracut-initqueue if it's already there
Remove the kdump error handler isolation wrapper
Use a customized emergency shell
dracut-kdump-emergency.service | 25 +++++++++----------
dracut-kdump-error-handler.service | 33 ------------------------
dracut-module-setup.sh | 1 -
kdump-lib-initramfs.sh | 40 +++++++++++++++++++++++++-----
kexec-tools.spec | 2 --
5 files changed, 46 insertions(+), 55 deletions(-)
delete mode 100644 dracut-kdump-error-handler.service
--
2.29.2
1 week, 1 day
[PATCH v2] Doc: improve the kexec-kdump-howto.txt documentation
by Lianbo Jiang
Because there are some duplicated contents, this will remove the
infrequently used options descriptions from the "kexec-kdump-howto.txt",
only add the "KDUMP_COMMANDLINE_REMOVE" and "KDUMP_COMMANDLINE_APPEND".
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
kexec-kdump-howto.txt | 78 +++++++++++++++----------------------------
1 file changed, 27 insertions(+), 51 deletions(-)
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt
index 88af6078ae6e..d23dd24b3fc7 100644
--- a/kexec-kdump-howto.txt
+++ b/kexec-kdump-howto.txt
@@ -525,7 +525,7 @@ Advanced Setups
===============
About /etc/sysconfig/kdump
-------------------------------
+--------------------------
Currently, there are a few options in /etc/sysconfig/kdump, which are
usually used to control the behavior of kdump kernel. Basically, all of
@@ -533,51 +533,29 @@ these options have default values, usually we do not need to change them,
but sometimes, we may modify them in order to better control the behavior
of kdump kernel such as debug, etc.
--KDUMP_BOOTDIR
+Usually option of kexec utility is used to inherit the kernel cmdline
+from the 1st kernel for kdump kernel. E.g specifying --command-line=
+"`cat /proc/cmdline`" or simply using '--reuse-cmdline'. Then only need
+modify KDUMP_COMMANDLINE_APPEND and KDUMP_COMMANDLINE_REMOVE in the
+/etc/sysconfig/kdump to adjust the kernel cmdline of kdump as expected.
+
+For detailed description of each options, please refer to the file
+/etc/sysconfig/kdump directly.
+
+Kdump boot directory
+--------------------
Usually kdump kernel is the same as 1st kernel. So kdump will try to find
kdump kernel under /boot according to /proc/cmdline. E.g we execute below
command and get an output:
cat /proc/cmdline
BOOT_IMAGE=/xxx/vmlinuz-3.yyy.zzz root=xxxx .....
+Then kdump kernel will be /boot/xxx/vmlinuz-3.yyy.zzz.
+However a variable KDUMP_BOOTDIR in /etc/sysconfig/kdump is provided to
+user if kdump kernel is put in a different directory.
-Then kdump kernel will be /boot/xxx/vmlinuz-3.yyy.zzz. However, this option
-is provided to user if kdump kernel is put in a different directory.
-
--KDUMP_IMG
-
-This represents the image type used for kdump. The default value is "vmlinuz".
-
--KDUMP_IMG_EXT
-
-This represents the images extension. Relocatable kernels don't have one.
-Currently, it is a null string by default.
-
--KEXEC_ARGS
-
-Any additional kexec arguments required. For example:
-KEXEC_ARGS="--elf32-core-headers".
-
-In most situations, this should be left empty. But, sometimes we hope to get
-additional kexec loading debugging information, we can add the '-d' option
-for the debugging.
-
--KDUMP_KERNELVER
-
-This is a kernel version string for the kdump kernel. If the version is not
-specified, the init script will try to find a kdump kernel with the same
-version number as the running kernel.
-
--KDUMP_COMMANDLINE
-
-The value of 'KDUMP_COMMANDLINE' will be passed to kdump kernel as command
-line parameters, this will likely match the contents of the grub kernel line.
-
-In general, if a command line is not specified, which means that it is a null
-string such as KDUMP_COMMANDLINE="", the default will be taken automatically
-from the '/proc/cmdline'.
-
--KDUMP_COMMANDLINE_REMOVE
+KDUMP_COMMANDLINE_REMOVE
+------------------------
This option allows us to remove arguments from the current kdump command line.
If we don't specify any parameters for the KDUMP_COMMANDLINE, it will inherit
@@ -586,30 +564,28 @@ default kernel parameters could affect kdump, furthermore, that could cause
the failure of kdump kernel boot.
In addition, the option is also helpful to debug the kdump kernel, we can use
-this option to change kdump kernel command line.
+this option to change kdump kernel command line. For example:
-For more kernel parameters, please refer to kernel document.
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet log_buf_len swiotlb"
--KDUMP_COMMANDLINE_APPEND
+For more kernel parameters, please refer to kernel document:
+Documentation/admin-guide/kernel-parameters.txt.
+
+KDUMP_COMMANDLINE_APPEND
+------------------------
This option allows us to append arguments to the current kdump command line
after processed by the KDUMP_COMMANDLINE_REMOVE. For kdump kernel, some
specific modules require to be disabled like the mce, cgroup, numa, hest_disable,
etc. Those modules may waste memory or kdump kernel doesn't need them,
-furthermore, there may affect kdump kernel boot.
+furthermore, there may affect kdump kernel boot. For example:
+
+KDUMP_COMMANDLINE_APPEND="cgroup_disable=memory"
Just like above option, it can be used to disable or enable some kernel
modules so that we can exclude any errors for kdump kernel, this is very
meaningful for debugging.
--KDUMP_STDLOGLVL | KDUMP_SYSLOGLVL | KDUMP_KMSGLOGLVL
-
-These variables are used to control the kdump log level in the first kernel.
-In the second kernel, kdump will use the rd.kdumploglvl option to set the log
-level in the above KDUMP_COMMANDLINE_APPEND.
-
-Logging levels: no logging(0), error(1), warn(2), info(3), debug(4)
-
Kdump Post-Capture Executable
-----------------------------
--
2.29.2
1 week, 4 days
[PATCH] Don't use die in dracut-module-setup.sh
by Coiby Xu
die (in dracut-lib.sh) is supposed to be used in the initramfs environment.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
dracut-module-setup.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 8316589..394317c 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -334,7 +334,10 @@ kdump_setup_znet() {
kdump_get_ip_route()
{
local _route=$(/sbin/ip -o route get to $1 2>&1)
- [ $? != 0 ] && die "Bad kdump network destination: $1"
+ if [[ $? != 0 ]]; then
+ derror "Bad kdump network destination: $1"
+ exit 1
+ fi
echo $_route
}
--
2.31.0
2 weeks
Set up kdump network by parsing nmcli output and drop dependence on ifcfg scripts
by Coiby Xu
ifcfg scripts are deprecated. kexec-tools still set up network
based on ifcfg scripts which lead to the issues like [1] [2].
We can get network configuration including dns, bond and znet by
parsing nmcli output instead. Another benefit is we could potentially
avoid subtle bugs caused by namespace pollution because of sourcing
ifcfg scripts.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1919052
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1933679
Coiby Xu (8):
Parse option value from nmcli output
Get nmcli connection id by ifname
get nmcli connection show output by ifname
setup s390 znet cmdline by parsing nmcli connection show output
setup dns by parsing nmcli connection show output
setup bond by parsing nmcli connection show output
clean up codes related to ifcfg scripts
clean up unused is_nm_* functions
dracut-module-setup.sh | 72 +++++++++++++---------------
kdump-lib.sh | 106 ++++++++++++-----------------------------
2 files changed, 65 insertions(+), 113 deletions(-)
--
2.30.1
2 weeks, 1 day
[PATCH 1/2] Implement IP netmask caculation to replace "ipcalc -m"
by Coiby Xu
Recently, dracut-network drops depedency on dhcp-client which requires
ipcalc. Thus the dependency chain
"kexec-tools -> dracut-network -> dhcp-client -> ipcalc"
is broken. When NIC is configured to a static IP, kexec-tools depended
on "ipcalc -m" to get netmask. This commit implements the shell
equivalent of "ipcalc -m".
The following test code shows cal_netmask_by_prefix is consistent with
"ipcalc -m",
#!/bin/bash
. dracut-module-setup.sh
for i in {0..128}; do
mask_expected=$(ipcalc -m fe::/$i| cut -d"=" -f2)
mask_actual=$(cal_netmask_by_prefix $i true)
if [[ "$mask_expected" != "$mask_actual" ]]; then
echo $i, "expected=", $mask_expected, "acutal=", $mask_actual
fi
done
for i in {0..32}; do
mask_expected=$(ipcalc -m 8.8.8.8/$i| cut -d"=" -f2)
mask_actual=$(cal_netmask_by_prefix $i false)
if [[ "$mask_expected" != "$mask_actual" ]]; then
echo $i, "expected=", $mask_expected, "acutal=", $mask_actual
fi
done
Reported-by: Jie Li <jieli(a)redhat.com>
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
dracut-module-setup.sh | 107 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 105 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 21143b4..bf6acf9 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -121,17 +121,119 @@ kdump_setup_dns() {
done < "/etc/resolv.conf"
}
+# $1: repeat times
+# $2: string to be repeated
+# $3: separator
+repeatedly_join_str() {
+ local _count="$1"
+ local _str="$2"
+ local _separator="$3"
+ local i _res
+
+ if [[ "$_count" -le 0 ]]; then
+ echo -n ""
+ return
+ fi
+
+ i=0
+ _res="$_str"
+ ((_count--))
+
+ while [[ "$i" -lt "$_count" ]]; do
+ ((i++))
+ _res="${_res}${_separator}${_str}"
+ done
+ echo -n "$_res"
+}
+
+# $1: prefix
+# $2: ipv6 or not
+# Given a prefix, calculate the netmask (equivalent of "ipcalc -m")
+# by concatenating three parts,
+# 1) the groups with all bits set 1
+# 2) a group with partial bits set to 0
+# 3) the groups with all bits set to 0
+#
+cal_netmask_by_prefix() {
+ local _prefix="$1"
+ local _ipv6="$2"
+ local _bits_per_octet=8
+ local _count _res _octets_per_group _octets_total _seperator _total_groups
+ local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits
+
+ if "$_ipv6"; then
+ [ "$_prefix" -gt 128 ] || [ "$_prefix" -lt 0 ] && die "Wrong IPv6 prefix $_prefix"
+ _octets_per_group=2
+ _octets_total=16
+ _seperator=":"
+ else
+ [ "$_prefix" -gt 32 ] || [ "$_prefix" -lt 0 ] && die "Wrong IPv4 prefix $_prefix"
+ _octets_per_group=1
+ _octets_total=4
+ _seperator="."
+ fi
+
+ _total_groups=$((_octets_total/_octets_per_group))
+ _bits_per_group=$((_octets_per_group * _bits_per_octet))
+ _max_group_value=$(((1 << _bits_per_group) - 1))
+
+ if "$_ipv6"; then
+ _max_group_value_repr=$(printf "%x" $_max_group_value)
+ else
+ _max_group_value_repr="$_max_group_value"
+ fi
+
+ _count=$((_prefix/_octets_per_group/_bits_per_octet))
+ _first_part=$(repeatedly_join_str "$_count" "$_max_group_value_repr" "$_seperator")
+ _res="$_first_part"
+
+ _tmp=$((_octets_total*_bits_per_octet-_prefix))
+ _zero_bits=$(expr $_tmp % $_bits_per_group)
+ if [[ "$_zero_bits" -ne 0 ]]; then
+ _second_part=$((_max_group_value >> _zero_bits << _zero_bits))
+ if "$_ipv6"; then
+ _second_part=$(printf "%x" $_second_part)
+ fi
+ ((_count++))
+ if [[ -z "$_first_part" ]]; then
+ _res="$_second_part"
+ else
+ _res="${_first_part}${_seperator}${_second_part}"
+ fi
+ fi
+
+ _count=$((_total_groups-_count))
+ if [[ "$_count" -eq 0 ]]; then
+ echo -n "$_res"
+ return
+ fi
+
+ if "$_ipv6" && [[ "$_count" -gt 1 ]] ; then
+ # use condensed notion for IPv6
+ _third_part=":"
+ else
+ _third_part=$(repeatedly_join_str "$_count" "0" "$_seperator")
+ fi
+
+ if [[ -z "$_res" ]] && ! "$_ipv6" ; then
+ echo -n "${_third_part}"
+ else
+ echo -n "${_res}${_seperator}${_third_part}"
+ fi
+}
#$1: netdev name
#$2: srcaddr
#if it use static ip echo it, or echo null
kdump_static_ip() {
local _netdev="$1" _srcaddr="$2" _ipv6_flag
- local _netmask _gateway _ipaddr _target _nexthop
+ local _netmask _gateway _ipaddr _target _nexthop _prefix
+ local _ipv6=false
_ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}")
if is_ipv6_address $_srcaddr; then
_ipv6_flag="-6"
+ _ipv6=true
fi
if [ -n "$_ipaddr" ]; then
@@ -144,7 +246,8 @@ kdump_static_ip() {
_srcaddr="[$_srcaddr]"
_gateway="[$_gateway]"
else
- _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
+ _prefix=$(cut -d'/' -f2 <<< "$_ipaddr")
+ _netmask=$(cal_netmask_by_prefix "$_prefix" "$_ipv6")
fi
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fi
--
2.31.0
3 weeks
[PATCH v2 0/3] Preparing for running kexec-tools tests from dracut
by Coiby Xu
kexec-tools heavily depends on dracut and occasionally breaks
because the change of dracut.
I'm now adding kdump test [1] to dracut which will clone kexec-tools'
rawhide branch and run kexec-tools' basic functionality tests.
This patch set prepares kexec-tools for running its tests from dracut.
[1] https://github.com/coiby/dracut/tree/kexec_tools_tests
v1 -> v2:
- s/DRACUT_RPMs/EXTRA_RPMS [Kairui]
Coiby Xu (3):
selftest: Fix bug of collecting test RPMs from argument
selftest: add EXTRA_RPMs so dracut RPMs can be installed onto the
image to run the tests
selftest: replace qemu-kvm with one based on dracut's run-qemu
tests/Makefile | 2 +-
.../scripts/build-scripts/test-base-image.sh | 2 +-
tests/scripts/run-qemu | 23 +++++++++++++++++++
tests/scripts/test-lib.sh | 2 +-
4 files changed, 26 insertions(+), 3 deletions(-)
create mode 100755 tests/scripts/run-qemu
--
2.31.0
3 weeks
[PATCH] mkdumprd: prompt the user to install nfs-utils when mounting NFS fs failed
by Coiby Xu
When nfs-utils is not installed, mounting as NFS fs would fail.
Currently, the error message is not user-friendly,
mount: /tmp/mkdumprd.HyPGpS/target: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.
kdump: Failed to mount on xxx for kdump preflight check.
kdump: mkdumprd: failed to make kdump initrd
Prompt the user to install nfs-utilsa in the error message,
kdump: Failed to mount on xxx for kdump preflight check. Please make sure nfs-utils has been installed.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
mkdumprd | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index c34b79c..50ebdc8 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -185,6 +185,26 @@ check_save_path_fs()
fi
}
+mount_failure()
+{
+ local _target=$1
+ local _mnt=$2
+ local _fstype=$3
+ local msg="Failed to mount $_target"
+
+ if [ -n "$_mnt" ]; then
+ msg="$msg on $_mnt"
+ fi
+
+ msg="$msg for kdump preflight check."
+
+ if [[ $_fstype = "nfs" ]]; then
+ msg="$msg Please make sure nfs-utils has been installed."
+ fi
+
+ perror_exit "$msg"
+}
+
check_user_configured_target()
{
local _target=$1 _cfg_fs_type=$2 _mounted
@@ -210,7 +230,7 @@ check_user_configured_target()
if ! is_mounted "$_mnt"; then
if [[ $_opt = *",noauto"* ]]; then
mount $_mnt
- [ $? -ne 0 ] && perror_exit "Failed to mount $_target on $_mnt for kdump preflight check."
+ [ $? -ne 0 ] && mount_failure "$_target" "$_mnt" "$_fstype"
_mounted=$_mnt
else
perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\""
@@ -220,7 +240,7 @@ check_user_configured_target()
_mnt=$MKDUMPRD_TMPMNT
mkdir -p $_mnt
mount $_target $_mnt -t $_fstype -o defaults
- [ $? -ne 0 ] && perror_exit "Failed to mount $_target for kdump preflight check."
+ [ $? -ne 0 ] && mount_failure "$_target" "" "$_fstype"
_mounted=$_mnt
fi
--
2.30.0
3 weeks