Commit Graph

116 Commits

Author SHA1 Message Date
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
WANG Chao
2276b8561c Introduce kdump capture service
This patch introduce a new kdump-capture.service which is used to run
kdump.sh.

kdump-capture.service has OnFailure=emergency.target and
OnFailureIsolate=yes set. When kdump.sh fails, the kdump emergency
service will be triggered and enter the error handling path.

In 2nd kernel, the default target for systemd is initrd.target, so we
put kdump-capture.service in initrd.target.wants/ and by that, system
will start kdump-capture as part of the boot process.

kdump.sh used to run in dracut-pre-pivot hook. Now kdump-capture.service
is placed after dracut-pre-pivot.service and other dependencies are all
copied from dracut-pre-pivot.service. So the start point of
kdump.sh will be almost the same as it used to be.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2014-08-05 13:13:32 +08:00
WANG Chao
002337c671 Introduce kdump error handling service
Now upon failure kdump script might not be called at all and it might
not be able to execute default action. It results in a hang.

Because we disable emergency shell and rely on kdump.sh being invoked
through dracut-pre-pivot hook. But it might happen that we never call
into dracut-pre-pivot hook because certain systemd targets could not
reach due to failure in their dependencies. In those cases error
handling code does not run and system hangs. For example:

sysroot-var-crash.mount --> initrd-root-fs.target --> initrd.target \
  --> dracut-pre-pivot.service --> kdump.sh

If /sysroot/var/crash mount fails, initrd-root-fs.target will not be
reached. And then initrd.target will not be reached,
dracut-pre-pivot.service wouldn't run. Finally kdump.sh wouldn't run.

To solve this problem, we need to separate the error handling code from
dracut-pre-pivot hook, and every time when a failure shows up, the
separated code can be called by the emergency service.

By default systemd provides an emergency service which will drop us into
shell every time upon a critical failure. It's very convenient for us to
re-use the framework of systemd emergency, because we don't have to
touch the other parts of systemd. We can use our own script instead of
the default one.

This new scheme will overwrite emergency shell and replace with kdump
error handling code. And this code will do the error handling as needed.
Now, we will not rely on dracut-pre-pivot hook running always. Instead
whenever error happens and it is serious enough that emergency shell
needed to run, now kdump error handler will run.

dracut-emergency is also replaced by kdump error handler and it's
enabled again all the way down. So all the failure (including systemd
and dracut) in 2nd kernel could be captured, and trigger kdump error
handler.

dracut-initqueue is a special case, which calls "systemctl start
emergency" directly, not via "OnFailure=emergency". In case of failure,
emergency is started, but not in a isolation mode, which means
dracut-initqueue is still running. On the other hand, emergency will
call dracut-initqueue again when default action is dump_to_rootfs.
systemd would block on the last dracut-initqueue, waiting for the first
instance to exit, which leaves us hang. It looks like the following:

dracut-initqueue (running)
  --> call dracut-emergency:
    --> dracut-emergency (running)
      --> kdump-error-handler.sh (running)
        --> call dracut-initqueue:
          --> blocking and waiting for the original instance to exit.

To fix this, I'd like to introduce a wrapper emergency service. This
emegency service will replace both the systemd and dracut emergency. And
this service does nothing but to isolate to real kdump error handler
service:

dracut-initqueue (running)
  --> call dracut-emergency:
    --> dracut-emergency isolate to kdump-error-handler.service
      --> dracut-emergency and dracut-initqueue will both be stopped
          and kdump-error-handler.service will run kdump-error-handler.sh.

In a normal failure case, this still works:
foo.service fails
  --> trigger emergency.service
    --> emergency.service isolates to kdump-error-handler.service
      --> kdump-error-handler.service will run kdump-error-handler.sh

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2014-08-05 13:13:32 +08:00
WANG Chao
3b27570bea cleanup: extract functions from kdump.sh to kdump-lib-initramfs.sh
Extract functions from kdump.sh, and construct kdump-lib-initramfs.sh as
kdump common functions/varaibles library.

