Commit Graph

25 Commits

Author SHA1 Message Date
Pratyush Anand
81f2c9ea6f get_persistent_dev(): fix name contention with dracut's similar function
Resolves: BZ1348898

dracut-functions.sh defines a get_persistent_dev(). Earlier, we had another
local get_persistent_dev() in mkdumprd, however that was moved to
kdump-lib.sh, so that it can be reused in kdumpctl.

Since, dracut-module-setup.sh (which is dracut's
99kdumpbase/module-setup.sh) sources kdump-lib.sh. Therefore, once dracut
will execute 99kdumpbase module, it's own get_persistent_dev() function is
overwritten by kdump's version. If any other dracut module calls
get_persistent_dev() thereafter then, kdump's version is executed, which was
not expected.

Therefore rename kdump's get_persistent_dev() as kdump_get_persistent_dev()
to avoid any name contention.

Signed-off-by: Pratyush Anand <panand@redhat.com>
Acked-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2016-06-28 03:28:47 +08:00
Xunlei Pang
65b0f80a5c kdump-lib: Add get_ifcfg_filename() to get the proper ifcfg file
Previously, we assumed the ifcfg file of a network "interface" is
"/etc/sysconfig/network-scripts/ifcfg-<interface>", but actually
it is not the case.

For example, for network interface "enp0s25", we are able to
generate like "/etc/sysconfig/network-scripts/ifcfg-enp0s25-test"
for it via network-manager.

The "suffix" in "ifcfg-<suffix>" is actually a "configuration"
name not "interface" name, though normally we use the "interface"
name as its "configuration" name. You can refer to "man ifup"
for some detail.

So, this patch adds some assistant helpers to acquire the right
ifcfg file for an interface. Borrow some logic from script below:
"/etc/sysconfig/network-scripts/network-functions"

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2016-06-06 13:03:18 +08:00
Pratyush Anand
d1424f3f66 mkdumprd: move to_dev_name() & get_persistent_dev() to kdump-lib.sh
to_dev_name() and get_persistent_dev() can be used by function in kdumpctl.
Therefore moving them to kdump-lib.sh.

No functional changes.

Signed-off-by: Pratyush Anand <panand@redhat.com>
Acked-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Baoquan He <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2016-05-12 09:53:51 +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
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
7acaa304f6 Fix the warning if the target path is bind mount in Atomic
kdump will raise the warning in Atomic, if the path is bind mounted
directory. The reason why causes this issue is kdump cannt parse the
bind mounted directory.

To correct dumping target, we can construct the real dumping path in
Atomic, which contains two part, one bind mounted path, the other
specified dump target.

Following is an example:
    -bash-4.2# cat /etc/kdump.conf | grep ^path
    path /var/crash

    -bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}'
    /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var]

    -bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}'
    /dev/mapper/atomicos-root

Then we can found it that the real path of dumping vmcore is
/ostree/deploy/rhel-atomic-host/var/crash.

To fix this issue, we can replace the target path as the real path which
is from above parsing.

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:00 +08:00
Minfei Huang
c82a453c67 Get the mount point correctly, if the device has several mount point
Any block device can be mounted multiply on the different mount point.
Once a mount point is mounted in bind mode, the general mount point can
be unmounted. Thus kdump would not find the general mount point[1] to
handle the path.

The mount point, which is as general mount point, will be got by
"fintmnt" previously. But the mntpoint may be incorrect, if the mntpoint
is bind mount.

In order to fix it to support bind mounted in atomic, we will add a
judgement to comfirm the mntpoint is bind mounted, or not.

For general mount, returning path is like following, if we use
"findmnt". The returning is same as "findmnt -v".

    -bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}'
    /dev/mapper/atomicos-root

But for bind mount, returning path is like following, if we use
"fintmnt".
    -bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}'
    /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var]

Use "findmnt -v" is like this:
    -bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}'
    /dev/mapper/atomicos-root

So we can determine the bind mount, if the returning is different
between "findmnt" and "findmnt -v".

