Commit Graph

210 Commits

Author SHA1 Message Date
Kairui Song
c6021648f1 Don't iterate the whole /sys/devices just to find drm device
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@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2021-04-16 17:47:27 +08:00
Tao Liu
91c802ff52 Fix incorrect permissions on kdump dmesg file
Also known as CVE-2021-20269. The kdump dmesg log files(kexec-dmesg.log,
vmcore-dmesg.txt) are generated by shell redirection, which take the
default umask value, making the files readable for group and others.

This patch chmod these files, making them only accessible to owner.

Signed-off-by: Tao Liu <ltao@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-03-23 16:39:18 +08:00
Pingfan Liu
24bbe9c05e dracut-module-setup.sh: enable ForwardToConsole=yes in fadump mode
In fadump mode, it is also useful to observe kdump message through
console. Hence enable it.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2021-01-22 14:16:17 +08:00
Kairui Song
88f787e1f5 module-setup.sh: don't polute the namespace unnecessarily
Only source kdump libs when building a kdump initramfs.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2021-01-20 14:14:08 +08:00
Kairui Song
d49a5015d8 module-setup.sh: don't source $dracutfunctions
There is no need to source the file manually, dracut will always
prepare the dracut lib before calling a module-setup.sh

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2021-01-20 14:14:03 +08:00
Kairui Song
24c6b3027f Merge #4 Make dracut-squash a weak dep 2021-01-10 19:18:23 +00:00
Kairui Song
fa9797ec9d dracut-module-setup.sh: Use systemctl call to replace ln_r
systemctl -q --root "$initdir" add-wants X.target X.service is the
recommanded way to add service dependency, and it covers more corner
cases.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-12-15 10:13:08 +08:00
Pingfan Liu
eaf0e813a2 dracut-module-setup.sh: use auto6 for ipv6
The parameter either6 is introduced to dracut by
commit 67354eebbcd4c358b8194ba5fd1ab1cf7dbd42aa
Author: Pingfan Liu <piliu@redhat.com>
Date:   Tue Apr 24 16:41:21 2018 +0800

    40network: introduce ip=either6 option

But it turns out needless.

On a sensible ipv6 network environment, DHCPv6 can not work properly alone,
because DHCPv6 protocol has no info about the gateway.

An reasonalbe process of ipv6 address set up should look like
   host send: Router Solicitation
   router reply: Router Advertisements

"Router Advertisements" carries many info like gateway, and if it has
other-config flag set, it carries DNS info etc.  As for DHCPv6 address
allocation, it will only start if "Router Advertisements" has the 'managed'
flag set, which directs the host to start a stateful address allocation
from DHCPv6 server.

For more info:
rfc4861: Neighbor Discovery for IP version 6 (IPv6)
rfc5175: IPv6 Router Advertisement Flags Option

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-12-07 14:59:57 +08:00
Pingfan Liu
6f9235887f module-setup.sh: enable vlan on team interface
Dracut has switch network-legacy to network-manager by default, which makes
vlan on team easy. So it can be enabled.

Testing network topology with two VMs.
VM1
            ens2-\         /----> VLAN8 (192.168.120.50)
                  ---> team0
            ens3-/     (192.168.122.10)

VM2
            ens2-\         /----> VLAN8 (192.168.120.100)
                  ---> team0
            ens3-/      (192.168.122.20)

Both of ens2/ens3 in VM1/VM2 are connected to virbr0.

During test, dump target is set as root@192.168.120.100:/var/crash
then crashing in VM1

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-30 15:27:00 +08:00
Lianbo Jiang
e345ed18e2 Add the rd.kdumploglvl option to control log level in the second kernel
Let's add the rd.kdumploglvl option to control log level in the second
kernel, which can make us avoid rebuilding the kdump initramfs after we
change the log level in /etc/sysconfig/kdump.

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-11-13 02:43:49 +08:00
Kairui Song
69bf81bc8b Move watchdog detect and install code to module-setup.sh
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-12 14:03:40 +08:00
Kairui Song
bc639c9763 Add a helper to omit non-mandatory dracut module
Use dracut_args to omit some non-mandatory modules.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-12 14:03:35 +08:00
Kairui Song
08de712528 Move some dracut module dependencies checks to module-setup.sh
depend() in module-setup.sh is a better place to setup dracut module
dependency, it will do early check, and fail early if needed module is
missing. Also remove a unneeded helper add_dracut_module.

Also remove the unnecessary return in depend() function.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-11-12 14:03:19 +08:00
Jonathan Lebon
c9a0df1ccb Make dracut-squash a weak dep
The dracut module is opportunistic about using the built-in squashfs
support only when available, but the spec file hard requires it. Demote
it to a weak dep to truly make it optional.

This caters to environments which strive to stay minimal, like FCOS and
RHCOS. See https://github.com/coreos/fedora-coreos-config/pull/708 for
details.
2020-10-28 16:36:05 -04:00
Kairui Song
46cc7f46b2 module-setup.sh: Instead of drop journalctl log, just don't read kmsg
Previously journalctl logs are directly dropped to save memory, but this
make journalctl unusable in kdump kernel and diffcult to debug. So
instead just don't let it read kmsg but keep other logs stored as volatile.

Kernel message are already stored in the kernel log ring buffer,
no need to let journalctl make a copy, especially when in kdump
kernel, ususlly there won't be too much kernel log overlapping
the old ring buffer.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-10-27 17:34:15 +08:00
Lianbo Jiang
d7054f4cd8 Improve debugging in the kdump kernel
Let's use the logger in the second kernel and collect the kernel ring
buffer(dmesg) of the second kernel.

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-10-27 17:34:07 +08:00
Kairui Song
041ba89902 Don't drop journalctl content if failure action is "shell"
If failure action is set to "shell", user will need more debug info
available in kdump kernel. Especially when serial console is not
available, manually retrieve the log from journalctl is very useful
for debugging kdump issue.

Else, we can still drop journalctl content to save memory assuming
nothing will use it.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-09-17 10:43:07 +08:00
Kairui Song
bcaa4358b1 dracut-module-install: Move systemd conf install code to a function
No feature change.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-09-17 10:43:07 +08:00
Pingfan Liu
bdbddbff73 module-setup.sh: suppress false alarm
Even if the directory "/etc/kdump/pre.d/" is empty, the following false
alarm can be observed during building kdump.initrd:
  "/etc/kdump/pre.d/* is not executable"

Suppress it.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-07-20 16:17:53 +08:00
Kairui Song
a29de38da5 Always wrap up call to dracut get_persistent_dev function
Dracut get_persistent_dev function don't recognize UUID= or LABEL=
format, so caller should conver it to the path to the block device
before calling it. There is already such a helper
"kdump_get_persistent_dev", just move it to kdump-lib.sh and rename
it to reuse it,

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-06-22 19:58:08 +08:00
onitsuka.shinic@fujitsu.com
4246f26725 dracut-module-setup.sh: Install files under /etc/kdump/{pre.d,post.d} into kdump initramfs
This patch installs the binary and script files under /etc/kdump/{pre.d,post.d}
into new initramfs of kdump.

Signed-off-by: Shinichi Onitsuka <onitsuka.shinic@fujitsu.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-06-11 12:58:48 +08:00
Kairui Song
e05c550144 Drop switch root capability for non fadump initramfs
Switch root is never used for kdump image, and this will be helpful to
reduce the initramfs size.