kdump-lib-initramfs.sh will include kdump-lib.sh, because it will use
the functions from there. IOW, kdump-lib-initramfs.sh will be a superset
of kdump-lib.sh

So after this cleanup:

- scripts running in 1st kernel only have to include kdump-lib.sh
- scripts running in 2nd kernel only have to include kdump-lib-initramfs.sh

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2014-08-05 13:13:11 +08:00
WANG Chao
ba7660f37e dracut-module-setup: NIC renamed with prefix "kdump-" for native ethX
We met a problem that eth0 ends up being eth1 and eth1 being eth0
between 1st and 2nd kernel. Because we pass ifname=eth0:$mac to force
it's named eth0 and since "eth0"is already taken by the other NIC, udev
fails to bring up the NIC we want, thus kdump fails.

kernel assigned network interface names are not persistent. So if first
kernel is using kernel assigned interface names, then force it to use
"kdump-" prefixed names in second kernel.

For ethX, we put a prefix "kdump-" before it, so in 2nd kernel, ethX
will name to "kdump-ethX". So that we can avoid the naming conflict.

We only need to change the ethernet card name, that means, for bridge,
vlan, bond, team devices' names , we never prefix them. Because these
names are assigned when they're created by userspace.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-07-24 12:58:06 +08:00
WANG Chao
fd4bd5552b dracut-module-setup: avoid writing the vlan.conf twice
We handle different types of device for vlan. For each type, it should
write different options for vlan.conf in each control path.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-07-24 12:57:53 +08:00
Marc Milgram
7ea50dc7a3 kdump-module-setup.sh: Handle static IPs defined in NetworkManager gui
NetworkManager changed the format of ifcfg-device files.  They may define
static IP addresses with the following format:
    IPADDR0=192.168.122.100
    PREFIX0=24

There may be up to 255 ip addresses for a network device - each with a unique
number tagged to the end of IPADDR and PREFIX.

Prior to this fix, kdump only handled static ip addresses defined with
   IPADDR=192.168.122.100
   PREFIX=24

ie. without the number.

The solution is to use "ip" commands to find the correct network information.

Tested with both static and dynamic IP addresses.

v2: Fixed a local variable that was set incorrectly
v3: Fix iscsi case

Signed-off-by: Marc Milgram <mmilgram@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
2014-05-30 14:52:17 +08:00
Baoquan He
a54ea2d6b8 store the default dump target info when default target is a separate disk
If default target is a separate disk, the related information need be
stored in /etc/kdump.conf of kdump initramfs. This includes the disk
info which will help to deduce the dump_code and path which the vmcore
will be written into.

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

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
0f8c8dd04f Rename kdump_check_fence_kdump to kdump_configure_fence_kdump
Renames kdump_check_fence_kdump kdump_configure_fence_kdump to clearly
identify what this function does.

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:59 +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
5caafd2c00 adjust the installkernel function to make it return correct value
The old implementation in installkernel() will not return success when
added wdt module is not iTCO_wdt. The returned value is related to the
comparison. This is not correct and will cause kdump load failed.

Now move the exact wdt module inserting to the right place, this can
be fixed.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-03-03 13:36:50 +08:00
Baoquan He
1060846036 insert wdt kernel modules when watchdog is active
When watchdog is enabled in 1st kernel, then crash dump in kdump
kernel will be interrupted if watchdog is timeout. Since some
wdt drivers can stop the watchdog when its driver is loaded,
e.g iTCO_wdt, this can benefit crash dump.

Add watchdog driver which is active in system to initramfs, its
loading can stop watchdog.

For now, put this adding in 99kdumpbase.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-02-17 12:49:56 +08:00
WANG Chao
d7158a284c ssh dump: create random-seed manually
In ssh dump, we use random-seed to feed /dev/urandom. Since the systemd
random-seed file could change location, it's better we create our
own random-seed.

The discussion is listed below for future reference:
https://lists.fedoraproject.org/pipermail/kexec/2014-January/000340.html

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-01-29 16:31:05 +08:00
WANG Chao
11cb815904 module-setup.sh: do not add duplicate ip=xxx to 40ip.conf
In the remote dump case, and if fence kdump is configured, chances are
that the same network interface will be setup more than once.
One time for network dump, the other times for fence kdump. The result
is we will have two or more duplicate ip= configuration in 40ip.conf.

