Commit Graph

65 Commits

Author SHA1 Message Date
Coiby Xu
06ddf8d90d dracut-module-setup.sh: also install the driver of physical NIC for Hyper-V VM with accelerated networking
Resolves: bz2151842
Upstream: Fedora
Conflict: None

commit bc101086e2
Author: Coiby Xu <coxu@redhat.com>
Date:   Mon Dec 12 18:37:25 2022 +0800

    dracut-module-setup.sh: also install the driver of physical NIC for
    Hyper-V VM with accelerated networking

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

    Currently, vmcore dumping to remote fs fails on Azure Hyper-V VM with
    accelerated networking because it uses a physical NIC for accrelarated
    networking [1]. In this case, the driver for this physical NIC should be
    installed as well.

    [1] https://learn.microsoft.com/en-us/azure/virtual-network/accelerated-networking-overview

    Fixes: a65dde2d ("Reduce kdump memory consumption by only installing needed NIC drivers")

    Reported-by: Xiaoqiang Xiong <xxiong@redhat.com>
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-12-27 02:45:59 +00:00
Coiby Xu
0aaa053cc3 dracut-module-setup.sh: stop overwriting dracut's trap handler
Resolves: bz2151832
Upstream: Fedora
Conflict: None

commit b45896c620
Author: Coiby Xu <coxu@redhat.com>
Date:   Tue Dec 6 18:18:32 2022 +0800

    dracut-module-setup.sh: stop overwriting dracut's trap handler

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

    Latest Workstation live x86_64 image has an excess increase of ~300 MB
    in size. This is because kdumpbase module's trap handler overwrites
    dracut's handler and DRACUT_TMPDIR which has three unpacked initramfs
    files fails to be cleaned up. This patch moves kdumpbase module's
    temporary folder under DRACUT_TMPDIR and lets dracut's trap handler do
    the cleanup instead.

    Fixes: d25b1ee3 ("Add functions to copy NetworkManage connection profiles to the initramfs")
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-12-14 10:02:00 +08:00
Coiby Xu
fa2f8fc244 Don't run kdump_check_setup_iscsi in a subshell in order to collect needed network interfaces
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit 523cda8f34
Author: Coiby Xu <coxu@redhat.com>
Date:   Fri Nov 25 12:07:25 2022 +0800

    Don't run kdump_check_setup_iscsi in a subshell in order to collect needed
    network interfaces

    Currently, dumping to iSCSI target fails because the global array
    (unique_netifs) that stores the network interfaces needed by kdump is
    empty. The root cause is change of the array made in a subshell (a child
    process) is inaccessible to the parent process. So don't run
    kdump_check_setup_iscsi in a subshell.

    Fixes: 63c3805c ("Set up kdump network by directly copying NM connection profile to initrd")
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Pingfan Liu <piliu@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-25 13:57:32 +08:00
Coiby Xu
afbb32a83c Simplify setup_znet by copying connection profile to initrd
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit b5577c163a
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Sep 23 15:26:00 2021 +0800

    Simplify setup_znet by copying connection profile to initrd

    /usr/lib/udev/ccw_init [1] shipped by s390utils extracts the values of
    SUBCHANNELS, NETTYPE and LAYER2 from /etc/sysconfig/network-scripts/ifcfg-*
    or /etc/NetworkManager/system-connections/*.nmconnection to activate znet
    network device. If the connection profile is copied to initrd,
    there is no need to set up the "rd.znet" dracut cmdline parameter.

    There are two cases addressed by this commit,
     1. znet network interface is a slave of bonding/teaming/vlan/bridging
        network. The connection profile has been copied to initrd by
        kdump_copy_nmconnection_file and it contains the info needed by
        ccw_init.
     2. znet network interface is a slave of bonding/teaming/vlan/bridging
        network. The corresponding ifcfg-*/*.nmconnection file may not contain
        info like SUBCHANNELS [2]. In this case, copy the ifcfg-*/*.nmconnection
        file that has this info to the kdump initrd. Also to prevent the copied
        connection profile from being chosen by NM, set
        connection.autoconnect=false for this connection profile.

    With this implementation, there is also no need to check if znet is
    used beforehand.

    Note
    1. ccw_init doesn't care if SUBCHANNELS, NETTYPE and LAYER2 comes from
       an active NM profile or not. If an inactive NM profile contains this
       info, it needs to be copied to the kdump initrd as well.
    2. "rd.znet_ifname=$_netdev:${SUBCHANNELS}" is no longer needed needed
       because now there is no renaming of s390x network interfaces when
       reusing NetworkManager profiles. rd.znet_ifname was introduced in
       commit ce0305d ("Add a new option 'rd.znet_ifname' in order to use it
       in udev rules") to address the special case of non-persistent
       MAC address by renaming a network interface by SUBCHANNELS.

    [1] https://src.fedoraproject.org/rpms/s390utils/blob/rawhide/f/ccw_init
    [2] https://bugzilla.redhat.com/show_bug.cgi?id=2064708

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:33 +08:00
Coiby Xu
d22786bb5a Address the cases where a NIC has a different name in kdump kernel
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit 568623e69a
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Sep 23 14:25:01 2021 +0800

    Address the cases where a NIC has a different name in kdump kernel

    A NIC may get a different name in the kdump kernel from 1st kernel
    in cases like,
     - kernel assigned network interface names are not persistent e.g. [1]
     - there is an udev rule to rename the NIC in the 1st kernel but the
       kdump initrd may not have that rule e.g. [2]

    If NM tries to match a NIC with a connection profile based on NIC name
    i.e. connection.interface-name, it will fail the above bases. A simple
    solution is to ask NM to match a connection profile by MAC address.
    Note we don't need to do this for user-created NICs like vlan, bridge and
    bond.

    An remaining issue is passing the name of a NIC via the kdumpnic dracut
    command line parameter which requires passing ifname=<interface>:<MAC> to
    have fixed NIC name. But we can simply drop this requirement. kdumpnic
    is needed because kdump needs to get the IP by NIC name and use the IP
    to created a dumping folder named "{IP}-{DATE}". We can simply pass the
    IP to the kdump kernel directly via a new dracut command line parameter
    kdumpip instead. In addition to the benefit of simplifying the code,
    there are other three benefits brought by this approach,
      - make use of whatever network to transfer the vmcore. Because  as long
        as we have the network to we don't care which NIC is active.
      - if obtained IP in the kdump kernel is different from the one in the
        1st kernel. "{IP}-{DATE}" would better tell where the dumped vmcore
        comes from.
      - without passing ifname=<interface>:<MAC> to kdump initrd, the
        issue of there are two interfaces with the same MAC address for
        Azure Hyper-V NIC SR-IOV [3] is resolved automatically.

    [1] https://bugzilla.redhat.com/show_bug.cgi?id=1121778
    [2] https://bugzilla.redhat.com/show_bug.cgi?id=810107
    [3] https://bugzilla.redhat.com/show_bug.cgi?id=1962421

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Coiby Xu
81b414d100 Reduce kdump memory consumption by only installing needed NIC drivers
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit a65dde2d10
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu May 19 11:39:25 2022 +0800

    Reduce kdump memory consumption by only installing needed NIC drivers

    Even after having asked NM to stop managing a unneeded NIC, a NIC driver
    may still waste memory. For example, mlx5_core uses a substantial amount
    of memory during driver initialization,

    ======== Report format module_summary: ========
    Module mlx5_core using 350.2MB (89650 pages), peak allocation 367.4MB (94056 pages)
    Module squashfs using 13.1MB (3360 pages), peak allocation 13.1MB (3360 pages)
    Module overlay using 2.1MB (550 pages), peak allocation 2.2MB (555 pages)
    Module dns_resolver using 0.9MB (219 pages), peak allocation 5.2MB (1338 pages)
    Module mlxfw using 0.7MB (172 pages), peak allocation 5.3MB (1349 pages)
    ======== Report format module_summary END ========

    ======== Report format module_top: ========
    Top stack usage of module mlx5_core:
      (null) Pages: 89650 (peak: 94056)
        ret_from_fork (0xffffda088b4165f8) Pages: 60007 (peak: 60007)
          kthread (0xffffda088b4bd7e4) Pages: 60007 (peak: 60007)
            worker_thread (0xffffda088b4b48d0) Pages: 60007 (peak: 60007)
              process_one_work (0xffffda088b4b3f40) Pages: 60007 (peak: 60007)
                work_for_cpu_fn (0xffffda088b4aef00) Pages: 53906 (peak: 53906)
                  local_pci_probe (0xffffda088b9e1e44) Pages: 53906 (peak: 53906)
                    probe_one mlx5_core (0xffffda084f899cc8) Pages: 53518 (peak: 53518)
                      mlx5_init_one mlx5_core (0xffffda084f8994ac) Pages: 49756 (peak: 49756)
                        mlx5_function_setup.constprop.0 mlx5_core (0xffffda084f899100) Pages: 44434 (eak: 44434)
                          mlx5_satisfy_startup_pages mlx5_core (0xffffda084f8a4f24) Pages: 44434 (peak: 44434)
                        mlx5_function_setup.constprop.0 mlx5_core (0xffffda084f899078) Pages: 5285 (peak: 5285)
                          mlx5_cmd_init mlx5_core (0xffffda084f89e414) Pages: 4818 (peak: 4818)
                            mlx5_alloc_cmd_msg mlx5_core (0xffffda084f89aaa0) Pages: 4403 (peak: 4403)

    This memory consumption is completely unnecessary when kdump doesn't need
    this NIC. Only install needed NIC drivers to prevent this kind of waste.

    Note
    1. this patch depends on [1] to ask dracut to not install NIC drivers.
    2. "ethtool -i" somehow fails to get the vlan driver
    3. team.ko doesn't depend on the team mode drivers so we need to install
       the team mode drivers manually.

    [1] https://github.com/dracutdevs/dracut/pull/1789

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Coiby Xu
95a39f602b Reduce kdump memory consumption by not letting NetworkManager manage unneeded network interfaces
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit 586fe410aa
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Sep 9 11:50:00 2021 +0800

    Reduce kdump memory consumption by not letting NetworkManager manage unneeded network interfaces

    By default, NetworkManger will manage all the network interfaces and
    try to set interface IFF_UP to get carrier state. Regardless of whether
    the network interface is connected to a cable or not, the NIC driver
    will allocate memory resources for e.g. ring buffers when setting IFF_UP.
    This could be a waste of memory. For example it's found i40e consumes ~15GB
    on a power machine. On this machine, i40e manages four interfaces but only
    one interface is valid. This patch use "managed=false" to tell
    NetworkManager to not manage network interfaces that are not needed by
    kdump by putting 10-kdump-netif_allowlist.conf in the initramfs.

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Coiby Xu
420f55c096 Set up kdump network by directly copying NM connection profile to initrd
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit 63c3805c48
Author: Coiby Xu <coxu@redhat.com>
Date:   Fri Sep 17 13:02:07 2021 +0800

    Set up kdump network by directly copying NM connection profile to initrd

    This patch setup kdump network by directly copying NM connection profile(s)
    for different network setup including bond, bridge, vlan, and team. For
    vlan network, rename phydev to parent_netif to improve code readability.

    With the new approach, the related code to build up dracut cmdline
    parameter such rd.route, ip and etc can be cleaned up. And there is no
    need to setup dns when copying .nmconnection directly to initrd
    either. Note the bootdev dracut command line parameter is only used by
    dracut's 35network-legacy and network-manager doesn't use it, remove
    related code as well.

    Note
    1. kdump_setup_vlan/bond/... are no longer called in subshells in order
       to modify global variables like unique_netifs
    2. The original kdump_install_net is renamed to better reflect its
       current function

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Coiby Xu
1141e03fa1 Stop dracut 35network-manager from running nm-initrd-generator
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit 62355ebe5a
Author: Coiby Xu <coxu@redhat.com>
Date:   Fri Sep 23 22:16:49 2022 +0800

    Stop dracut 35network-manager from running nm-initrd-generator

    kexec-tools depends on dracut's 35network-manager module which will
    call nm-initrd-generator. We don't want nm-initrd-generator to generate
    connection profiles since we  will copy them from 1st kernel to
    kdump kernel initramfs. NetworkManager >= 1.35.2 won't generate connection
    profiles if there's a connection dir with rd.neednet. For Fedora/RHEL,
    this connection dir is /etc/NetworkManager/system-connections. For the
    details, please refer to the NetworkManager commit 79885656d3
    ("initrd: don't add a connection if there's a connection dir with
    rd.neednet") [1]. Before the release of NetworkManager >= 1.35.2, we
    need to mask /usr/libexec/nm-initrd-generator.

    [1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1010

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Coiby Xu
214e9d0bef Apply the timeout configuration of nm-initrd-generator
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit 6b586a9036
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Sep 22 22:08:43 2022 +0800

    Apply the timeout configuration of nm-initrd-generator

    nm-wait-online-initrd.service installed by dracut's 35-networkmanager
    module calls nm-online with "-s" which means it returns immediately when
    NetworkManager logs "startup complete" after certain timeouts are
    reached. "startup complete" doesn't necessarily network connectivity has
    been established. nm-initrd-generator has a set of timeouts that in most
    of cases when applied, "startup-complete" means network connectivity has
    been established. So apply it when setting up kdump network.

    Suggested-by: Thomas Haller <thaller@redhat.com>
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Coiby Xu
668875e186 Determine whether IPv4 or IPv6 is needed
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit 9dfcacf72d
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Sep 8 17:06:19 2022 +0800

    Determine whether IPv4 or IPv6 is needed

    According to `man nm-online`,
      "By default, connections have the ipv4.may-fail and
      ipv6.may-fail properties set to yes; this means that
      NetworkManager waits for one of the two address families to
      complete configuration before considering the connection
      activated. If you need a specific address family configured
      before network-online.target is reached, set the corresponding
      may-fail property to no."

    If a NIC has an IPv4 or IPv6 address, set the corresponding may-fail
    property to no. Otherwise, dumping vmcore over IPv6 could fail because
    only IPv4 network is ready or vice versa.

    Also disable IPv6 if only IPv4 is used and vice versa.

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Coiby Xu
94f8eed573 Add functions to copy NetworkManage connection profiles to the initramfs
Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit d25b1ee31c
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Sep 9 11:35:52 2021 +0800

    Add functions to copy NetworkManage connection profiles to the initramfs

    Each network interface is manged by a NM connection. Given a list of
    network interface names, copy the NetworkManager (NM) connection
    profiles i.e. .nmconnection files to the kdump initramfs.

    Before copying a connection file, clone it to automatically convert a
    legacy ifcfg-*[1] file to a .nmconnection file and for the convenience of
    editing the connection profile.

    [1] https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifcfg_rh

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Coiby Xu
ec669a8e8b Fix error for vlan over team network interface
Related: bz2076416
Upstream: Fedora
Conflict: None

commit b7e58619d1
Author: Coiby Xu <coxu@redhat.com>
Date:   Mon Sep 13 22:13:44 2021 +0800

    Fix error for vlan over team network interface

    6f9235887f ("module-setup.sh: enable
    vlan on team interface") skips establishing teaming network by mistake.
    Although it could use one of slave netifs to establish connection
    to transfer vmcore to remote fs, it breaks the implicit assumption of
    creating an identical network topology to the 1st kernel.

    Fixes: 6f92358 ("module-setup.sh: enable vlan on team interface")
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2022-11-23 09:42:18 +08:00
Tao Liu
10e0a513a4 Add dependency of dracut lvmthinpool-monitor module
upstream: fedora
resolves: bz2083475
conflict: Yes, use "grep -q <<< $(cmd)" instead of
          "cmd | grep -q", because the latter will
          fail with strange reason.

commit f11721077a
Author: Tao Liu <ltao@redhat.com>
Date:   Sat Oct 8 15:41:41 2022 +0800

    Add dependency of dracut lvmthinpool-monitor module

    The 80lvmthinpool-monitor module is needed for monitor and
    autoextend the size of thin pool in 2nd kernel. The module was
    integrated in dracut version 057.

    If lvmthinpool-monitor module is not found, we will print a warning.
    Because we don't want to block the kdump process when the thin pool
    capacity is enough and no monitor-and-autoextend actually needed.

    Signed-off-by: Tao Liu <ltao@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2022-11-11 11:49:32 +08:00
Tao Liu
dcaec956e8 virtiofs support for kexec-tools
upstream: fedora
resolves: bz2085347
conflict: yes, small conflict due to patch
          "kdumpctl: drop DUMP_TARGET variable" not
          backported to rhel9.

commit c743881ae6
Author: Tao Liu <ltao@redhat.com>
Date:   Fri Sep 23 18:13:11 2022 +0800

    virtiofs support for kexec-tools

    This patch add virtiofs support for kexec-tools by introducing a new option
    for /etc/kdump.conf:

    virtiofs myfs

    Where myfs is a variable tag name specified in qemu cmdline
    "-device vhost-user-fs-pci,tag=myfs".

    The patch covers the following cases:
    1) Dumping VM's vmcore to a virtiofs shared directory;
    2) When the VM's rootfs is a virtiofs shared directory and dumping the
       VM's vmcore to its subdirectory, such as /var/crash;
    3) The combination of case 1 & 2: The VM's rootfs is a virtiofs shared
       directory and dumping the VM's vmcore to another virtiofs shared
       directory.

    Case 2 & 3 need dracut >= 057, otherwise VM cannot boot from virtiofs
    shared rootfs. But it is not the issue of kexec-tools.

    Reviewed-by: Philipp Rudo <prudo@redhat.com>
    Signed-off-by: Tao Liu <ltao@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2022-10-26 10:24:57 +08:00
Pingfan Liu
5ac720fc20 ppc64/ppc64le: drop cpu online rule in 40-redhat.rules in kdump initramfs
Resolves: bz2023165
Upstream: Fedora
Conflict: None

commit a3c1e70fc1c0e4bab4149f617cbd629e89bd5ca0 (HEAD -> main)
Author: Pingfan Liu <piliu@redhat.com>
Date:   Wed Dec 8 10:46:38 2021 +0800

    ppc64/ppc64le: drop cpu online rule in 40-redhat.rules in kdump initramfs

    Onlining secondary cpus breaks kdump completely on KVM on Power hosts
    Though we use maxcpus=1 by default but 40-redhat.rules will bring up all
    possible cpus by default.

    Thus before we get the kernel fix and the systemd rule fix let's remove
    the cpu rule in 40-redhat.rules for ppc64/ppc64le kdump initramfs.

    This is back ported from RHEL, and original credit goes to Dave Young
    <dyoung@redhat.com>

    Signed-off-by: Pingfan Liu <piliu@redhat.com>

Signed-off-by: Pingfan Liu <piliu@redhat.com>
2021-12-29 11:21:42 +08:00
Tao Liu
6a373dffde fix broken extra_bins when installing multiple binaries
upstream: fedora
resolves: bz2003832
conflict: none

commit 6936fbc1b2
Author: Coiby Xu <coxu@redhat.com>
Date:   Mon Nov 1 14:13:16 2021 +0800

    fix broken extra_bins when installing multiple binaries

    When there more than one binaries, quoting "$val" would make
    dracut-install treat multiple binaries as one binary. Take
    "extra_bins /usr/sbin/ping /usr/sbin/ip" as an example, the
    following error would occur when building initrd,

    dracut-install: ERROR: installing '/usr/sbin/ping /usr/sbin/ip'
    dracut: FAILED: /usr/lib/dracut/dracut-install -D /var/tmp/dracut.ODrioZ/initramfs -a /usr/sbin/ping /usr/sbin/ip

    Fix it by not quoting the variable and bypassing SC2086 shellcheck.

    Fixes: commit 86538ca6e2
           ("bash scripts: fix variable quoting issue")

    Acked-by: Tao Liu <ltao@redhat.com>
    Signed-off-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-10 10:27:18 +08:00
Tao Liu
c9f583baa4 kdump-lib.sh: rework nmcli related functions
upstream: fedora
resolves: bz2003832
conflict: none

commit 58d3e6db3a
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 15:20:42 2021 +0800

    kdump-lib.sh: rework nmcli related functions

    This fixes word splitting issue with nmcli args. Current kexec-tools
    scripts won't call nmcli with correct arguments when there are space in
    network interface name.

    nmcli expects multiple parameters, but get_nmcli_value_by_field only
    accepts two params and depends on shell word splitting to split the
    _nm_show_cmd into multiple params, which is very fragile.
    So switch the param order, simplified this function and now multiple
    params can be used properly.

    And get_nmcli_connection_show_cmd_by_ifname returns multiple
    nmcli params in a single variable, it depend on shell word splitting to
    split the words when calling nmcli. But this is very fragile and break
    easily when there are any special character in the connection path.

    This function is only introduced to get and cache the nmcli command
    which contains the "connection name".

    Actually only cache the "connection path" is enough. Callers should
    just call get_nmcli_connection_apath_by_ifname to cache the path, and
    a new helper get_nmcli_field_by_conpath is introduced here to get value
    from nmcli. This way "connection path" can contain any character.

    Also get rid of another nmcli_cmd usage in
    get_nmcli_connection_apath_by_ifname which stores multiple params in a
    single bash variable separated by space.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:53:00 +08:00
Tao Liu
039c1d4dc8 dracut-kdump.sh: Use stat instead of ls to get vmcore size
upstream: fedora
resolves: bz2003832
conflict: none

commit b1c794a2cf
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Sep 14 03:00:48 2021 +0800

    dracut-kdump.sh: Use stat instead of ls to get vmcore size

    ls output is fragile, so use stat instead.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:46:04 +08:00
Tao Liu
13a24c49ab Merge kdump-error-handler.sh into kdump.sh
upstream: fedora
resolves: bz2003832
conflict: none

commit e7118d1de8
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Aug 2 00:50:22 2021 +0800

    Merge kdump-error-handler.sh into kdump.sh

    kdump-error-handler.sh does nothing except calling three functions,
    it can be easily merged into kdump.sh by using a parameter to run the
    error handling routine.

    kdump-lib-initramfs.sh was created to hold the three shared functions
    and related code, so by merging these two files, kdump-lib-initramfs.sh
    can be simplified by a lot.

    Following up commits will clean up kdump-lib-initramfs.sh.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:45:31 +08:00
Tao Liu
35519c3eca kdump-lib-initramfs.sh: prepare to be a POSIX compatible lib
upstream: fedora
resolves: bz2003832
conflict: none

commit a5faa052d4
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Sep 14 03:25:46 2021 +0800

    kdump-lib-initramfs.sh: prepare to be a POSIX compatible lib

    Move all functions needed in the second kernel from kdump-lib.sh
    to kdump-lib-initramfs.sh, and update shebang headers.

    Now, kdump-lib-initramfs.sh is an independent lib script, no longer
    depend on kdump-lib.sh, and kdump-lib.sh is no longer needed for
    the second kernel.

    In later commits, functions in kdump-lib-initramfs.sh will be reworked
    to be POSIX compatible, kdump-lib.sh will contain bash only functions.

    POSIX shell have very limited features, eg. `local` keyword doesn't
    exist in POSIX but we rely on that heavily. So kdump-lib.sh will
    use bash syntax and contain the most complex helper and codes.

    kdump-lib-initramfs.sh will contain the minimum set of helpers,
    and be shared by both the first and second kernel.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:45:15 +08:00
Tao Liu
b494b7f193 bash scripts: reformat with shfmt
upstream: fedora
resolves: bz2003832
conflict:
    function load_kdump_kernel_key() not exist in rhel9,
    so related patch hunk is removed.

commit 0e4b66b1ab
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Sep 14 02:25:40 2021 +0800

    bash scripts: reformat with shfmt

    This is a batch update done with:
    shfmt -s -w mkfadumprd mkdumprd kdumpctl *-module-setup.sh

    Clean up code style and reduce code base size, no behaviour change.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:42:45 +08:00
Tao Liu
63308480fc bash scripts: declare and assign separately
upstream: fedora
resolves: bz2003832
conflict: none

commit 4f75e16700
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 18 02:04:45 2021 +0800

    bash scripts: declare and assign separately

    Declare and assign separately to avoid masking return values:
    https://github.com/koalaman/shellcheck/wiki/SC2155

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:37:15 +08:00
Tao Liu
f6d6b60a6a bash scripts: fix redundant exit code check
upstream: fedora
resolves: bz2003832
conflict: none

commit a4648fc851
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 17:23:16 2021 +0800

    bash scripts: fix redundant exit code check

    As suggested by:
    https://github.com/koalaman/shellcheck/wiki/SC2181

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:35:45 +08:00
Tao Liu
bf4667b866 bash scripts: fix variable quoting issue
upstream: fedora
resolves: bz2003832
conflict:
    function remove_kdump_kernel_key() not presented in rhel9,
    so related patch hunk are removed.

commit 86538ca6e2
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 17:21:41 2021 +0800

    bash scripts: fix variable quoting issue

    Fixed quoting issues found by shellcheck, no feature
    change. This should fix many errors when there is space
    in any shell variables, eg. dump target's name/path/id.

    False positives are marked with "# shellcheck disable=SCXXXX", for
    example, args are expected to split so it should not be quoted.

    And replaced some `cut -d ' ' -fX` with `awk '{print $X}'` since cut
    is fragile, and doesn't work well with any quoted strings that have
    redundant space.

    Following quoting related issues are fixed (check the link
    for example code and what could go wrong):

    https://github.com/koalaman/shellcheck/wiki/SC2046
    https://github.com/koalaman/shellcheck/wiki/SC2053
    https://github.com/koalaman/shellcheck/wiki/SC2068
    https://github.com/koalaman/shellcheck/wiki/SC2086
    https://github.com/koalaman/shellcheck/wiki/SC2206

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:27:55 +08:00
Tao Liu
c373a2c582 Don't use die in dracut-module-setup.sh
upstream: fedora
resolves: bz2003832
conflict: none

commit 8b4b7bf808
Author: Coiby Xu <coxu@redhat.com>
Date:   Fri Mar 26 10:22:09 2021 +0800

    Don't use die in dracut-module-setup.sh

    die (in dracut-lib.sh) is supposed to be used in the initramfs environment.

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:22:55 +08:00
Tao Liu
dcb59c30d5 bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
upstream: fedora
resolves: bz2003832
conflict:
    function load_kdump_kernel_key() not presented in rhel9,
    so related patch hunk are removed.

commit 70978c00e5
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 17:20:51 2021 +0800

    bash scripts: replace '[ ]' with '[[ ]]' for bash scripts

    kdumpctl, mkdumprd, *-module-setup.sh only target bash, since they
    only run in first kernel and depend on dracut, and dracut depends
    on bash. So use '[[ ]]' to replace '[ ]'.

    This is a batch update done with following command:
    `sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdumpctl, mkdumprd, *-module-setup.sh`
    and replaced [ ... -a ... ] with [[ ... ]] && [[ ... ]] manually.

    See https://tldp.org/LDP/abs/html/testconstructs.html for more details
    on '[[ ]]', it's more versatile, safer, and slightly faster than '[ ]'.

    This will also help shfmt to clean up the code in later commits.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:13:59 +08:00
Tao Liu
98e1935293 Don't iterate the whole /sys/devices just to find drm device
upstream: fedora
resolves: bz2003832
conflict: none

commit c6021648f1
Author: Kairui Song <kasong@redhat.com>
Date:   Fri Mar 19 18:21:11 2021 +0800

    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>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 20:48:26 +08:00
Tao Liu
16c2821171 bash scripts: use $(...) notation instead of legacy ...
upstream: fedora
resolves: bz2003832
conflict: none

commit 54cc5c44be
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 01:48:52 2021 +0800

    bash scripts: use $(...) notation instead of legacy `...`

    This is a batch update done with following command:

    `sed -i -e 's/`\([^`]*\)`/\$(\1)/g' mkfadumprd mkdumprd \
     kdumpctl dracut-module-setup.sh dracut-fadump-module-setup.sh \
     dracut-early-kdump-module-setup.sh`

    And manually converted some corner cases. This fixes
    all related issues detected by shellcheck.
    Make it easier to do clean up in later commits.

    Check following link for reasons to switch to the new syntax:
    https://github.com/koalaman/shellcheck/wiki/SC2006

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 20:39:50 +08:00
Tao Liu
67611bba2a bash scripts: always use "read -r"
upstream: fedora
resolves: bz2003832
conflict: none

commit a416930706
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 15:50:30 2021 +0800

    bash scripts: always use "read -r"

    This helps to strip spaces and avoid mangling backslashes:

    https://github.com/koalaman/shellcheck/wiki/SC2162

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 20:39:17 +08:00
Tao Liu
d07b20d718 bash scripts: get rid of unnecessary sed calls
upstream: fedora
resolves: bz2003832
conflict: none

commit fdfad3102e
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 15:46:27 2021 +0800

    bash scripts: get rid of unnecessary sed calls

    Use bash builtin string substitution instead, as suggested by:
    https://github.com/koalaman/shellcheck/wiki/SC2001

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 20:39:09 +08:00
Tao Liu
480de7c63d bash scripts: get rid of expr and let
upstream: fedora
resolves: bz2003832
conflict: none

commit c4d85142be
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 15:18:59 2021 +0800

    bash scripts: get rid of expr and let

    As suggested by:
    https://github.com/koalaman/shellcheck/wiki/SC2219

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 20:39:02 +08:00
Tao Liu
e07098aa14 bash scripts: remove useless cat
upstream: fedora
resolves: bz2003832
conflict:
    load_kdump_kernel_key() didn't present in rhel9,
    so removed the patch for it.

commit 6d45257cc1
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 15:14:00 2021 +0800

    bash scripts: remove useless cat

    Some `cat` calls are useless, remove them to make it cleaner.
    See: https://github.com/koalaman/shellcheck/wiki/SC2002

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 20:38:55 +08:00
Tao Liu
6d930905d5 dracut-module-setup.sh: remove surrounding $() for subshell
upstream: fedora
resolves: bz2003832
conflict: none

commit 3b0157197b
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 15:15:44 2021 +0800

    dracut-module-setup.sh: remove surrounding $() for subshell

    Some functions are executed in subshell to avoid variable environment
    pollution. But the surrounding $() is not needed, and it may lead to
    executing output which is unexpected here.

    See: https://github.com/koalaman/shellcheck/wiki/SC2091

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Suggested-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:15:26 +08:00
Tao Liu
9abf44a082 dracut-module-setup.sh: make iscsi check fail early if cd failed
upstream: fedora
resolves: bz2003832
conflict: none

commit 67e559a6b9
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 16:29:55 2021 +0800

    dracut-module-setup.sh: make iscsi check fail early if cd failed

    As suggested by:
    https://github.com/koalaman/shellcheck/wiki/SC2164

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:15:06 +08:00
Tao Liu
72c3befcb8 dracut-module-setup.sh: fix a loop over ls issue
upstream: fedora
resolves: bz2003832
conflict: none

commit 3b2fa982bb
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 16:16:44 2021 +0800

    dracut-module-setup.sh: fix a loop over ls issue

    Iterating over ls output is fragile:
    https://github.com/koalaman/shellcheck/wiki/SC2045

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:14:44 +08:00
Tao Liu
057e505536 dracut-module-setup.sh: fix a ambiguous variable reference
upstream: fedora
resolves: bz2003832
conflict: none

commit dfe7555323
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 15:51:34 2021 +0800

    dracut-module-setup.sh: fix a ambiguous variable reference

    Wrap the variable with {...}, else it may get interpreted as array due
    to the '[' char next to it.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:14:24 +08:00
Tao Liu
c8faddc4f8 dracut-module-setup.sh: use "*" to expend array as string
upstream: fedora
resolves: bz2003832
conflict: none

commit da3ad9cbda
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 15:47:43 2021 +0800

    dracut-module-setup.sh: use "*" to expend array as string

    As suggested by:
    https://github.com/koalaman/shellcheck/wiki/SC2199
    The array is not quoted here but implicitly concatenate still happens,
    could be harmless but shellcheck complains about it so fix it.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:14:08 +08:00
Tao Liu
c0cbd45726 dracut-module-setup.sh: fix _bondoptions wrong references
upstream: fedora
resolves: bz2003832
conflict: none

commit 49dd4fcdbb
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 15:41:10 2021 +0800

    dracut-module-setup.sh: fix _bondoptions wrong references

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:13:55 +08:00
Tao Liu
3fb4383a9c dracut-module-setup.sh: remove an unused variable
upstream: fedora
resolves: bz2003832
conflict: none

commit ba7aa447b2
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 14:29:10 2021 +0800

    dracut-module-setup.sh: remove an unused variable

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:13:40 +08:00
Tao Liu
37b61ee43a dracut-module-setup.sh: rework kdump_get_ip_route_field
upstream: fedora
resolves: bz2003832
conflict: none

commit 46542ccda5
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 02:59:43 2021 +0800

    dracut-module-setup.sh: rework kdump_get_ip_route_field

    Avoid duplicated echo / cut / grep call, just use sed.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:13:28 +08:00
Tao Liu
14205c1d6f kdump-lib.sh: add a config value retrive helper
upstream: fedora
resolves: bz2003832
conflict: none

commit 09ccf88405
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Aug 16 23:25:14 2021 +0800

    kdump-lib.sh: add a config value retrive helper
    Add a helper kdump_get_conf_val to replace get_option_value.

    It can help cover more corner cases in the code, like when there are
    multiple spaces in config file, config value separated by a tab,
    heading spaces, or trailing comments.

    And this uses "sed group command" and "sed hold buffer", make it much
    faster than previous `grep <config> | tail -1`.

    This helper is supposed to provide a universal way for kexec-tools
    scripts to read in config value. Currently, different scripts are
    reading the config in many different fragile ways.

    For example, following codes are found in kexec-tools script code base:
      1. grep ^force_rebuild $KDUMP_CONFIG_FILE
	 echo $_force_rebuild | cut -d' '  -f2

      2. grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\  -f2

      3. awk '/^sshkey/ {print $2}' $conf_file

      4. grep ^path $KDUMP_CONFIG_FILE | cut -d' '  -f2-

    1, 2, and 4 will fail if the space is replaced by, e.g. a tab

    1 and 2 might fail if there are multiple spaces between config name
    and config value:
    "kdump_post  /var/crash/scripts/kdump-post.sh"
    A space will be read instead of config value.

    1, 2, 3 will fail if there are space in file path, like:
    "kdump_post /var/crash/scripts dir/kdump-post.sh"

    4 will fail if there are trailing comments:
    "path /var/crash # some comment here"

    And all will fail if there are heading space,
    " path /var/crash"

    And all will most likely cause problems if the config file contains
    the same option more than once.

    And all of them are slower than the new sed call. Old get_option_value
    is also very slow and doesn't handle heading space.

    Although we never claim to support heading space or tailing comments
    before, it's harmless to be more robust on config reading, and many
    conf files in /etc support heading spaces. And have a faster and
    safer config reading helper makes it easier to clean up the code.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:08:50 +08:00
Tao Liu
67b8dd1cb8 kdump-lib.sh: add a config format and read helper
upstream: fedora
resolves: bz2003832
conflict: none

commit a0282ab22c
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Aug 3 19:49:51 2021 +0800

    kdump-lib.sh: add a config format and read helper

    Add a helper `kdump_read_conf` to replace read_strip_comments.
    `kdump_read_conf` does a few more things:

      - remove trailing spaces.
      - format the content, remove duplicated spaces between name and value.
      - read from KDUMP_CONFIG_FILE (/etc/kdump.conf) directly, avoid pasting
	"/etc/kdump.conf" path everywhere in the code.
      - check if config file exists, just in case.

    Also unify the environmental variable, now KDUMP_CONFIG_FILE stands for
    the default config location.

    This helps avoid some shell pitfalls about spaces when reading config.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-03 16:08:22 +08:00
Coiby Xu
d4de3e9dcc Check the existence of /sys/bus/ccwgroup/devices/*/online beforehand
Resolves: bz1982474
Upstream: Fedora
Conflict: None