Also increase dracut dependency version and the function is
dracut_no_switch_root is new introduced.

This commit is applied to RHEL some time ago, but missing in Fedora as
Fedora's Dracut didn't backport this feature at that time. Now apply
this missing commit.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-06-10 22:37:34 +08:00
Kairui Song
0cc3b85d0d module-setup.sh: Add "rd.neednet" parameter if network is needed
Upstream dracut now use network-manager module by default and since
upstream commit 3dcaa97, network-manager expects user to pass "rd.neednet"
to indicate network is required.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-05-28 16:26:06 +08:00
Kairui Song
cfd93e2b7e Revert "Add a hook to wait for kdump target in initqueue"
This reverts commit cee618593c.

Upstream dracut have provided a parameter for adding mandantory network
requirement by appending "rd.neednet" parameter, so we should use that
instead.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2020-05-28 16:26:00 +08:00
Lianbo Jiang
ce0305d4f9 Add a new option 'rd.znet_ifname' in order to use it in udev rules
In most cases, it always provides a persistent MAC address. But for
the s390 Arch, sometimes, kernel could run in the LPAR mode and it
doesn't provide a persistent MAC address, which caused the kdump
failure.

Currently, some rules rely on the persistent MAC address, for the
above case, which won't work in kdump kernel because non-persistent
MAC could not match with udev rules.

To fix this issue, need to add a new option 'rd.znet_ifname' in order
to provide extra parameters such as 'ifname' and 'subchannels' for
some rules, which ensures kdump can also work appropriately without
the persistent MAC. Please refer to the following commit in dracut:

872eb69936bd ("95znet: Add a rd.znet_ifname= option")

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-04-27 18:21:22 +08:00
Pingfan Liu
f33f30eb61 dracut-module-setup.sh: fix breakage in get_pcs_fence_kdump_nodes()
pcs cluster and cluster cib-upgrade may throw some information and disturb
the parsing. Mute them

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-04-20 11:24:46 +08:00
Pingfan Liu
6348398743 dracut-module-setup.sh: ensure cluster info is ready before query
There is a race issue between "pcs" and "kdumpctl restart"

-1. set up cluster
 # pcs cluster setup --start mycluster node1 node2
 # pcs stonith create kdump fence_kdump pcmk_reboot_action="off"
 # pcs stonith level add 1 node1 kdump
 # pcs stonith level add 1 node2 kdump

-2. Then here comes the command _immediately_ in kdumpctl
 # pcs cluster cib

But due to some pcs internal mechanism, "pcs cluster cib" can not
fetch the updated info in time.

Fix these issue by forcing the upgrade of cib.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-04-08 15:46:06 +08:00
Kairui Song
3b09c4910d Remove adjust_bind_mount_path call
If user configured target is used, path should be used as the absolute
path within the dump target direct, and user should be fully aware of
the path structure within the target device. The adjust_bind_mount_path
call here make it very hard to control the behavior.

Especially, if it's a cross device bind mount, this will likely create a
invalid path in the target. And for atomic case, adjust_bind_mount_path call
here assumes user will always pass root device as the explicitly configured
dump target, which is not true.

If user configured target device is used, the path is always be the
absolute path inside of given target. If user don't know about the path
structure in the target device, then user should either use the path
based config, or carefully exam the target device before using it as a
dump target.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-30 22:06:46 +08:00
Kairui Song
bde4b7af3b No longer treat atomic/silverblue specially
This commit remove almost all special workaround for atomic, and treat
all bind mounts in any environment equally.

Use a helper get_bind_mount_directory_from_path to get the bind mount
source path of given path.

is_atomic function now only used to determine the right /boot path
for atomic/silverblue environment.

And remove get_mntpoint_from_path(), it's the only function that never
ignore bind mount, and it have no caller after this clean up.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-30 22:06:37 +08:00
Pingfan Liu
3be5f74df0 dracut-module-setup.sh: improve get_alias()
In /etc/hosts, the alias name can come at the 2nd column, regardless of the
recommendation.

E.g. the following format is valid although not recommended
cat /etc/hosts
        127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
        ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
        192.168.22.21	fastvm-rhel-7-6-21	fastvm-rhel-7-6-21.localdomain
        192.168.22.22	fastvm-rhel-7-6-22	fastvm-rhel-7-6-22.localdomain

        192.168.22.21   node1_hb
        192.168.22.22   node2_hb

So filtering out both 2nd and 3rd column for matching.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-03-24 15:36:26 +08:00
Kairui Song
424ac0bf80 Fix a potential syntax error
Process substitution is not POSIX standard syntax, so if bash is configured
to strictly follow POSIC, this will fail.

Just use a POSIX friendly syntax instead.

Fixes: bz1708321

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-23 10:26:20 +08:00
Kairui Song
e78639b46f Use read_strip_comments to filter the installed kdump.conf
This help remove redundant spaces and tailing comment in installed
kdump.conf, currently installed kdump.conf always contain extra empty
lines.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Lianbo Jiang <lijiang@redhat.com>
2020-03-23 10:26:08 +08:00
Kairui Song
c9c50f9a36 dracut-module-setup.sh: Ensure initrd.target.wants dir exists
Latest dracut release stopped creating
$systemdsystemunitdir/initrd.target.wants dir for us, so ensure it
exists before creating the symlink.

Signed-off-by: Kairui Song <kasong@redhat.com>
Tested-and-Reviewed-by: Bhupesh Sharma <bhsharma@redhat.com>
2020-03-18 15:10:59 +08:00
Bhupesh Sharma
a01270b64e kexec-tools/module-setup: Ensure eth devices get IP address for VLAN
Currently while trying to save vmcore via vlan eth interface, the Kdump
kernel fails with network unreachable message.

This is because mkdumprd produces a vlan config that does not get
ip address for vlan on eth device.

Fix the same via this patch.

Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2020-02-13 14:13:59 +08:00
Kairui Song
cee618593c Add a hook to wait for kdump target in initqueue
The dracut initqueue may quit immediately and won't trigger any hook if
there is no "finished" hook still pending (finished hook will be deleted
once it return 0).

This issue start to appear with latest dracut, latest dracut use
network-manager to configure the network,
network-manager module only install "settled" hook, and we didn't
install any other hook. So NFS/SSH dump will fail. iSCSI dump works
because dracut iscsi module will install a "finished" hook to detect if
the iscsi target is up.

So for NFS/SSH we keep initqueue running until the host successfully get
a valid IP address, which means the network is ready.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-01-29 08:12:45 +08:00
Kairui Song
24b00298d0 Always install sed and awk
sed and awk is heavily used everywhere in the code, but it's not
explicitely installed by kdump dracut module. If the module in dracut
stop installing them (which already happened with latest dracut
upstream), kdump will break.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-01-03 16:35:19 +08:00
Kairui Song
bcdcf35759 Fix potential ssh/nfs kdump failure of missing "ip" command
For ssh/nfs dump, kdump need the 'ip' tool to get the host ip address
for naming the vmcore. But kdump-module-setup.sh never installed this
tool. kdump-module-setup.sh worked so far as dracut network module will
help install it.

After dracut changed to use 35network-manager for network setup, "ip"
command won't be installed in second kernel by default. So need to
ensure "ip" is installed when installing kdump dracut module.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-01-03 16:35:15 +08:00
Kairui Song
03111c797b Always use get_save_path to get the 'path' option
This help deduplicate the code. Use a single function instead of
repeat the same logic.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-01-03 16:35:07 +08:00
Kairui Song
5633e83318 Always set vm.zone_reclaim_mode = 3 in kdump kernel
By default kernel have vm.zone_reclaim_mode = 0 and large page
allocation might fail as kernel is very conservative on memory
reclaiming. If the page allocation failure is not handled carefully
it could lead to more serious problems.