[1] general mount point is a directory without being in bind mounted
mode, just a normal directory.

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:57:44 +08:00
Minfei Huang
4a468829e7 kdump-lib: Add new function to judge the system is Atomic or not
For Atomic system, the cmdline will contain the specific string
"ostree". So we can filter out the "ostree" to judge the system is
Atomic or not.

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:57:28 +08:00
Minfei Huang
ef94190ce5 kdump-lib: Add the new function to enhance bind mounted judgement
findmnt uses the option "-v, --nofsroot" to exclude the [/dir] in the
SOURCE column for bind-mounts, then if $_mntpoint equals to
$_mntpoint_nofsroot, the mountpoint is not bind mounted directory.

the value of $_mntpoint may be like
/dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the
directory is bind mounted. The former part represents the device path, the
rest part is the bind mounted directory which quotes by bracket "[]".

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:57:12 +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
WANG Chao
b95a63839a kdump-lib: fix get_option_value()
get_option_value() is used to get the value of $1 configured in
/etc/kdump.conf. But when we use "get_option_value ssh", it can get the
value of "sshkey" instead of "ssh".

Fix the regexp pattern to get an exact match.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2014-11-04 11:42:04 +08:00
Baoquan He
f8d7090b59 pass mount info to dracut when default target is a separate disk
When user does not specify dump target explicitly, it's better to
dump to the "path" specified. That means after dump user enter into
1st kernel, can find vmcore in the "path". If that path is in root
fs, vmcore is stored in root fs. If separate disk is mounted on
any tier of "path", we just dump vmcore into the left path on the
left separate disk.

E.g in kdump.conf
path /mnt/nfs

in mount info,
/dev/vdb on /mnt type ext4 (rw,relatime,seclabel,data=ordered)

Then vmcore will be saved in /nfs of /dev/vdb.

In this patch, pass mount info to dracut in this case if separate
disk is mounted on any tier of "path".

Meanwhile introduce a function in kdump-lib.sh to check if any
target is specified.

v4->v5:
    Per Vivek's comment, add a helper function is_fs_dump_target.
    Then is_user_configured_dump_target is rewrite with these helper
    functions.

v5->v7:
    No v6 for this patch. Just use newly introduced function
    is_fs_type_nfs in handle_default_dump_target.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-17 11:27:31 +08:00
Baoquan He
b2429dbd3d user need make sure "path" on mounted fs has been created
kdump need create the dir specified in "path" formerly if it does not
exist. Now change the behavior to be that ueser takes charge of the
"path", make sure "path" has been created, especially when separate disk
is mounted on this "path".

Also introduce 2 helper functions to help check the existence of path.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-17 11:27:31 +08:00
Baoquan He
b9185c78ee introduce several basic utility function
These utility function will be shared by several files, they are all
operation related to mount stuff.

Meantime define DEFAULT_PATH="/var/crash".

v5-> v6:
    Since in rhel7 nfs4 becomes default nfs version, and its fstype is
nfs4. So change the implementation of get_fs_type_from_target(),
whatever fstype returned from findmount, just echo nfs as fstype for all
nfs version.

v6->v7:
    Introduce is_fs_type_nfs to check if fstype is nfs or nfs4 per Vivek's
idea.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-17 11:27:31 +08:00
Martin Perina
2066e5f792 Add fence_kdump support for generic clusters
Adds two new options to kdump.conf to be able to configure fence_kdump
support for generic clusters:

  fence_kdump_args <arg(s)>
    - Command line arguments for fence_kdump_send (it can contain all
      valid arguments except hosts to send notification to)

  fence_kdump_nodes <node(s)>
    - List of cluster node(s) separated by space to send fence_kdump
      notification to (this option is mandatory to enable fence_kdump)

Generic clusters fence_kdump configuration take precedence over older
method of fence_kdump configuration for Pacemaker clusters. It means
that if fence_kdump is configured using above options in kdump.conf, old
Pacemaker configuration is not used even if it exists.

Bug-Url: https://bugzilla.redhat.com/1078134
Signed-off-by: Martin Perina <mperina@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-03 14:43:06 +08:00
Martin Perina
b8d586dd59 Add get_option_value()
Adds get_option_value() function to retrieve value of specified option
from /etc/kdump.conf.