commit b2bbb54d89
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Jul 15 09:18:33 2021 +0800

    Check the existence of /sys/bus/ccwgroup/devices/*/online beforehand

    On s390x KVM machines, the following errors would show when building kdump
    initramfs that dumps vmcore to a remote target,
        $ kdumpctl rebuild
        /usr/lib/dracut/modules.d/99kdumpbase/module-setup.sh: line 475: /sys/bus/ccwgroup/devices/online: No such file or directory
        /usr/lib/dracut/modules.d/99kdumpbase/module-setup.sh: line 476: [: -ne: unary operator expected

    This happens because s390x KVM machines use virtual network and
    /sys/bus/ccwgroup/devices/ exists but is empty. Fix it by check
    the existence of file "/sys/bus/ccwgroup/devices/*/online".

    Fixes: commit 7d47251568
           ("Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet")

    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1982474
    Reported-by: Jie Li <jieli@redhat.com>
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2021-07-21 17:24:50 +08:00
Kairui Song
96a3fc1ac8 fadump: isolate fadump initramfs image within the default one
Resolves: bz1924115
Conflict: None
Upstream: Fedora

commit fa9201b240 (devel)
Author: Hari Bathini <hbathini@linux.ibm.com>
Date:   Wed Jun 23 20:06:48 2021 +0530

    fadump: isolate fadump initramfs image within the default one

    In case of fadump, the initramfs image has to be built to boot into
    the production environment as well as to offload the active crash dump
    to the specified dump target (for boot after crash). As the same image
    would be used for both boot scenarios, it could not be built optimally
    while accommodating both cases.

    Use --include to include the initramfs image built for offloading
    active crash dump to the specified dump target. Also, introduce a new
    out-of-tree dracut module (99zz-fadumpinit) that installs a customized
    init program while moving the default /init to /init.dracut. This
    customized init program is leveraged to isolate fadump image within
    the default initramfs image by kicking off default boot process
    (exec /init.dracut) for regular boot scenario and activating fadump
    initramfs image, if the system is booting after a crash.

    If squash is available, ensure default initramfs image is also built
    with squash module to reduce memory consumption in capture kernel.

    Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-07-20 15:43:11 +08:00