This issue can be reproduced by change with following steps:

- Fill up page cache use:
  # dd if=/dev/urandom of=/test bs=1M count=1300

- Now the memory is filled with write cache:
  # free -m
                total        used        free      shared  buff/cache   available
  Mem:           1790         184         132           2        1473        1348
  Swap:          2119           7        2112

- Insert a module which simply calls "kmalloc(SZ_1M, GFP_KERNEL)" for
  512 times: (Notice: vmalloc don't have such problem)
  # insmod debug_module.ko

- Got following allocation failure:
  insmod: page allocation failure: order:8, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0

- Clean up and repeat again with vm.zone_reclaim_mode = 3, OOM is not
  observed.

In kdump kernel there is usually only one online CPU and limited memory,
so we set vm.zone_reclaim_mode = 3 to let kernel reclaim memory more
aggresively to avoid such issue.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2019-11-13 11:35:46 +08:00
Kairui Song
5e76e53a70 module-setup.sh: Simplify the network setup code
Merge kdump_setup_netdev into kdump_install_net.

kdump_install_net is a wrapper of calling kdump_setup_netdev, and
it do following three extra things:

  1. Sanitize and resolve the hostname
  2. Resolve the route to the destination
  3. Set the default gateway for once

There is currently only one caller of kdump_setup_netdev, the iscsi
network setup code, and it's doing 1 and 2 by itself. And there should
only be one default gateway in kdump enviroment, so applying 3 here is
fine.

And the comment of kdump_install_net is wrong and obsoleted, update the
comment too.

Just merge kdump_setup_netdev into kdump_install_net and always use
kdump_install_net instead.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2019-10-24 17:00:02 +08:00
Pingfan Liu
882b920c2f module-setup: re-fix 99kdumpbase network dependency
In commit a431a7e354 (module-setup: fix 99kdumpbase network dependency),
the statement for OR operation is still wrong.

The OR condition statement should be:  if a || b

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2019-10-22 16:09:43 +08:00
Kairui Song
75297d6f20 dracut-module-setup: fix bond ifcfg processing
Bond options in ifcfg is space separated, dracut expected it to be comma
separated, so it have to be parsed and converted during initramfs
building.

The currently parsing and convert pattern is flawed, for example:
" downdelay=0 miimon=100 mode=802.3ad updelay=0 "

is converted to :
":,downdelay=0 miimon=100 mode=802.3ad updelay=0 "

should be:
":downdelay=0,miimon=100,mode=802.3ad,updelay=0"

So fix this issue by using more simple but robust method for processing
the options.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-09-02 17:05:43 +08:00
Pingfan Liu
a5ea190af2 dracut-module-setup: filter out localhost for generic_fence_kdump
The localhost is filtered out in case of is_pcs_fence_kdump, do it too in
case of is_generic_fence_kdump.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2019-08-28 14:19:17 +08:00
Pingfan Liu
f0b5493b2e dracut-module-setup: get localhost alias by manual
'hostname -A' can not get the alias, meanwhile 'hostname -a' is deprecated.
So we should do it by ourselves.

The parsing is based on the format of /etc/hosts, i.e.
  IP_address canonical_hostname [aliases...]

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2019-08-28 14:19:01 +08:00
Kairui Song
4a0f9763c0 Don't forward and drop journalctl logs for fadump
fadump will alter the normal boot initramfs and we don't want a normal
boot to foward and drop the journalctl logs.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-08-06 11:14:15 +08:00
Pingfan Liu
88bbab963f dracut-module-setup.sh: skip alias of localhost in get_pcs_fence_kdump_nodes()
The current code only exclude the hostname, while localhost can have alias in
/etc/hosts. All of the alias should be excluded from the fence dump node to
avoid deadlock issue.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
2019-08-01 13:38:53 +08:00
Kairui Song
cf5d362dca dracut-module-setup.sh: Don't use squash module for fadump
Squash module is used to save memory. For fadump this is not neccessary
and may slow down the build time, and make it more fragile.

fadump initramfs is used for normal boot as well, although squash module
is capable of being used for generic normal boot, but there are cases
where is doesn't work well. So disable it and make fadump more robust.

Signed-off-by: Kairui Song <kasong@redhat.com>
Tested-by: Hari Bathini <hbathini@linux.ibm.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-07-16 16:46:23 +08:00
Kairui Song
5b26c1f8b2 Forward logs in kdump kernel to console directly
Don't use any log storage and forward to console directly, this make
console output more useful, and also save more memory. On a fresh
installed Fedora 30 it saved ~5M of memory, and the amount of log being
printed to console is still accetable.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-07-16 14:11:16 +08:00
Kairui Song
75d9132417 Get rid of duplicated strip_comments when reading config
When reading kdump configs, a single parsing should be enough and this
saves a lot of duplicated striping call which speed up the total load
speed.

Speed up about 2 second when building and 0.1 second for reload in my
tests.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-05-20 16:56:28 +08:00
Kairui Song
4a44eee472 dracut-module-setup: Don't build squashed image if required modules are missing
When someone is using a minimal kernel without squash module installed,
including squash dracut module will either either fail to build or fail to
boot the initramfs.

As kdump always build the image for one single kernel, we can safely just
use modprobe to check if a modules is already built in, or it exists and
loadable for the kernel we are using for kdump image, and don't include
the squash module if they are missing. Everything will still work just
fine without squash module.

We do the check in kdump dracut modules not in squash dracut module
because kdump dracut module could leverage of the KDUMP_KERNELVER variable
to know which kernel it should check against, squash dracut module may be
used to build for a generic image.

And we only check for the kernel module dependency, other binary
dependencies are either well checked or well declared in dracut.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2018-12-26 10:28:12 +08:00
Kairui Song
a0dc92f46c dracut-module-setup: Fix routing failure on multipath route
Currently we still don't support multipath route, when parsing multipath
route kdumpctl will wrongly consider 'nexthop' as the destination address,
and raise errors in second kernel.

When multipath route is in use, ip route output should be like this:
$ /sbin/ip route show
default via 192.168.122.1 dev ens1 proto dhcp metric 100
192.168.122.0/24 dev ens1 proto kernel scope link src 192.168.122.161 metric 100
192.168.122.8
	nexthop via 192.168.122.1 dev ens1 weight 50
	nexthop via 192.168.122.2 dev ens1 weight 5

As we don't care about HA/performance, simply use the rule with highest
weight and ignore the rest.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2018-11-27 18:12:52 +08:00
Kairui Song
9b6e312447 Enable dracut squash module
In dracut-049, a new squash module is introduced, it can reduce the
memory usage of kdump initramfs in the capture kernel, this helps a lot
on lowering the risk of OOM failure.

Tested with latest rawhide with NFS, SSH and local dump.

Signed-off-by: Kairui Song <kasong@redhat.com>
2018-10-15 15:01:31 +08:00
Kairui Song
f6770b30c3 dracut-module-setup: Fix DRM module inclusion test for hyper-v
We test if to include the drm module or not by testing if there are any
drm entry in sysfs. But there is an exception for hyper-v, DRM module
take care of hyperv's framebuffer driver as well but hyperv_fb will
not create any drm entry. So currently we got black screen on
hyperv guest.

Fix by detect hyperv's special entry as well.

Signed-off-by: Kairui Song <kasong@redhat.com>
2018-08-07 17:22:05 +08:00
Kairui Song
4eedcae5e1 dracut-module-setup.sh: don't include multipath-hostonly
This commit basically reverts commit c755499fad,
and make use of new introduced tri-state hostonly mode.

Following dracut commits merged multipath-hostonly into multipath
module, and introduced a tri-state hostonly mode.

    commit 35e86ac117acbfd699f371f163cdda9db0ebc047
    Author: Kairui Song <kasong@redhat.com>
    Date:   Thu Jul 5 16:20:04 2018 +0800

        Merge 90-multipath-hostonly and 90-multipath

    commit a695250ec7db21359689e50733c6581a8d211215
    Author: Kairui Song <kasong@redhat.com>
    Date:   Wed Jul 4 17:21:37 2018 +0800

        Introduce tri-state hostonly mode

multipath-hostonly module was introduced only for kdump, because kdump
need a more strict hostonly policy for multipath device to save memory.

Now multipath module will provide the behave we wanted by setting
hostonly mode to strict.
2018-07-26 19:25:09 +08:00
Pingfan Liu
6832be14f2 dracut-module-setup.sh: pass ip=either6 param for ipv6
Kdump always use _proto=dhcp for both ipv4 and ipv6.  But for ipv6
the dhcp address assignment is not like ipv4, there are different ways
for it, stateless and stateful, see below document:
https://fedoraproject.org/wiki/IPv6Guide

In case stateless, kernel can do the address assignment, dracut use
_proto=auto6;  for stateful case, dracut use _proto=dhcp6.
But it is hard to decide whether stateless or stateful takes effect,
hence, dracut introduces ip=either6 option, which can try both of these
method automatically for us. For detail, refer to dracut:
commit 67354ee 40network: introduce ip=either6 option

We do not see bug reports before because for the most auto6 cases
kernel assign ip address before dhclient, kdump just happened to work.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
2018-07-09 12:43:28 +08:00
Pingfan Liu
92db9cb9f2 dracut-module-setup.sh: install /etc/hosts when using fence_kdump
When using fence_kdump, module-setup will create a kdump.conf with
fence_kdump_nodes. The node name comes from the cluster xml, which may
use the hostname alias. Later in kdump stage, "fence_kdump_send alias_1
alias_2" sends out notification to peers. Hence it requires /etc/hosts
and nsswitch.conf to make alias work.

Signed-off-by: Pingfan Liu <piliu@redhat.com>
2018-07-09 12:43:19 +08:00
Dave Young
2884fed616 Revert "dracut-module-setup.sh: pass correct ip= param for ipv6"
This reverts commit 2f4149f276.

It is not proved to be right to get auto6 or dhcpv6 in 1st kernel,
pingfan is working on a dracut fix to do some fallback in 2nd kernel initramfs.
So revert this commit
2018-05-09 14:21:51 +08:00
Pingfan Liu
2f4149f276 dracut-module-setup.sh: pass correct ip= param for ipv6
Kdump always use _proto=dhcp for both ipv4 and ipv6.  But for ipv6
the dhcp address assignment is not like ipv4, there are different ways
for it, stateless and stateful, see below document:
https://fedoraproject.org/wiki/IPv6Guide

In case stateless, kernel can do the address assignment, dracut use
_proto=auto6;  for stateful case, dracut use _proto=dhcp6.

We do not see bug reports before because for the most auto6 cases
kernel assign ip address before dhclient, kdump just happened to work.

Here we use auto6 if possible first. And we take the assumption that
host use auto6 if /proc/sys/net/ipv6/conf/$netdev/autoconf is enabled

Signed-off-by: Pingfan Liu <piliu@redhat.com>
2018-03-15 10:06:51 +08:00
Pingfan Liu
c755499fad dracut-module-setup.sh: check whether to include multipath-hostonly or not
Due to the following commit in dracut, which splits out hostonly modules
commit 5ce7cc7337a4c769b223152c083914f2052aa348
Author: Harald Hoyer <harald@redhat.com>
Date:   Mon Jul 10 13:28:40 2017 +0200

    add 90multipath-hostonly module

    hardcoding the wwid of the drives in the initramfs causes problems
    when the drives are cloned to a system with the same hardware, but
    different disk wwid's

    https://bugzilla.redhat.com/show_bug.cgi?id=1457311

So kdump should decide whether to include the hostonly module.
The multipath-hostonly can help kdump to include only the needed mpath device,
in order to use less memory by 2nd kernel.

---- The performance -----
before this patch
[root@localhost ~]# time kdumpctl start
Detected change(s) in the following file(s):

  /etc/kdump.conf
Rebuilding /boot/initramfs-4.13.9-300.fc27.x86_64kdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]