These are exactly duplicates, however dracut will refuse to continue and
raise a fatal error if there are duplicate configuration for the same
interface. So we have to avoid adding these duplicates.

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
WANG Chao
da61e30907 module-setup.sh: setup fence kdump environment
This patch is used to setup fence kdump environment when building kdump
initrd:
1. Check if it's cluster and fence_kdump is configured.
2. Get all the nodes in the cluster and pass them to 2nd kernel via
   /etc/fence_kdump_nodes
3. Setup network interface which will be used by fence kdump notifier in
   2nd kernel.
4. Install fence kdump notifier (/usr/libexec/fence_kdump_send) to
   initrd.

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
59e28ddf75 Strip inline comments from the kdump config file before use
From: Wade Mealing <wmealing@redhat.com>

The RHEL 5 release of mkdumprd allowed for comments in the kdump config
file as shown below:

net 192.168.1.1 # this is the comment part

This patch strips them out during processing, but leaves the configuration
file in original condition.

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:09:25 +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
WANG Chao
cbbd4428ac dracut-module-setup: _dev to be a local variable
In kdump_setup_bridge/bond/team(), we use _dev as a global variable.
That causes following issues when network is br0 over bond0:

-> kdump_setup_bridge br0: _dev to be "bond0" as a brif
  -> kdump_setup_bond bond0: _dev is modified to be eth0 as a bond slave
    -> (jump back) kdump_setup_bridge br0: we really need _dev is
       "bond0" not "eth0".

_dev must be a local variable because it has been used multiple places.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2013-09-27 10:07:13 +08:00
dyoung@redhat.com
d4ce7e5d97 remove 98selinux dependency
Chaowang measured the selinux load_policy memory usage, it need ~50M
It's too much under kdump 2nd kernel, it cause more OOM then before.

Here is the findings from Vivek:
- If we don't load policy or don't do restorecon, kernel automatically
  uses a label for file as specified by file
  /sys/fs/selinux/initial_contexts/file

  On my system this value is "system_u:object_r:file_t:s0". Kernel
  enforces this label on a file if it is not labeled. That's the reason
  that you see above label on vmcore file when selinux policy was not
  loaded in second kernel or restorecon was not done.

  Note: I did some testing with rhel6 and there also I see file_t context.
  Not sure why that's the case.

- Relabeling of root file system over boot happens if there is a file
  /.autorelabel present. This file is touched by systemd service
  fedora-autorelabel-mark.service. And this file comes from initscritps
  package.

  So if this service thinks that system was booted with selinux disabled
  it will put this file on root and when next time system boots with
  selinux enabled, relabeling is enforced by fedora-autorelabel.service
  service.

- In our case relabeling is not happening after saving vmcore because
  there does not seem be any fedora-autorelabel-mark.service running
  from initramfs context. Looks like this service runs after switching
  to real root.

  Aug 08 10:44:13 vm9-f19 systemd[1]: Started Mark the need to relabel after reboot.

- selinux poicy is now loaded by systemd after root switch has taken
  place.

  Aug 08 10:44:10 vm9-f19 systemd[1]: Successfully loaded SELinux policy in 357.693ms.

So now we know that why selinux relabeling is not taking place. Reason
being that systemd service which marks the file system for autorelabeling
does not run from initramfs context.

And it might not make to run this service from initramfs context before
switch root. In general it makes sense to first switch to root, load
selinux policy if needed and then check whether to mark this filesystem
for relabel or not. Ideally root is mourted read only before that. It is
just that we break this rule for kdump. So as long as we make sure we
relabel files created by kdump after booting back, things should be fine.

Since we will relabel the vmcore dir after reboot so let's remove
the selinux dracut module dependency to avoid load_policy in 2nd kernel.
If in the future load_policy memory usage shrinks to an acceptable level
or there's a better solution we can add selinux load_policy back later.

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-08-21 14:54:33 +08:00
WANG Chao
0aee2a0072 dracut-module-setup.sh: setup correct system time and time zone in 2nd kernel.
Currently in initrd, hardware clock is always considered to use UTC time
format and system time zone is also UTC. Thus system time isn't correct
if hw clock is localtime or we're using other time zone in real root.

