Commit Graph

296 Commits

Author SHA1 Message Date
Tao Liu
df46b8c7e7 Release 2.0.22-16
resolves: bz1982535
resolves: bz2003832
resolves: bz2014626
resolves: bz1989451

Increased release subversion for the commit message.

Fixes: commit c1406d2cab
       ("Rebuilt for IMA sigs, glibc 2.34, aarch64 flags")
The release subversion wasn't increased for this commit.

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-10 13:57:44 +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
0ebd803f45 mkdumprd: drop mountaddr/mountproto nfs mount options
upstream: fedora
resolves: bz1982535
conflict: none

commit 727251e52e
Author: Tao Liu <ltao at redhat.com>
Date:   Tue Oct 26 22:03:28 2021 +0800

    mkdumprd: drop mountaddr/mountproto nfs mount options

    nfs service will append extra mount options to kernel mount options.
    Such as mountaddr/mountproto options. These options only represent
    current mounting details of the 1st kernel, but may not appropriate
    for the 2nd kernel for the same reason as commit
    d4f04afa47 ("mkdumprd: drop some nfs
                    mount options when reading from kernel"). This patch will remove
    these options.

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

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-10 10:27:11 +08:00
Tao Liu
5f12822d8f 92-crashkernel.install: fix exit code
upstream: fedora
resolves: bz2003832
conflict: none

commit f6e6aa4551
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 1 17:38:50 2021 +0800

    92-crashkernel.install: fix exit code

    The return value of set_ck_kernel or set_grub_ck is wrongly being used
    as the exit code. This hook should exit with 0 or it may result in
    unexpected behavior of kernel-install.

    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-10 10:27:05 +08:00
Tao Liu
38f981907c dracut-early-kdump.sh: make it POSIX compatible
upstream: fedora
resolves: bz2003832
conflict: none

commit 4c39ad9a0c
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Sep 13 16:40:25 2021 +0800

    dracut-early-kdump.sh: make it POSIX compatible

    Refactor and remove bash only syntax.

    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-10 10:27:00 +08:00
Tao Liu
050f80ef36 Add header comment for POSIX compliant scripts
upstream: fedora
resolves: bz2003832
conflict: none

commit ee337c6f49
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Sep 13 03:38:14 2021 +0800

    Add header comment for POSIX compliant scripts

    To make things cleaner and more human readable, add a short comment for
    the POSIX scripts.

    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-10 10:26:54 +08:00
Tao Liu
a42769a32c mkdumprd: allow using dash
upstream: fedora
resolves: bz2003832
conflict: none

commit 4b4d045b8c
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 11 19:55:19 2021 +0800

    mkdumprd: allow using dash

    All non-POSIX syntax in second kernel are gone, tested on Fedora 34
    with latest dracut, dash now works fine.

    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-10 10:26:48 +08:00
Tao Liu
f0d3575138 kdump-logger.sh: make it POSIX compatible
upstream: fedora
resolves: bz2003832
conflict: none

commit 8cd57e5565
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 11 19:19:59 2021 +0800

    kdump-logger.sh: make it POSIX compatible

    Refactor to remove some bash only syntax.

    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-10 10:26:40 +08:00
Tao Liu
d53e0655f1 kdump-lib.sh: reformat with shfmt
upstream: fedora
resolves: bz2003832
conflict:
    Regenerated with shfmt command because of
    too much hunk patches. When comparing with the original
    patch, only patch "kdumpctl: enable secure boot on ppc64le LPARs"
    related hunks are different.

commit 4cdce1f489
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Sep 14 03:09:30 2021 +0800

    kdump-lib.sh: reformat with shfmt

    This is a batch update done with:
    shfmt -s -w kdump-lib.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-10 10:26:29 +08:00
Tao Liu
040a2e259f kdump-lib.sh: declare and assign separately
upstream: fedora
resolves: bz2003832
conflict: none

commit 20089dddd5
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 03:48:19 2021 +0800

    kdump-lib.sh: declare and assign separately

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

    Signed-off-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-10 10:26:12 +08:00
Tao Liu
653edd848c kdump-lib.sh: fix variable quoting issue
upstream: fedora
resolves: bz2003832
conflict: none

commit 4f01cb1b0a
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Sep 13 01:18:04 2021 +0800

    kdump-lib.sh: 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.

    And fixed how remove_cmdline_param is being called in prepare_cmdline.
    Kernel parameters can have space like: param="spaces in here". So currently
    remove_cmdline_param is broken since its args always get split by space.
    But prepare_cmdline is expecting remove_cmdline_param to split its args
    by space and passing a list of kernel args separated by space as a whole arg.
    So fix that by using `xargs` to parse and split the args properly, then
    call remove_cmdline_param.

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

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

    Signed-off-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-10 10:24:19 +08:00
Tao Liu
078307f19f Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel
upstream: fedora
resolves: bz2003832
conflict: none

commit f39000f524
Author: fj1508ic@fujitsu.com <fj1508ic@fujitsu.com>
Date:   Tue Jan 26 06:37:28 2021 +0000

    Remove trace_buf_size and trace_event from the kernel bootparameters of the kdump kernel

    The kdump kernel uses resources for ftrace because trace_buf_size, which
    specifies the ring buffer size for ftrace, and trace_event, which specifies
    a valid trace event, are not removed, but the kdump kernel does not require
    ftrace.

    trace_buf_size is ignored if the specified size is 0, so specify 1.

    Signed-off-by: Hisashi Nagaoka <fj1508ic@fujitsu.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-10 10:20:27 +08:00
Tao Liu
beac78b8e7 kdump-lib.sh: fix a few ambiguous or redundant code
upstream: fedora
resolves: bz2003832
conflict: none

commit 319219d23b
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Sep 13 01:17:23 2021 +0800

    kdump-lib.sh: fix a few ambiguous or redundant code

    Fix a few ambiguous syntax issues and remove some unused variables.
    Also refactor some code to make it more robust.

    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:46 +08:00
Tao Liu
d8f8b09fa0 kdump-lib.sh: fix arithmetic operation syntax
upstream: fedora
resolves: bz2003832
conflict: none

commit c0edb80b8f
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 13:31:31 2021 +0800

    kdump-lib.sh: fix arithmetic operation syntax

    Get rid of let, and remove useless '$' on arithmetic variables.

    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:37 +08:00
Tao Liu
6dbf7c2e6c kdump-lib.sh: remove useless echo and cat
upstream: fedora
resolves: bz2003832
conflict: none

commit 53813e8b9a
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 8 02:48:17 2021 +0800

    kdump-lib.sh: remove useless echo and cat

    Replace echo "$(cmd)" and "var=$(cmd); echo $var" with just `cmd`.
    And remove some useless cat.

    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:12 +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
60e5a1e7a5 kdump-lib.sh: replace '[ ]' with '[[ ]]' and get rid of legacy ``
upstream: fedora
resolves: bz2003832
conflict:
    Patch hunk modified for function is_secure_boot_enforced().

commit 30090f3a15
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Sep 13 01:17:05 2021 +0800

    kdump-lib.sh: replace '[ ]' with '[[ ]]' and get rid of legacy ``

    Updated file syntax with following command:

    sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdump-lib.sh
    (replace '[ ]' with '[[ ]]')

    sed -i -e 's/`\([^`]*\)`/\$(\1)/g' kdump-lib.sh
    (replace `...` with $(...))

    And manually updated [[ ... -a ... ]] and [[ ... -o ... ]] with && and
    ||.

    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:52:36 +08:00
Tao Liu
57daebe2f7 kdump-lib-initramfs.sh: make it POSIX compatible
upstream: fedora
resolves: bz2003832
conflict: none

commit 5debf397fe
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Sep 14 03:04:08 2021 +0800

    kdump-lib-initramfs.sh: make it POSIX compatible

    POSIX doesn't support keyword local, so add double underscore and prefix
    to variable names, and reduce variable usage, to avoid any variable name
    conflict.

    Also reformat the code with `shfmt -s -w 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:46:45 +08:00
Tao Liu
5e60aafcaf dracut-kdump.sh: reformat with shfmt
upstream: fedora
resolves: bz2003832
conflict: none

commit 7c76611abb
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Sep 15 23:10:07 2021 +0800

    dracut-kdump.sh: reformat with shfmt

    This is done with `shfmt -w -s dracut-kdump.sh`. There is 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:46:37 +08:00
Tao Liu
eb6eafaf18 dracut-kdump.sh: make it POSIX compatible
upstream: fedora
resolves: bz2003832
conflict: none

commit b1339c3b8a
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 18 21:06:52 2021 +0800

    dracut-kdump.sh: make it POSIX compatible

    POSIX doesn't support keyword `local`, so this commit reduced variable usage.
    Heredoc ("<<<") operation is also not supported, so kdump.conf is now pre-parse
    into a temp file. Also fixes many POSIX syntax errors.

    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:16 +08:00
Tao Liu
62d6f35de4 dracut-kdump.sh: POSIX doesn't support pipefail
upstream: fedora
resolves: bz2003832
conflict: none

commit 725027b735
Author: Kairui Song <kasong@redhat.com>
Date:   Thu Aug 12 02:55:32 2021 +0800

    dracut-kdump.sh: POSIX doesn't support pipefail

    Set pipefail will cause POSIX shell to exit with failure. So only do
    that in bash.

    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:10 +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
058c4321a8 dracut-kdump.sh: simplify dump_ssh
upstream: fedora
resolves: bz2003832
conflict: none

commit 7a9823b42e
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Aug 3 13:23:26 2021 +0800

    dracut-kdump.sh: simplify dump_ssh

    There is a workaround for `scp` that it expects IPv6 address to be
    quoted with [ ... ], only apply the workaround once and store the
    updated `scp` address to reuse 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-09 21:45:58 +08:00
Tao Liu
e268210244 dracut-kdump.sh: remove add_dump_code
upstream: fedora
resolves: bz2003832
conflict: none

commit 8f89e89071
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Aug 2 01:25:17 2021 +0800

    dracut-kdump.sh: remove add_dump_code

    `add_dump_code "<op>"` is just `DUMP_INSTRUCTION="<op>"`, no need a
    extra wrapper for that.

    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:52 +08:00
Tao Liu
28cf217362 dracut-kdump.sh: don't put KDUMP_SCRIPT_DIR in PATH
upstream: fedora
resolves: bz2003832
conflict: none

commit 0675edbadb
Author: Kairui Song <kasong@redhat.com>
Date:   Mon Aug 2 01:19:44 2021 +0800

    dracut-kdump.sh: don't put KDUMP_SCRIPT_DIR in PATH

    monitor_dd_progress is the only extra binary in KDUMP_SCRIPT_DIR, no
    need to change PATH environment variable, just call it directly.

    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:45 +08:00
Tao Liu
f9025ca711 kdump-lib-initramfs.sh: move dump related functions to kdump.sh
upstream: fedora
resolves: bz2003832
conflict: none

commit a1205effaa
Author: Kairui Song <kasong@redhat.com>
Date:   Thu Aug 5 00:59:29 2021 +0800

    kdump-lib-initramfs.sh: move dump related functions to kdump.sh

    These dump related functions are only used by dracut-kdump.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:39 +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
20c694278f mkdumprd: display the absolute path of dump location in the check_user_configured_target()
upstream: fedora
resolves: bz2003832
conflict: none

commit 2d9504c4a4
Author: Lianbo Jiang <lijiang@redhat.com>
Date:   Tue Jun 1 18:33:44 2021 +0800

    mkdumprd: display the absolute path of dump location in the check_user_configured_target()

    When kdump service fails, the current errors do not display the
    absolute path of dump location(marked it as "^"), for example:

    kdump: kexec: unloaded kdump kernel
    kdump: Stopping kdump: [OK]
    kdump: Detected change(s) in the following file(s):  /etc/kdump.conf
    kdump: Rebuilding /boot/initramfs-4.18.0-304.el8.x86_64kdump.img
    kdump: Dump path "/var1/crash" does not exist in dump target "UUID=c202ef45-3ac3-4adb-85e7-307a916757f0"
                      ^^^^^^^^^^^
    kdump: mkdumprd: failed to make kdump initrd
    kdump: Starting kdump: [FAILED]

    Here, it should output the absolute path of dump location with this
    format: "<mount path>/<path>". To fix it, let's extend the relative
    pathname to the absolute pathname in check_user_configured_target().

    Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 21:10:25 +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
b9cefb4161 mkdumprd: prompt the user to install nfs-utils when mounting NFS fs failed
upstream: fedora
resolves: bz2003832
conflict: none

commit e5a745ce77
Author: Coiby Xu <coxu@redhat.com>
Date:   Sat Feb 20 11:55:52 2021 +0800

    mkdumprd: prompt the user to install nfs-utils when mounting NFS fs failed

    When nfs-utils is not installed, mounting as NFS fs would fail.
    Currently, the error message is not user-friendly,
        mount: /tmp/mkdumprd.HyPGpS/target: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.
        kdump: Failed to mount on xxx for kdump preflight check.
        kdump: mkdumprd: failed to make kdump initrd

    Prompt the user to install nfs-utilsa in the error message,
        kdump: Failed to mount on xxx for kdump preflight check. Please make sure nfs-utils has been installed.

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

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 20:41:42 +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