Coiby Xu
e45a51c995 fix format issue in find_online_znet_device
Related: bz1977543
Upstream: Fedora
Conflict: None

commit ad6f60d70d
Author: Coiby Xu <coxu@redhat.com>
Date:   Mon Jun 28 18:37:11 2021 +0800

    fix format issue in find_online_znet_device

    Change spaces to tab to fix alignment issue.

    Fixes: commit 7d47251568
           ("Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet")
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2021-06-30 10:26:28 +08:00
Coiby Xu
3b4df2455b check the existence of /sys/bus/ccwgroup/devices before trying to find online network device
Resolves: bz1977543
Upstream: Fedora
Conflict: None

commit 03f9b91351
Author: Coiby Xu <coxu@redhat.com>
Date:   Mon Jun 28 18:37:10 2021 +0800

    check the existence of /sys/bus/ccwgroup/devices before trying to find online network device

    /sys/bus/ccwgroup/devices doesn't exist for non-s390x machines which leads to
    the warning "find: '/sys/bus/ccwgroup/devices': No such file or directory".
    This warning can be eliminated by checking the existence of
    "/sys/bus/ccwgroup/devices" beforehand.

    Fixes: commit 7d47251568
           ("Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet")

    Reported-by: Ruowen Qin <ruqin@redhat.com>
    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1974618
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2021-06-30 10:10:37 +08:00
Coiby Xu
f0ecf8fef1 Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet
Resolves: bz1941905
Upstream: Fedora
Conflict: None