To fix this, install /etc/adjtime and /etc/localtime to initrd.

Previously, this functionality was implemented in dracut base module:

commit 77364fd
Author: WANG Chao <chaowang@redhat.com>

    base: setup correct system time and time zone in initrd

But some people complains about a normal boot initrd needs to rebuild
every time if time zone is changed. So let's fix it on our side.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-08-02 14:56:01 +08:00
Baoquan He
cc4abf52c9 Use /lib/dracut/no-emergency-shell to control action on fail
Currently when action_on_fail is enabled, the emergency_shell won't be called
either. In kdump even though user specify the default action as emergency_shell,
dracut still skip it. Now change the implementation of action_on_fail to depend
on a file which is created by kdump when making kdump initrd, then remove it
at the beginning of kdump. This can solve the explicit emergency_shell problem.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
2013-08-02 14:52:32 +08:00
WANG Chao
dd7ce4b5fd dracut-module-setup.sh: improve the approach to get a bridged interface list
When directory is empty, echo * will output *, not empty string. That's
not intended.
Also it looks a little bit nicer now.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-06-18 13:10:21 +08:00
WANG Chao
76602596e0 dracut-module-setup.sh: cleanup - use kdump_get_mac_addr() function
We forget to use kdump_get_mac_addr() in this case. So fix it.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-06-18 13:09:54 +08:00
WANG Chao
7b19ef79c3 dracut-module-setup.sh: use kernel exported mac address in kdump_get_mac_addr()
kernel has exported mac address for each interface, we can get it
directly instead of parsing the output from ip address show.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-06-18 13:09:27 +08:00
WANG Chao
671e18f43b dracut-module-setup.sh: use perm addr of slaves to setup bonding network
Currently we use runtime mac addr to 2nd kernel to setup bonding
interface. But Bonding master will modify its slaves' mac addr and
incorrect mac addr is passed to 2nd kernel. Thus dracut in 2nd kernel
can't find expected slaves and bonding will fail.

Fix this issue by using perm address.

Tested in Fedora 19 KVM guest configured bonding with two slaves.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-06-18 13:08:40 +08:00
WANG Chao
56c7c922e1 dracut-module-setup.sh: kdump module depends on drm module
When 1st kernel is using KMS and crash, 2nd kernel can't reset to
nomodeset and the screen is black. In this case, user can't observe the
boot/dump progress and run commands in shell.

So let's pull in drm dracut module to fix this.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-06-18 10:37:44 +08:00
dyoung@redhat.com
b156ef0d68 depends on dracut selinux module
depends on 98selinux if 1st kernel selinux is enabled so we can load_policy
and correctly label the vmcore/vmcore-dmesg files.

Since dracut always mount rootfs, the 98selinux will chroot and load_policy,
so this will be ok for Fedora. In case rootfs mount failure we have to check
and relable vmcore files, will add the kdumpctl relabeling code in another
patch.

add 'dracut_args --printsize' to /etc/kdump.conf, it shows below added size:
selinux install size: 16k

Tested on F19:
With this patch applied, vmcore selinux attr is ok.

v1->v2: use sestatus 2>/dev/null to mute error messages

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-06-13 11:28:25 +08:00
Baoquan He
259baae8f3 Add tab key as delimiter for core_collector in kdump.conf
In kdump.conf, space key is used as delimiter by default.

In kdump_install_conf of dracut-module-setup.sh, if specify
core_collector with a tab delimiter, the tool may not be
copied into kdump-initrd.
E.g, core_collector scp		-v

And in dump_ssh of dracut-kdump.sh, dumping will fail caused
by tab key in core_collector.