real    0m12.485s
user    0m10.096s
sys     0m1.887s

after this patch

root@localhost ~]# time kdumpctl start
Detected change(s) in the following file(s):

  /etc/kdump.conf
Rebuilding /boot/initramfs-4.13.9-300.fc27.x86_64kdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]

real    0m15.839s
user    0m13.015s
sys     0m1.853s

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-11-24 13:58:28 +08:00
Ziyue Yang
c05c898062 dracut-module-setup.sh: eliminate redundant kdump_get_mac_addr call
This commit eliminates a redundant kdump_get_mac_addr call in
kdump_setup_netdev.

Signed-off-by: Ziyue Yang <ziyang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-09-06 15:42:40 +08:00
Xunlei Pang
3172bc0ef3 module-setup: remove software iscsi cmdline generated by dracut
After adding "--hostonly-cmdline", besides 99kdump, 95iscsi
also generates iscsi related cmdline. IOW, we have duplicate
software iscsi cmdlines.

95iscsi generated software iscsi cmdline doesn't work, so we
remove that of 95iscsi and use that of 99kdump which has been
well tested.

We can change to use 95iscsi when possible in the future.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-09-06 15:41:48 +08:00
Xunlei Pang
38e6b41c0c module-setup: suppress the early iscsi error messages
Currently, we throw the error message at the very beginning, as
a result on a pure-hardware(all-offload) iscsi machine with many
iscsi partitions, we suffered from too much noise as follows:
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.1/host0/session1
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.3/host1/session2
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.1/host0/session1
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.3/host1/session2
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.1/host0/session1
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.3/host1/session2
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.1/host0/session1
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.3/host1/session2
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.1/host0/session1
  iscsiadm: No records found
  Unable to find iscsi record for
  /sys/devices/pci0000:00/0000:00:06.0/0000:07:00.0/0000:08:01.3/host1/session2
  kexec: loaded kdump kernel
  Starting kdump: [OK]

There's no need to know the very early error messages, we can
remove the error output which is actually normal for the pure
hardware iscsi.

As for unexpected errors, we kept the error outputs in the
succeeding kdump_iscsi_get_rec_val() calls by not appending
"2>/dev/null".

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-08-08 10:10:19 +08:00
Xunlei Pang
2777a93a9c mkdumprd: use 300s as the default systemd unit timeout for kdump mount
Currently, systemd uses 90s as the default mount unit timeout
(see "man 5 systemd-system.conf " for "DefaultTimeoutStartSec"),
in some cases, although it works well in 1st kernel, it's not
enough under kdump and results in mount timeout, further results
in kdump dumping failure.

