Commit Graph

67 Commits

Author SHA1 Message Date
Tao Liu 6afe4ea23f kdumpctl: use kdump_get_conf_val to read config values
upstream: fedora
resolves: bz2003832
conflict: none

commit 01613b7211
Author: Kairui Song <kasong@redhat.com>
Date:   Tue Aug 3 22:50:02 2021 +0800

    kdumpctl: use kdump_get_conf_val to read config values

    Also fixed kdumpctl, use `awk` instead of `cut` to read
    core_collector's executable name correctly when its arguments
    are not seperated 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-03 16:09:49 +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 f3db4acbcf Clear old crashkernl=auto in comment and doc
Resolves: bz1986250
Upstream: Fedora

commit 097059dedc
Author: Kairui Song <kasong@redhat.com>
Date:   Fri Jul 30 14:40:45 2021 +0800

    Clear old crashkernl=auto in comment and doc

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

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-08-06 01:33:34 +00:00
Kairui Song 6cc04b5313 kdumpctl: fix a typo
Resolves: bz1981684
Conflict: Minor conflict resolved easily
Upstream: Fedora

commit bcd8d6a47b
Author: Kairui Song <kasong@redhat.com>
Date:   Thu Jul 15 03:08:28 2021 +0800

    kdumpctl: fix a typo

    Recommanded -> Recommended

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

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-07-30 09:21:21 +00:00
Kairui Song 8e51ebe6fb fadump: kdumpctl should check the modules used by the fadump initramfs
Resolves: bz1924115
Conflict: None
Upstream: Fedora

commit bf6671b60d
Author: Kairui Song <kasong@redhat.com>
Date:   Fri Jun 25 14:44:45 2021 +0800

    fadump: kdumpctl should check the modules used by the fadump initramfs

    After fadump embedded the fadump initramfs in the normal initramfs,
    kdumpctl will mistakenly rebuild the initramfs everytime.

    kdumpctl checks the hostonly-kernel-modules.txt file in initramfs
    to check if required drivers are included, but the normal initramfs
    is built in non-hostonly mode, so it doesn't have a
    hostonly-kernel-modules.txt file. The check will always fail.

    So let mkfadumprd make a copy of the hostonly-kernel-modules.txt in the
    fadump initramfs and let kdumpctl check that file instead.

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

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-07-20 15:43:26 +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 a0fe51b32e kdumpctl: Add kdumpctl reset-crashkernel
Resolves: bz1974638
Upstream: Fedora
Conflict: None

commit 86130ec10f
Author: Kairui Song <kasong@redhat.com>
Date:   Thu Jun 10 13:06:22 2021 +0800

    kdumpctl: Add kdumpctl reset-crashkernel

    In newer kernel, crashkernel.default will contain the default
    crashkernel value of a kernel build. So introduce a new sub command
    to help user reset kernel crashkernel size to the default value.

    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:42:14 +08:00
Tao Liu ba2668b537 kdumpctl: fix check_config error when kdump.conf is empty
Resolves: bz1975632
Upstream: Fedora
Conflict: None

commit 6137956f79
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Apr 14 13:41:19 2021 +0800

    kdumpctl: fix check_config error when kdump.conf is empty

    Kdump scirpt already have default values for core_collector, path in
    many other place. Empty kdump.conf still works. Fix this corner case and
    fix the error message.

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

Signed-off-by: Tao Liu <ltao@redhat.com>
2021-06-25 12:29:40 +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
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
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 6333173003 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#fc703518525dc85b88873120f2bcf7bffa682735
2021-01-08 13:46:38 +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