commit 7d47251568
Author: Coiby Xu <coxu@redhat.com>
Date:   Mon Jun 7 07:26:03 2021 +0800

    Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet

    This patch fixes bz1941106 and bz1941905 which passed empty rd.znet to the
    kernel command line in the following cases,
     - The IBM (Z15) KVM guest uses virtio for all devices including network
       device, so there is no znet device for IBM KVM guest. So we can't
       assume a s390x machine always has a znet device.
     - When a bridged network is used, kexec-tools tries to obtain the znet
       configuration from the ifcfg script of the bridged network rather than
       from the ifcfg script of znet device.

    We can iterate /sys/bus/ccwgroup/devices to tell if there if there is
    a znet network device. By getting an ifname from znet, we can also avoid
    mistaking the slave netdev as a znet network device in a bridged network
    or bonded network.

    Note: This patch also assumes there is only one znet device as commit
    7148c0a30d ("add s390x netdev setup")
    which greatly simplifies the code. According to IBM [1], there could be
    more than znet devices for a z/VM system and a z/VM system may have a
    non-znet network device like ConnectX. Since kdump_setup_znet was
    introduced in 2012 and so far there is no known customer complaint that
    invalidates this assumption I think it's safe to assume an IBM z/VM
    system only has one znet device. Besides, there is no z/VM system found
    on beaker to test the alternative scenarios.

    [1] https://bugzilla.redhat.com/show_bug.cgi?id=1941905#c13

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
2021-06-08 13:27:04 +08:00
Kairui Song
06aa5b897f Remove the kdump error handler isolation wrapper
Resolves: bz1901024
Upstream: Fedora
Conflict: None

