Commit Graph

72 Commits

Author SHA1 Message Date
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 9a937b5e22 kdump-lib.sh: use kdump_get_conf_val to read config values
upstream: fedora
resolves: bz2003832
conflict: none

commit ab1ef78aa2
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 01:18:48 2021 +0800

    kdump-lib.sh: use kdump_get_conf_val to read config values

    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:09:16 +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
Kairui Song abb0c38b7f kdump-lib.sh: kdump_get_arch_recommend_size uses crashkernel.default
Resolves: bz1986281
Conflict: None
Upstream: Fedora

commit 7b7ddaba88
Author: Kairui Song <kasong@redhat.com>
Date:   Fri Jul 2 01:31:26 2021 +0800

    kdump-lib.sh: kdump_get_arch_recommend_size uses crashkernel.default

    The new `crashkernel.default` file in kernel package can be used as the
    ck_cmdline source.

    Also keep the legacy code so old kernel packages will still work.

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

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-07-30 15:22:14 +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
Kairui Song 80c1913e4a Revert "kdump-lib.sh: Remove is_atomic"
Resolves: bz1974638
Upstream: Fedora
Conflict: None

commit 017903c3c4
Author: Kairui Song <kasong@redhat.com>
Date:   Fri Jun 25 03:42:19 2021 +0800

    Revert "kdump-lib.sh: Remove is_atomic"

    Now we need this helper again, for `reset-crashkernel`

    This reverts commit ff46cfb19e.

    Signed-off-by: Kairui Song <kasong@redhat.com>
    Acked-by: Baoquan He <bhe@redhat.com>

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-07-08 15:40:44 +08:00
Pingfan Liu 8ce1f3c1df kdump-lib.sh: fix a warning in prepare_kdump_bootinfo()
Resolves: bz1968374
Upstream: Fedora
Conflict: None