Here change code to allow tab key as delimiter when specifying
core_collector.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-06-04 10:54:23 +08:00
Baoquan He
ca61e6a1bb kdump: Save vmcore-dmesg.txt before saving vmcore
Save vmcore-dmesg.txt before saving vmcore. For ssh targets, it assumes
that ssh is enabled. No scp logic as I don't have a local copy of
kernel log buffers and saving one will consume extra memory. We
can possibly enhance this logic to save kernel log buffers first locally
and then scp it (For setups which allow scp but disable ssh access).
(log is from Vivek Goyal <vgoyal@redhat.com>)

And add 1 section to describe it in kexec-kdump-howto.txt

v3->v4:
     Remove old description of dmesg in kexec-kdump-howto.txt, now
     add a new section to describe it, and note user kernel log
     buffers won't be available if dump target is raw device.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-05-14 11:17:55 +08:00
WANG Chao
c3635964c4 Remove "ip=" overwrite to 40ip.conf
Currently we overwrite 40ip.conf to make ip and ifname both at the first
line. But getarg() of dracut doesn't have the limitation that all
cmdline args should be at the first line. Therefore, we can remove the
overwrite safely.

After applying this patch, in 2nd kernel,

kdump:/# cat /etc/cmdline.d/40ip.conf
 ip=eth0:dhcp
 ifname=eth0:52:54:00:b2:98:05
kdump:/# source /usr/lib/dracut/dracut-lib.sh
kdump:/# getarg ip
ip=eth0:dhcp
kdump:/# getarg ifname
ifname=eth0:52:54:00:b2:98:05

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-05-14 11:13:25 +08:00
WANG Chao
233bd8765e Add support for bridge over bond/team/vlan.
Kdump module doesn't check if bridge is stack on other complex interface
and setup proper dracut cmdline. That makes dracut fail to setup a working
network environment in 2nd kernel.

This patch adds the ability to setup proper dracut cmdline for bridge over
bond/team/vlan. Although in this timeframe, drauct only supports bridge over
bond among these three complex network, it's worth fixing the other two types
(bridge over team/vlan) along with. It would be much easier for us once
the dracut part is done.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-05-14 09:44:16 +08:00
WANG Chao
0455b7035e Fix bonding options syntax and get all specified options from ifcfg file.
drauct takes bond=<bondname>[:<bondslaves>:[:<options>]] syntax to parse
bond. For example:
 bond=bond0:eth0,eth1:mode=balance-rr

Update v2:
- Get bonding options from corresponding ifcfg. Because it's hard to keep
  track of all the runtime configurable options under /sys/class/net/$netif/
- Remove kdump_get_bond_mode, since it's useless now.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-05-14 09:43:31 +08:00
dyoung@redhat.com
ff7d629a56 dracut-module-setup.sh: remove UUID/LABEL quotes before using it
blkid do not support UUID/LABEL with quotes, remove the quotes before converting
to dev name, or the result devname will be nul.

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-03-14 10:42:15 +08:00
Cong Wang
97e107b5ab Add support for team devices
V4: Sync with the latest teamd

V3: Drop patch 2/2 which harms readability
    Move inst_dir to kdump_setup_team()
    Avoid saying why teamdctl fails
    Error out for vlan over team, like bridge
    Remove the useless exit in kdump_get_perm_addr()

V2: remove the tmp config file in /tmp
    split the non-team part

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=874025
(This BZ is against RHEL7 though...)

Depends on dracut patch:
http://article.gmane.org/gmane.linux.kernel.initramfs/3043

and depends on latest version of teamd.

This patch adds support for team devices on kdump side.
I tested team active-backup mode and round-robin mode,
vmcore can be dumped over ssh successfully.

Note, currently we don't support stacked devices
on/under team, it is tricky and can be added on request.

Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2013-01-28 14:04:27 +08:00
Dave Young
ae1db90332 add bootdev cmdline param
With recent dracut a bootdev is needed in cmdline, so dracut can waiting for
this nic ready early in initqueue. So in this patch bootdev=${_netnic} is added