Bug-Url: https://bugzilla.redhat.com/1078134
Signed-off-by: Martin Perina <mperina@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-03 14:43:03 +08:00
Martin Perina
98f58cdc56 Rename is_fence_kdump to is_pcs_fence_kdump
Renames is_fence_kdump to is_pcs_fence_kdump to identify that this
method should be used to detect fence_kdump configuration only in
Pacemaker clusters.

Bug-Url: https://bugzilla.redhat.com/1078134
Signed-off-by: Martin Perina <mperina@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-03 14:42:57 +08:00
Martin Perina
48f4375f2e Rename FENCE_KDUMP_NODES to FENCE_KDUMP_NODES_FILE
Renames FENCE_KDUMP_NODES variable to FENCE_KDUMP_NODES_FILE to
distinguish it from values read from fence_kdump_nodes option in
kdump.conf (introduced in following patches).

Bug-Url: https://bugzilla.redhat.com/1078134
Signed-off-by: Martin Perina <mperina@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-03 14:42:54 +08:00
Martin Perina
98d4be908a Rename FENCE_KDUMP_CONFIG to FENCE_KDUMP_CONFIG_FILE
Renames FENCE_KDUMP_CONFIG variable to FENCE_KDUMP_CONFIG_FILE to
distinguish it from values read from fence_kdump_args option in
kdump.conf (introduced in following patches).

Bug-Url: https://bugzilla.redhat.com/1078134
Signed-off-by: Martin Perina <mperina@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-03 14:42:13 +08:00
Baoquan He
c1bf4dec6c mkdumprd fail if target is NFS and mounted on /var/crash
Now when dump target is not specified, separate disk can't be mounted on
"path", e.g /var/crash. However if target is specified, whatever the default
fail action is set, mkdumprd should go ahead and not be failed.

In check_block_dump_target(), the check only on disk is not complete,
NFS and ssh need be filtered too. So introduce is_user_configured_dump_target
to check this.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-03-26 14:37:55 +08:00
Baoquan He
8c527aba43 kdump-lib.sh: introduce two functions abstracted from get_block_dump_target for reuse
In function get_block_dump_target(), code block to get user configured
dump disk and get root fs device can be reused by other places. Now
abstract and wrap them into 2 new functions:

get_user_configured_dump_disk()
get_root_fs_device()

And put them into kdump-lib.sh.

Meanwhile change the get_block_dump_target() accordingly.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-03-10 13:17:21 +08:00
WANG Chao
b0535afe2d kdump-lib: add common variables and function for fence kdump
Add following common variables and function:

$FENCE_KDUMP_CONIFG: configuration file /etc/sysconfig/fence_kdump
$FENCE_KDUMP_NODES: configuration file /etc/fence_kdump_nodes
$FENCE_KDUMP_SEND: executable /usr/libexec/fence_kdump_send
is_fence_kdump(): used to determine if the system is in a cluster and
configured with fence_kdump.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Tested-by: Zhi Zou <zzou@redhat.com>
Tested-by: Marek Grac <mgrac@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-01-29 16:20:06 +08:00
Baoquan He
a682315996 kdump-lib.sh: strip_comments is not implemented correcty
In mkdumprd, strip_comments is not implemented correctly. Since arguments
passed, strip_comments only take $1 and misses others. This caused
problems. Such as below line, current code will only get "makedumpfile"
and pass it to $config_val finally, then parameters for makedumpfile
are missed.

core_collector makedumpfile -c --message-level 1 -d 31

Now modify function strip_comments.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2013-10-12 16:00:12 +08:00
Baoquan He
ee524473c8 kdump-lib.sh: add common function strip_comments
Add function strip_comments into kdump-lib.sh, since it's used by
several files.

Signed-off-by: Wade Mealing <wmealing@redhat.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-09-27 10:08:56 +08:00
WANG Chao
a8921f04ae Introduce kdump-lib.sh for kdump shared functions
Currently in the whole kdump framework, we have some common functions
used across not only mkdumprd context and dracut context, but also 1st
kernel and 2nd kernel. We defined these functions at each script, which
is obviously not decent.

So let's introduce kdump-lib.sh for the shared functions and put it
to /lib/kdump/kdump-lib.sh.

It starts small, as you can see, only 3 functions are extracted. But in
the future more and more common functions can be added.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-09-27 10:07:13 +08:00