commit 39a642b66b
Author: Hari Bathini <hbathini@linux.ibm.com>
Date:   Tue Jun 1 16:46:58 2021 +0530

    kdump-lib.sh: fix a warning in prepare_kdump_bootinfo()

    Fix the warning observed when KDUMP_KERNELVER is specified:

      kdumpctl[10926]: /lib/kdump/kdump-lib.sh: line 697: [: missing `]'

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

Signed-off-by: Pingfan Liu <piliu@redhat.com>
2021-06-25 11:39:31 +08:00
Tao Liu 5f4c5f9819 Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not writable
Resolves: bz1965952
Upstream: Fedora
Conflict: None

commit 75bdcb7399
Author: Kelvin Fan <kfan@redhat.com>
Date:   Fri Apr 16 22:31:13 2021 +0000

    Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not writable

    The `/boot` directory on some operating systems might be read-only.
    If we cannot write to `$KDUMP_BOOTDIR` when generating the kdump
    initrd, attempt to place the generated initrd at `/var/lib/kdump`
    instead.

    Signed-off by: Kelvin Fan <kelvinfan001@gmail.com>
    Acked-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-06-23 09:34:40 +08:00
Pingfan Liu 73929fc549 kdump-lib.sh: fix the case if no enough total RAM for kdump in get_recommend_size()
Resolves: bz1952342
Upstream: Fedora
Conflict: None

commit 45377836b0
Author: Pingfan Liu <piliu@redhat.com>
Date:   Tue May 25 09:26:09 2021 +0800

    kdump-lib.sh: fix the case if no enough total RAM for kdump in get_recommend_size()

    For crashkernel=auto policy, if total RAM size is under a throttle,
    there is no memory reserved for kdump.

    Also correct a trivial bug by correcting the arch name.

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

Signed-off-by: Pingfan Liu <piliu@redhat.com>
2021-05-25 10:36:01 +08:00
Kairui Song a9fda5c885 kdumpctl: Add kdumpctl estimate
Resolves: bz1951415
Upstream: fedora
Conflict: none

commit e9e6a2c745
Author: Kairui Song <kasong@redhat.com>
Date:   Thu Apr 22 03:27:10 2021 +0800

    kdumpctl: Add kdumpctl estimate

    Add a rough esitimation support, currently, following memory usage are
    checked by this sub command:

    - System RAM
    - Kdump Initramfs size
    - Kdump Kernel image size
    - Kdump Kernel module size
    - Kdump userspace user and other runtime allocated memory (currently
      simply using a fixed value: 64M)
    - LUKS encryption memory usage

    The output of kdumpctl estimate looks like this:
      # kdumpctl estimate
      Reserved crashkernel:    256M
      Recommanded crashkernel: 160M

      Kernel image size:   47M
      Kernel modules size: 12M
      Initramfs size:      19M
      Runtime reservation: 64M
      Large modules:
          xfs: 1892352
          nouveau: 2318336

    And if the kdump target is encrypted:
      # kdumpctl estimate
      Encrypted kdump target requires extra memory, assuming using the keyslot with minimun memory requirement

      Reserved crashkernel:    256M
      Recommanded crashkernel: 655M

      Kernel image size:   47M
      Kernel modules size: 12M
      Initramfs size:      19M
      Runtime reservation: 64M
      LUKS required size:  512M
      Large modules:
          xfs: 1892352
          nouveau: 2318336
      WARNING: Current crashkernel size is lower than recommanded size 655M.

    The "Recommanded" value is calculated based on memory usages mentioned
    above, and will be adjusted accodingly to be no less than the value provided
    by kdump_get_arch_recommend_size.

    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-20 16:08:16 +08:00
Kairui Song 8387b514f1 kdump-lib.sh: introduce a helper to get all crypt dev used by kdump
Resolves: bz1951415
Upstream: fedora
Conflict: None

commit 1c70cf51c7
Author: Kairui Song <kasong@redhat.com>
Date:   Tue May 18 16:13:16 2021 +0800

    kdump-lib.sh: introduce a helper to get all crypt dev used by kdump

    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-20 16:08:05 +08:00
Kairui Song ccdd4f2894 kdump-lib.sh: introduce a helper to get underlying crypt device
Resolves: bz1951415
Upstream: fedora
Conflict: None

commit 3423bbc17f
Author: Kairui Song <kasong@redhat.com>
Date:   Thu Apr 8 01:36:49 2021 +0800

    kdump-lib.sh: introduce a helper to get underlying crypt device

    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-20 16:07:37 +08:00
Coiby Xu b15a090483 Add helper to get nmcli connection show cmd by ifname
Resolves: bz1919052
Upstream: Fedora
Conflict: None

commit 0c292f49c7
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Apr 1 15:32:10 2021 +0800

    Add helper to get nmcli connection show cmd by ifname

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

Signed-off-by: Coiby Xu <coxu@redhat.com>
2021-05-14 06:14:14 +00:00
Coiby Xu 2f9fc88963 Add helper to get nmcli connection apath by ifname
Resolves: bz1919052
Upstream: Fedora
Conflict: None

commit c69578ca43
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Apr 1 15:32:09 2021 +0800

    Add helper to get nmcli connection apath by ifname

    apath (a D-Bus active connection path) is used for nmcli connection operations, e.g.
      $ nmcli connection show $apath

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

Signed-off-by: Coiby Xu <coxu@redhat.com>
2021-05-14 06:14:14 +00:00
Coiby Xu d09dc2f45e Add helper to get value by field using "nmcli --get-values"
Resolves: bz1919052
Upstream: Fedora
Conflict: None

commit 10c309b5f7
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Apr 1 15:32:08 2021 +0800

    Add helper to get value by field using "nmcli --get-values"

    nmcli --get-values <field> connection show /org/freedesktop/NetworkManager/ActiveConnection/1
    returns the following value for the corresponding field respectively,
      Field                                  Value
      IP4.DNS                                "10.19.42.41 | 10.11.5.19 | 10.5.30.160"
      802-3-ethernet.s390-subchannels        ""
      bond.options                           "mode=balance-rr"

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

Signed-off-by: Coiby Xu <coxu@redhat.com>
2021-05-14 06:14:14 +00:00
Pingfan Liu 540d33a082 kdump-lib.sh: introduce functions to return recommened mem size
Resolves: bz1892558
Upstream: Fedora
Conflict: None

commit 18131894b6
Author: Pingfan Liu <piliu@redhat.com>
Date:   Thu Feb 4 09:45:36 2021 +0800

    kdump-lib.sh: introduce functions to return recommened mem size

    There is requirement to decide the recommended memory size for the current
    system. And the algorithm is based on /proc/iomem, so it can align with the
    algorithm used by reserve_crashkernel() in kernel.

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

Signed-off-by: Pingfan Liu <piliu@redhat.com>
2021-04-27 10:20:25 +08:00
DistroBaker 624a6443ca Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/kexec-tools.git#33108ef524ff033295711f888ce2c67d457951aa
2021-01-22 08:12:00 +00:00
DistroBaker a1014067b4 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/kexec-tools.git#d5e39c9f7b721b80d2aa1afa85c38754a5be074e
2020-11-30 11:50:38 +00:00
DistroBaker 17a51515f0 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/kexec-tools.git#4f492cf73ea11ff74f5b062e18fcea45cb5e7eeb
2020-11-20 12:35:49 +00:00
DistroBaker 5cac7c3f96 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/kexec-tools.git#bfd06661e81465d077bac435c90b4082134adf19
2020-11-05 05:34:29 +00:00
Petr Šabata f5bf4978d8 RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/kexec-tools#041ba89902961b5490a7143d9596dc00d732cba0
2020-10-15 14:45:57 +02:00