[v1->v2]: use standard cmdline file name 70bootdev.conf

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-01-28 14:00:58 +08:00
Dave Young
4874a9539a kdumpnic cmdline file name cleanup
use standard cmdline file name start with digit number: 60kdumpnic.conf

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
2013-01-28 14:00:54 +08:00
Baoquan He
4590f6e33b Optimize redundent code fetching server of network dump
Code in function kdump_install_net used to get server of network dump
is is a little redundent, can be optimized into one line. For nfs/ssh,
this line of code is enough.

Test passed on local kvm guest with Fedora 18.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-12-14 17:23:46 +08:00
Baoquan He
3be6c1228e change the dump dir format to be more readable
Resolves: bz880551

Currently on fedora directory name of kdump is like 14.11.12-03:40:30.
It's not as readable as RHEL6. The old format of dir is host_ip-date-time.
This patch changes it back like ole one as below.
192.168.122.234-2012-10-31-05:17:20

If can't get HOST_IP for a network kudmp, we just fail. Becasue most
likely any attempt to save dump will also fail.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-12-14 17:23:09 +08:00
Dave Young
c5c4a7b8b0 add random feeding code for ssh dump
ssh: add random feeding code

openssh usually depends on /dev/urandom to seeding PRNG (pseudo-random number
generator). To ensure there's sufficient entropy just feed /dev/urandom with
saved /var/lib/random-seed which is saved in installing phase.

dracut_install will print error message, so just exit and do not print error
again.

Todo: other dracut_install fail and exit, such as dd, makedumpfile.

[v2->v3]: use [[:blank:]] for whitespace checking.

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-11-16 14:07:52 +08:00
Dave Young
7de0cc4a92 use persistent name in kdump.conf of initramfs
In initramfs we should use persistent name created by udev to avoid
device rename issue.

fix by using udev persistent name when we copy the kdump.conf

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-09-20 11:03:14 +08:00
Dave Young
679b4216fa iscsi setup fix
Original host_fs_types could only contain one iscsi slave,
This is due to the check_block_and_slaves will return once the helper function
return TRUE, so only one slave with fs type will be added to host_fs_types[]
Thus, there will no chance to setup other slaves in kdump iscsi setup routine.

Use for_each_host_dev_and_slaves_all to setup all slaves.

Tested by chaowang and myself.

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-08-29 09:42:00 +08:00
Dave Young
b47c0915d2 refactor net option
Currently net options means either nfs or ssh dump.
Better to split these two into standalone options. That's more clear to user.

after the split, ssh dump need user specify "ssh user@host"
nfs dump need user specify "nfs host:nfsshare"

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-07-23 15:31:28 +08:00
Dave Young
4d37a55bc1 install core_collector in module-setup.sh
file install code should stay in module-setup.sh, move core_collector installation
code as well.

Note: mkdumpfile is installed twice before, one is dracut cmdline, another is
module_setup.sh. This patch removed the duplicate code in dracut cmdline.

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-07-12 11:15:35 +08:00
Dave Young
9f5af7aca8 install extra_bins in module-setup.sh
moving file install code to module-setup.sh looks better.
This patch move extra_bins installation to module-setup.sh

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-07-12 11:15:35 +08:00
Dave Young
57f8e18d17 network dns config fix
In case explict DNS setup in ifcfg file, we should add proper cmdline
for dracut network use.

Add a kdump_setup_dns function to handle this.
v1->v2: vivek: use echo instead of 'echo -n'

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-07-12 11:15:35 +08:00
dyoung@redhat.com
7148c0a30d add s390x netdev setup
s390x netdev need special cmdline to bring up
parse the ifcfg file to append proper cmdline, also add znet dracut module

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-07-05 16:52:12 +08:00
dyoung@redhat.com
a67cebf1bf Cleanup temp file leaved at /tmp/
module_setup.sh removed comment and blank lines of kdump.conf, then install it
to initramfs, but it leaved the /tmp/$$-kdump.conf which should be removed.

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-07-05 16:41:49 +08:00
Cong Wang
f9c56b3f6e Respect bonding mode
Update: use /sys/class/net/bondX/bonding/mode

We should set the mode of the bonding properly
in the second kernel too.

Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-07-05 16:35:16 +08:00
Cong Wang
469bdf2cae Support dump over vlan tagged bonding
Update: error out vlan over bridge case