commit a2306346bc
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Apr 26 17:09:56 2021 +0800

    Remove the kdump error handler isolation wrapper

    The wrapper is introduced in commit 002337c, according to the commit
    message, the only usage of the wrapper is when dracut-initqueue calls
    "systemctl start emergency" directly. In that case, emergency
    is started, but not in a isolation mode, which means dracut-initqueue
    is still running. On the other hand, emergency will call
    "systemctl start 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.

    In previous commit we added initqueue status detect in dump_to_rootfs,
    so now even without the wrapper, it will not hang.

    And actually, previously, with the wrapper, emergency might still hang
    for like 30s. When dracut called emergency service because initqueue
    timed out, dump_to_rootfs will try start initqueue again and timeout
    again. Now with the wrapper removed, we can avoid these two kinds of
    hangs, bacause without the isolation we can detect initqueue service
    status correctly in such case.

    Also remove the invalid header comments in service file, the service
    is not part of systemd code. And sync the service spec with dracut.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-06-04 14:29:28 +08:00
Kairui Song
de11ebc0b7 Revert "Always set vm.zone_reclaim_mode = 3 in kdump kernel"
Resolves: bz1896247
Upstream: fedora
Conflict: none

commit ee160bf04d
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Apr 19 23:00:10 2021 +0800

    Revert "Always set vm.zone_reclaim_mode = 3 in kdump kernel"

    This reverts commit 5633e83318.

    vm.zone_reclaim_mode may cause trashing on some machines. And after
    second thought, vm.zone_reclaim_mode is barely helpful for machines
    with high mem stress, so just revert it.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Pingfan Liu <piliu@redhat.com>

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-05-18 17:19:10 +08:00