We've met several such issues, we decided to enlarge this default
value a little for kdump.

We know that dracut has a default initqueue timeout value of 180s
("rd.retry"), we finalized a little larger value 300s as kdump's
default timeout if there is no explicit "DefaultTimeoutStartSec=X,
specified by users.

"DefaultTimeoutStartSec=X" can be overridden by individual mount
option "x-systemd.device-timeout=X", users can specify their own
values as needed.

This patch achieves the purpose by creating a dedicated conf file
"/etc/systemd/system.conf.d/kdump.conf" which has the content of
"DefaultTimeoutStartSec=300s", this is based on the fact that all
the conf files will be parsed by systemd and the last parsed one
will be used if there are duplicate definitions.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-08-08 10:10:03 +08:00
Xunlei Pang
a431a7e354 module-setup: fix 99kdumpbase network dependency
I noticed that network is still enabled for local dumping,
like the following kdump boot message on my test machine
using local disk as the dump target:
  tg3.c:v3.137 (May 11, 2014)
  tg3 0000:02:00.0 eth2: Tigon3 [partno(BCM95720) rev
  (PCI Express) MAC address c8:1f:66:c9:35:0d
  tg3 0000:02:00.0 eth2: attached PHY is 5720C

After some debugging, found it due to a misuse in code below:
  if [ is_generic_fence_kdump -o is_pcs_fence_kdump ]; then
      _dep="$_dep network"
  fi
The "if" condition always results in "true", and should be
changed as follows:
  if is_generic_fence_kdump -o is_pcs_fence_kdump; then
      _dep="$_dep network"
  fi

After this, network won't be involved in non-network dumping,
as for dumpings require network such as nfs/ssh/iscsi/fcoe/etc,
dracut will add network accordingly. And kdump initramfs size
can be reduced from 24MB to 17MB tested on some real hardware,
and from 19MB to 14MB on my kvm. Moreover, it could avoid the
network (driver) initialization thereby saving us more memory.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-14 14:54:59 +08:00
Benjamin Berg
f6303a2a93 dracut-module-setup: Fix test for inclusion of DRM modules
The /sys/modules/*/drivers sysfs entries do not exist anymore on newer
kernels which means that the DRM moduels would never be included.
Instead check if there is any device with a "drm" sysfs directory to
decide on whether DRM modules need to be included.

Acked-by: Dave Young <dyoung@redhat.com>
2017-06-15 09:40:03 +08:00
Xunlei Pang
b40c1f96cf kdumpctl: remove "root=X" for kdump boot
Since the current dracut of Fedora already supports not always
mounting root device, we can remove "root=X" from the command
line directly, and always get the dump target specified in
"/etc/kdump.conf" and mount it. If the dump target is located
at root filesystem, we will add the root mount info explicitly
from kdump side instead of from dracut side.

For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
kdump will not mount the unnecessary root fs after this change.

This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
(if "default dump_to_rootfs" is specified, don't remove "root=X"),
and mounts non-root target under "/kdumproot", the root target
still under "/sysroot"(to be align with systemd sysroot.mount).

After removing "root=X", we now add root fs mount information
explicitly from the kdump side.

Changed check_dump_fs_modified() a little to avoid rebuild when
dump target is root, since we add root fs mount explicitly now.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
2017-04-11 16:02:12 +08:00
Xunlei Pang
5c87d73cf3 kdump-emergency: fix "Transaction is destructive" emergency failure
We met a problem that the kdump emergency service failed to
start when the target dump timeout(we passed "rd.timeout=30"
to kdump), it reported "Transaction is destructive" messages:

  [ TIME ] Timed out waiting for device dev-mapper-fedora\x2droot.device.
  [DEPEND] Dependency failed for Initrd Root Device.
  [ SKIP ] Ordering cycle found, skipping System Initialization
  [DEPEND] Dependency failed for /sysroot.
  [DEPEND] Dependency failed for Initrd Root File System.
  [DEPEND] Dependency failed for Reload Configuration from the Real Root.
  [ SKIP ] Ordering cycle found, skipping System Initialization
  [ SKIP ] Ordering cycle found, skipping Initrd Default Target
  [DEPEND] Dependency failed for File System Check on /dev/mapper/fedora-root.
  [  OK  ] Reached target Initrd File Systems.
  [  OK  ] Stopped dracut pre-udev hook.
  [  OK  ] Stopped dracut cmdline hook.
           Starting Setup Virtual Console...
           Starting Kdump Emergency...
  [  OK  ] Reached target Initrd Default Target.
  [  OK  ] Stopped dracut initqueue hook.
  Failed to start kdump-error-handler.service: Transaction is destructive.
  See system logs and 'systemctl status kdump-error-handler.service' for details.
  [FAILED] Failed to start Kdump Emergency.
  See 'systemctl status emergency.service' for details.
  [DEPEND] Dependency failed for Emergency Mode.

This is because in case of root failure, initrd-root-fs.target
will trigger systemd emergency target which requires the systemd
emergency service actually is kdump-emergency.service, then our
kdump-emergency.service starts kdump-error-handler.service with
"systemctl isolate"(see 99kdumpbase/kdump-emergency.service, we
replace systemd's with this one under kdump).

This will lead to systemd two contradictable jobs queued as an
atomic transaction:
job 1) the emergency service gets started by initrd-root-fs.target
job 2) the emergency service gets stopped due to "systemctl isolate"
thereby throwing "Transaction is destructive".

In order to solve it, we can utilize "IgnoreOnIsolate=yes" for both
kdump-emergency.service and kdump-emergency.target. Unit with attribute
"IgnoreOnIsolate=yes" won't be stopped when isolating another unit,
they can keep going as expected in case be triggered by any failure.

We add kdump-emergency.target dedicated to kdump the similar way
as did for kdump-emergency.service(i.e. will replace systemd's
emergency.target with kdump-emergency.target under kdump), and
adds "IgnoreOnIsolate=yes" into both of them.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
[bhe: improve the patch log about IgnoreOnIsolate="]
2017-03-31 11:54:30 +08:00
Xunlei Pang
ae45e6f1bb mkdumprd: reduce lvm2 memory under kdump
We replace "reserved_memory = XXXX"(default value is 8192) with
"reserved_memory = 1024" in /etc/lvm/lvm.conf used by "lvm2", it
can save 7MB peak memory consumption, so lower the possibility of
OOM under kdump.

For kdump, we don't have too many lvm targets, lvm2 locates in the
RAM(rootfs), so don't need that much memory, as discussed with lvm
people, they agreed that we use 1MB under kdump as long as there
are not that many lvm targets invloved.

We modify /etc/lvm/lvm.conf when "99kdumpbase" install() is executed,
because it is parsed after "90lvm" by dracut.

We add the code unconditionally with &>/dev/null to ignore errors, it
doesn't matter in case of "lvm" not included(i.e. there is no lvm.conf).

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-03-31 11:53:57 +08:00
Dave Young
e2de6e1e9a rename function kdump_to_udev_name
kdump_to_udev_name function name cause confusion to people, change it to
kdump_get_persistent_dev which sounds better.

Signed-off-by: Dave Young <dyoung@redhat.com>
Reviewed-by: Xunlei Pang <xlpang@redhat.com>
2016-11-28 10:41:22 +08:00
Dave Young
3742e9d0c3 Raw dump: use by-id as persistent policy in 2nd kernel
Although we use by-id in mkdumprd as persistent policy for the dump target
checking, finally it is not used in kdump 2nd kernel because we call dracut
function in module-setup.sh without persistent policy specified that means
kdump will copy default "by-uuid" dev name.

Though by-uuid usually works and it is still better to fix it as raw disk
uuid make no sense.

Also do not need to call bind mount adjust function for raw dump, here add
another switch case for raw dump and cleanup the functions with short
variable names to keep code shorter.

Signed-off-by: Dave Young <dyoung@redhat.com>
Reviewed-by: Xunlei Pang <xlpang@redhat.com>
2016-11-28 10:41:22 +08:00
Hari Bathini
78e985e51c kdump/fadump: fix network interface name when switching from fadump to kdump
When a remote dump target is specified, kdump dracut module prefixes
'kdump-' to network interface name (ifname) as kernel assigned names
are not persistent. In fadump mode, kdump dracut module is added to
the default initrd, which adds the 'kdump-' prefix to the ifname of
the prodcution kernel itself. If fadump mode is disabled after this,
kdump dracut module picks the ifname that is already prefixed with
'kdump-' in the production kernel and adds another 'kdump-' to it,
making the ifname something like kdump-kdump-eth0 for kdump kernel.
Eventually, kdump kernel fails with below traces:

  dracut-initqueue[246]: RTNETLINK answers: Network is unreachable
  dracut-initqueue[246]: arping: Device kdump-kdump-eth0 not available.

The ip command shows the below:

  kdump:/# ip addr show kdump-kdump-eth0
  2: kdump-kdump-eth: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 \
  qdisc pfifo_fast state UNKNOWN qlen 1000
      link/ether 22:82:87:7b:98:02 brd ff:ff:ff:ff:ff:ff
      inet6 2002:903:15f:550:2082:87ff:fe7b:9802/64 scope global \
      mngtmpaddr dynamic
         valid_lft 2591890sec preferred_lft 604690sec
      inet6 fe80::2082:87ff:fe7b:9802/64 scope link
         valid_lft forever preferred_lft forever
  kdump:/#

The trailing 0 from kdump-kdump-eth0 is missing in the ifname, probably
truncated owing to ifname length limit, while setting.

This patch fixes this by avoiding addition of the prefix 'kdump-' when
such prefix is already present in the ifname.

Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Acked-by: Dave Young <dyoung@redhat.com>
2016-11-11 11:00:22 +08:00
Xunlei Pang
74c6f46429 Support special mount information via "dracut_args"
There are some complaints about nfs kdump that users must mount
nfs beforehand, which may cause some overhead to nfs server.
For example, there're thounsands of diskless clients deployed with
nfs dumping, each time the client is boot up, it will trigger
kdump rebuilding so will mount nfs, thus resulting in thousands
of nfs request concurrently imposed on the same nfs server.

We introduce a new way of specifying mount information via the
already-existent "dracut_args" directive(so avoid adding extra
directives in /etc/kdump.conf), we will skip all the filesystem
mounting and checking stuff for it. So it can be used in the
above-mentioned nfs scenario to avoid severe nfs server overhead.

Specifically, if there is any "--mount" information specified via
"dracut_args" in /etc/kdump.conf, always use it as the final mount
without any validation(mounting or checking like mount options,
fs size, etc), so users are expected to ensure its correctness.

NOTE:
-Only one mount target is allowed using "dracut_args" globally.
-Dracut will create <mountpoint> if it doesn't exist in kdump kernel,
 <mountpoint> must be specified as an absolute path.
-Users should do a test first and ensure it works because kdump does
 not prepare the mount or check all the validity.

Reviewed-by: Pratyush Anand <panand@redhat.com>
Suggested-by: Dave Young <dyoung@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
2016-08-26 14:03:48 +08:00
Pratyush Anand
344faf1a26 watchdog: do not add watchdog module in rd.driver.pre now
Now dracut takes care to add module for active watchdog.  Therefore we do
not need to pass iTCO_wdt  and lpc_ich module in rd.driver.pre specifically
here.

Signed-off-by: Pratyush Anand <panand@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2016-07-21 13:56:20 +08:00
Baoquan He
510084134f module-setup: Don't handle iBFT in kdump
There are several kinds of iSCSI mode rhel support currently.
 - Pure hardware iSCSI
 - iBFT iSCSI
 - Pure software iSCSI

Except for the 1st one that firmware takes care of everything to
make it behave like a local disk, both iBFT and pure software iSCSI
mode need pass information to kdump kernel for configuring them
correctly.

Currently kdump takes iBFT mode as a software iSCSI and collects
the related information to set up software iSCSI in 2nd kernel,
though dracut can detect and collect information to set up iBFT
iSCSI of 2nd kernel. This brings up 2 problems:

1) Redundent information about the related iSCSI is collected. One
is done by kdump, the other is from dracut.

2) These 2 sessions of 2nd kernel for a certain session of 1st kernel
could contain two "ip=xxx" cmdline option. This will cause cmdline
handling error in dracut.

The 1st one is not critical while the 2nd is. In order to avoid above
2 problems, kdump need detect iBFT mode iSCSI and leave it to dracut.
This is what is done in this patch.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2016-07-13 11:20:01 +08:00
Xunlei Pang
9f8fb447c1 module-setup: Use get_ifcfg_filename() to get the proper ifcfg file
The ifcfg file name of <netif> under "/etc/sysconfig/network-scripts/"
may not be "ifcfg-<netif>". For example, for "enp0s25" we are able to
generate its ifcfg like "/etc/sysconfig/network-scripts/ifcfg-enp0s25test"
via network-manager. If we alway assume "ifcfg-<netif>" is there, we will
got the wrong result in some cases.

The issue can be resolved by using the new get_ifcfg_filename() introduced
by PATCH "kdump-lib: Add get_ifcfg_filename() to get the proper ifcfg file",
so we hereby change all the "ifcfg-<netif>" users to use get_ifcfg_filename().

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2016-06-06 13:04:05 +08:00
Minfei Huang
7f44d3ee37 Remove duplicate prefix path ${initdir}
dracut will place the config in the random path during generating the
initramfs. Remove the duplicate prefix path ${initdir}.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-10-19 10:36:37 +08:00
Minfei Huang
b57fd97ba5 module-setup: Choose the first matched gateway in kdump_static_ip
The system may have multiple default route entry. Following is an
example to show the details.

 # ip -6 route list dev eth0
2620:52:0:1040::/64  proto kernel  metric 256  expires 2591978sec fe80::/64  proto kernel  metric 256
default via fe80:52:0:1040::1  proto ra  metric 1024  expires 1778sec hoplimit 64
default via fe80:52:0:1040::2  proto ra  metric 1024  expires 1778sec hoplimit 64

Choose the first matched entry.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2015-08-13 15:51:30 +08:00
Minfei Huang
e8e5a6a2d1 module-setup: Add permanent option to detect static ip address or not
Dracut will die in the situation that dracut detects to use dhcp to
setup ip address, but kdump passes the ip address to it.

In commit 7ea50dc7a3, we start to use
option permanent to get the ip address in kdump_static_ip. If the
network is setuped by static, we will get the ip address, otherwise
getting none.

In commit c994a80698 which it used to
support ipv6 protocol, I miss the option permanent.

This patch is not a fixing patch, just pulls back something to make
kdump work as original.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-08-13 15:49:53 +08:00
Minfei Huang
ea13e7ab98 dracut-module-setup: Enhance ISCSI to support ipv6 protocol
Due to the different format between ipv4 and ipv6 protocol, quote the
ipv6 address with bracket "[]" to make dracut notify.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-07-28 12:42:17 +08:00
Minfei Huang
2ba32c6ccf dracut-module-setup: Prefer ipv4 address as the hostname address
Kdump will parse the hostname to get the ip address, if hostname is
specfied in /etc/kdump.conf. We will get the ip address(ipv4 or ipv6,
according to the DNS server) by using "getent hosts".

For now, it is more reasonable that we shall get all of the ip
address(including ipv4 and ipv6 address) which point to the hostname by
using "getent ahosts". And we will prefer to use the ipv4 address, if
both ipv4 and ipv6 address work.

The reason why we choose the ipv4 as preferred address is to solve the
issue kdump will fail to connect the hostname machine(parsed as ipv6
address), due to the DNS server is ipv4 address in 2nd kernel.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-07-28 12:42:17 +08:00
Minfei Huang
c994a80698 dracut-module-setup: Support the network for ipv6 protocol
Previously, Kdump will save route to setup the network route in the 2nd
kernel for ipv4 protocol. To support ipv6 protocol, make Kdump fetch
correct nexthop, since the ruturning format is different.

In order to enhance kdump to support ipv6, support the static ip for
ipv6 protocol, which ipv4 has supported already.

Introduce a new lib function get_remote_host which is used to factor out
the ip address(ipv4 or ipv6) and hostname in /etc/kdump.conf.

Introduce a new lib function is_ipv6_address which is used to make sure
whether the passed ip address is ipv4 or ipv6.

Introduce a new lib function is_hostname which is used to confirm
whether the passed parameter is hostname, not the ip address.

Introduce a new function get_ip_route_field which is used to factor out
the specified string in ip route info.

Due to the different format between ipv4 and ipv6 protocol, quote the
ipv6 address with bracket "[]" to make dracut notify.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-07-28 12:42:17 +08:00
Minfei Huang
edec8a8266 dracut-kdump: Use the first filtered ip address as dump directory
For now, Kdump will use ipv4 address as dump directory, and it works, if
ipv4 is enabled.

Once Kdump start to support ipv6 protocol, we may only setup the ipv6
address exclusively. Modify the code to make Kdump work in either ipv4
and ipv6 protocol.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-07-28 12:42:17 +08:00
Minfei Huang
51cfe4f81c dracut-module-setup: Apply the manual DNS to the 2nd kernel
Now Kdump will ingore the DNS config in /etc/resolv.conf, when it
generates the initram. And most users do not concern about this issue,
because they never use deployment tools to configure machines
environment, like puppet.

It is more convenient to add the DNS config to /etc/resolv.conf for
people who use deployment tools to configure machines concurrently.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2015-07-28 12:41:45 +08:00
Dave Young
a75b17ef91 watchdog: load iTCO_wdt early in cmdline hook
We have added *wdt in kdump initramfs, but to improve it more we can do below
(1) load wdt drivers as early as possible so that we can save time before wdt timeout
    some drivers like iTCO_wdt can stop the watchdog while driver initialization, so
    it can give more chance for kdump.
    It can save time especially in case some drivers take long time to init, like
    some storage and networking cards.
(2) add only used wdt drivers in kdump initrd instead of add *wdt
    wdt driver layer need a change so that we can get the proper driver name from
    /dev/watchdog. Question to this is are we sure 1st kernel use /dev/watchdog
    instead of /dev/watchdog1? It need more investigation.
(3) in case a driver can not stop (nowayout?) during module_init, we need load it
    as early as possible and kick the watchdog. Likely we can use systemd default
    watchdog functionality.

This patch is about to address (1), and specially for iTCO_wdt, we only tested
iTCO_wdt, thus in this patch only add this driver, need investigate on other drivers
later to see if other drivers works in this way.

Signed-off-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Minfei Huang <mhuang@redhat.com>
2015-07-28 12:35:54 +08:00
Dave Young
70a4c96523 Revert "save exact route to remote target"
This reverts commit a68bb200f8.

Conflicts:
	dracut-module-setup.sh

Manually remove get_route function
2015-07-13 17:17:32 +08:00
Dave Young
6b7df5b0b3 Revert "module-setup: Use proper ethernet device name in 2nd kernel"
This reverts commit 08809fb0c7.
2015-07-13 17:15:46 +08:00
Dave Young
977d20cd50 Revert commit 63476302
The ipv6 patchset is still under review, previously the commit was mistakenly
merged, thus let's revert it.

Revert "dracut-kdump: Use proper the known hosts entry in the file known_hosts"

This reverts commit 63476302aa.

Conflicts:
	kdump-lib.sh

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Signed-off-by: Dave Young <dyoung@redhat.com>
2015-06-26 10:14:14 +08:00
Minfei Huang
25afa6ee5f dracut-module-setup: Enhance kdump to support the bind mounted feature in Atomic
Kdump will dump the vmcore in incorrect target directory, if the target
is bind mounted.

As commented in the previous patch, we can construct the real path in
Atomic, which contains two part, one bind mounted path, the other
specified dump path. Then replace the path as the real path in
/etc/kdump.conf.

findmnt can find the real path for nfs, although the path is in bind
mode. So nfs can work well with the path in bind mode.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2015-04-21 10:58:30 +08:00
Minfei Huang
fedeba5e4b Remove duplicate slash in save path
Now kdump cannt parse the path correctly, if the path contains
duplicated "/". Following is an example to explain it detail. (the
directory /mnt is a mount point which is mounted a block device)

path //mnt/var/crash

Then the warning will raise.

Force rebuild /boot/initramfs-3.19.1kdump.img
Rebuilding /boot/initramfs-3.19.1kdump.img
df: ‘/mnt///mnt/var/crash’: No such file or directory
/sbin/mkdumprd: line 239: [: -lt: unary operator expected
kexec: loaded kdump kernel
Starting kdump: [OK]

For above case, kdump fails to check the fs size, due to the incorrect
path.

In kdump code flow, we will cut out the mount point(/mnt) from the
path(//mnt/var/crash). But the mount point cannt match the path, because
of the duplicated "/".

To fix it, we will strip the duplicated "/" firstly.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2015-04-21 10:56:03 +08:00
Baoquan He
374d8b628b dracut-module-setup.sh: change the insecure use of /tmp/*$$* filenames
Harald warned it's dangerous to use /tmp/*$$* in shell scripts of dracut
modules.

Quote his saying as below:
***************************
This can be exploited so easily and used to overwrite e.g. /etc/shadow.
The only thing you have to do is waiting until the next time the kdump
initramfs is generated on a kernel update.

If at all, please use "$initdir/tmp/" because $initdir is a mktemp generated
directory with a non-guessable name!
**************************

So make a clean up in this patch.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-02-25 16:52:14 +08:00
Baoquan He
1a8a39aa9c adding the parsed path to etc/kdump.conf of kdump initrd
Steve found a bug. When mount a disk in /var and not specify path
in /etc/kdump.conf, the vmcore will be dumped into /var/crash of
that disk, but not /crash on that disk.

This is because when write the parsed path into /tmp/$$-kdump.conf
in default_dump_target_install_conf() of mkdumprd, it uses below
sed command. So if no path specified at all, this sed command won't
add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default
path, namely "/var/crash" as path if no path in /etc/kdump.conf in
2nd kernel.

    sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf

According to Dave Young's suggestion, erase the old path line and then
insert the parsed path. This can fix it.

v2->v3:
    erase the old path line and then insert the parsed path.

    sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf
    echo "path $_path" >> /tmp/$$-kdump.conf

v3->v4:
    Change the sed pattern, erase lines starting with "path" and then
    insert the parsed path.

    sed -i -e "s#^path.*##" /tmp/$$-kdump.conf
    echo "path $_path" >> /tmp/$$-kdump.conf

v4->v5:
    Chaowang suggested using sed command d to remove the whole line
    like below:
    sed -i "/^path/d" /tmp/$$-kdump.conf
    echo "path $_path" >> /tmp/$$-kdump.conf

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-01-13 13:16:25 +08:00
Baoquan He
1c9362c10d dracut-module-setup.sh: make some clean up
Chao pointed out that it's better to use get_option_value to get
get a specific config_val.

And also there's a potential risk when use below sed command to
do the replacement.

sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf

Say user configure kdump.conf like the following. Then sed may
replace "/var/crash/post.sh" with something else, depanding on
mount point.

kdump_post /var/crash/post.sh
path /var/crash

So in this patch clean them up.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2015-01-13 13:16:13 +08:00
Hari Bathini
80238ade18 kdump: remove sysctl.conf & sysctl.d/* files for kdump kernel
Certain kernel parameters like min_free_kbytes can be configured at runtime
using sysctl. While this is useful in first kernel, it can lead to unnecessary
failures like OOM in kdump kernel. This patch enforces default vaules for all
sysctl parameters, in kdump kernel, by removing sysctl.conf & sysctl.d/* files.

Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
2014-12-12 11:23:14 +08:00
Minfei Huang
63476302aa dracut-kdump: Use proper the known hosts entry in the file known_hosts
Once login using ssh, the ssh will store the known hosts entry to the
local ~/.ssh/known_hosts. From now, we can login using ssh automaticly.

The ssh will check the ~/ssh/.known_hosts entry, if set the option
StrictHostKeyChecking=yes/ask in the config or command line, when you
want to login the target. the default value of StrictHostKeyChecking is
ask.
And the kdump using the ssh will append the option
StrictHostKeyChecking=yes in the command line.

We can using following ip to connect peer machine, if enable the ipv6.
fe80::5054:ff:fe48:ca80%eth0

Obviously, above ip contains the ethX.

Kdump will add the prefix "kdump-" before ethX to avoid flowing
netdevice name in case netdevice names ethX in the 2nd kernel. So the
ip address will change to fe80::5054:ff:fe48:ca80%kdump-eth0.

Kdump will login the target manully in the 2nd kernel, because of the
option StrictHostKeyChecking=yes and inexistence known hosts entry
in the local ~/.ssh/known_hosts. Hence dumping core will fail.

In order to login automaticly using ssh, we should add the prefix
"kdump-" before ethX in the local ~/.ssh/known_hosts.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
2014-12-11 14:19:49 +08:00
Minfei Huang
08809fb0c7 module-setup: Use proper ethernet device name in 2nd kernel
For ethX, it may fail to setup the network in the 2nd kernel due to the
mapping of ethernet device name and MAC changes.

The commit(ba7660f37e) has fixed this
issue by add the prefix "kdump-" before ethX. But the network will fail
to work in the static route mode because of this commit.

Here is the config which is used to setup the static route:
rd.route=192.168.201.215:192.168.200.137:eth1

Obviously, the static route config comtains the ethX. But the network
device names kdump-ethX in the 2nd kernel, so the static route config
will fail to execute. To fix it, we should identify the network device.

Add the prefix "kdump-" before the ethX in the static route config to
setup it successfully in the 2nd kernel.

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2014-12-11 13:58:32 +08:00
Minfei Huang
d94c354e81 module-setup: Do not show the noisy in the terminal
It is boring that internal result is shown in the terminal. Do not print
anything to standard output by using the command "grep -q".

Signed-off-by: Minfei Huang <mhuang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
2014-12-11 13:56:26 +08:00
Baoquan He
a68bb200f8 save exact route to remote target
Previously for solving static route issues, all routes which go
through a specific dev will be saved in 1st kernel, and then added
in 2nd kernel. Because we use below search pattern, an exception
will happen:
/sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev"

That exception is a corner case which happened when 2 machines connected
directly by cable and the 2 network interfaces are configured in
different network subnets. E.g there are 2 machines A and B:

A:ens10 < ------ > B:ens9

A:ens10  inet 192.168.100.111/24 scope global ens10
route need be added in A:
192.168.110.0/24 dev ens10

B:ens9   inet 192.168.110.222/24 scope global ens9
route need be added in B
192.168.100.0/24 dev ens9

Now if A want to dump to B, the route "192.168.110.0/24 dev ens10"
has to be saved and added in 2nd kernel.

So in this patch "ip route get to $target" command is executed, then
an exact route can be got for going to that target. By this, static
route works and the corner case can be fixed too.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Marc Milgram <mmilgram@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
2014-10-28 10:56:57 +08:00
WANG Chao
013bb485b8 module-setup: do not add duplicate ip=xxx
In case of iscsi boot, kernel cmdline will contain ip=xxx kernel
parameter for dracut setting up iscsi root in initramfs. For example:

"root=xxx ip=192.168.3.26:::255.255.255.0:localhost.localdomain:eno19:none ..."

dracut doesn't allow duplicate ip conf for the same network card. dracut
will not ignore the either of the duplicate. Instead, it refuses to
continue:

[   15.876306] dracut: FATAL: For argument 'ip=192.168.3.26:::255.255.255.0:localhost.localdomain:eno19:none'\n
Duplication configurations for 'eno19'
[   16.055513] dracut: Refusing to continue ev argument for multiple ip= lines

That's why in our code we don't add a duplicate ip conf when handling
the same network card the second time. But we never consider the case
that ip conf is already added in kernel cmdline for some special
purpose, for example, iscsi boot.

Now we also look up /proc/cmdline for ip conf. If it exists, we use the
existing one. The existing one should work out of box because dracut
will handle it in second kernel like it does for first kernel. That
said, the network card will be brought up and root disk will be mounted
under /sysroot.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-09-25 10:06:02 +08:00
WANG Chao
082043e117 dracut-module-setup: allow short hostname in cluster configuration
Node could be referenced by short hostname (hostname -s) in cluster
configuration:

[root@virt-068 /]# pcs status nodes
Pacemaker Nodes:
 Online: virt-066 virt-067 virt-068
 Standby:
 Offline:

We didn't know it before. Martin noticed the kdump failure, and provide
this fix. Thanks to Martin.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Tested-by: Martin Juricek <mjuricek@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-08-12 13:16:08 +08:00
Baoquan He
f7f8361af9 Add static route into cmdline if target address is not local
If one target address is not local and its route is different than
default gateway, the specific route to this target address need be
added. E.g, target is 192.168.200.222.

sh> ip route show
default via 192.168.122.1 dev eth0  proto static  metric 1024
192.168.200.0/24 via 192.168.100.222 dev ens10  proto static  metric 1

In this patch, get the route to the specific target address and store
it as cmdline, here is /etc/cmdline.d/45-route-static.conf. And the
route options are separated by semicolon like below. Then the stored
route can be parsed when kdump kernel boot up.

192.168.200.0/24:192.168.100.222:ens10

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-08-05 14:05:53 +08:00