This patch adds support for vlan tagged bonding,
in theory, we could support other complex setup as well,
in practice, this is not easy, so just support vlan
tagged bonding, which is the one we support in RHEL6.

Note, this patch depends on the dracut patch:
http://marc.info/?l=initramfs&m=134025049228510&w=2

Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-07-05 16:34:54 +08:00
Dave Young
4e4a173698 Add kdump_post and kdump_pre support
Original patch is from Amerigo, but it has changed a lot:
remove multi dump
refreshed with latest git for the dump instruction function restructure
fixed the behavior of do_kdump_pre, if kdump_pre fails it will reboot
update the docs
check the existance and executable of kdump_pre/post files,
also check the timestamp of them for rebuilding.

refresh patch,
Address comments from vivek:
s/hush/bash in docs
fix the copy-paste error in kdump post error message
s/reboot\/halt/reboot in kexec-kdump-howto.txt

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-06-14 09:57:30 +08:00
Cong Wang
e720fcdadf add vlan support
This patch depends on the latest dracut in git.
It adds support of dumping over a vlan device.

Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-06-11 14:03:26 +08:00
Cong Wang
999870558b fix and refactor bond handling code
This patch fixes dumping over a bonding interface,
we should pass ifname= for all its underlying slaves,
which is required by dracut.

And it separates the code into a different function.

Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-06-11 14:03:12 +08:00
Cong Wang
725dae14ac fix and refactor bridge handling code
This patch fixes dumping over a bridge interface,
we should pass ifname= for all its underlying devices,
which is required by dracut.

And it separates the code into different functions,
for later patches to use.

Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-06-11 14:02:47 +08:00
Dave Young
21398a5cdd static ip configuration support
Resolves: bz822739

We hardcoded with dhcp in dracut cmdline before.
Fix it by parsing  ifcfg to get the proper proto,
echo proper cmdline for both static and dhcp
[v1->v2]: amwang - handle PREFIX as well

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Cong Wang <amwang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-05-28 09:49:25 +08:00
Vivek Goyal
e30ad0a4ec kdump: Basic iscsi target dump support (software initiator)
BZ: 822701

This patch implements basic software iscsi dump support. Complex iscsi
setups like ibft etc might not work.

iscsi self configuration logic is currenlty part of kdump module. At some
point of time I would like to see it in dracut iscsi module instead of
kdump module when iscsi and other subsystems become self configuration aware
for general boot.

This patch will require work for complex setups. Some of them are.

- IPV6 support
- IBFT support
- Parsing some more advanced parameters and passing to netroot option.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-05-28 09:42:00 +08:00
Vivek Goyal
bf247cb56c kdump: Move network device setup in a separate function
BZ: 822701

This allows to reuse same function from iscsi setup code too. Also makes
code more modular.

[dyoung: add a missed space]

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2012-05-24 13:49:21 +08:00
Dave Young
70dbef8656 Resolves: bz805773
cleanup module_setup.sh, move code blocks to functions.

[v1->v2]: vivek: add kdump_ prefix to kdump functions because dracut
          source this file

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2012-05-14 10:36:18 +08:00
Dave Young
bbd2e7d30a remove dracut-files.tbz2 [v2]
Resolves: bz816864

currently kexec-tools maintains kdump dracut modules as below dir hierarchy:
 [dave@localhost fedpkg]$ tree kexec-tools/kdump_dracut_modules
 kexec-tools/kdump_dracut_modules
 `-- 99kdumpbase
     |-- kdump.sh
     `-- module-setup.sh

But in kexec-tools.spec, sources line is below:
Source100: dracut-files.tbz2

So we need to manually generate the dracut-files.tbz2, upload it, modify
the sources file which contains the md5sum of these binaies, and then do
the building. The more headache problem is this make local tests of
changes to kdump module hard.

To ease future work, move the files to TOPDIR, cp the sources instead.

Thanks for help from dzickus
[v1->v2]: Also remove dracut-files.tbz2 from sources file
          ChaoWang: add prefix to dracut files
2012-05-03 10:06:05 +08:00