Merge branch 'f37' into f36

Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2022-10-27 16:20:47 +08:00
commit 2479c8f687
6 changed files with 74 additions and 23 deletions

View File

@ -82,6 +82,8 @@ kernels to the default value is:
grubby --update-kernel ALL --args "crashkernel=$(kdumpctl get-default-crashkernel)"
NOTE: On s390x you also need to run zipl for the change to take effect.
Estimate crashkernel
====================

View File

@ -49,9 +49,16 @@ fi
single_instance_lock()
{
local rc timeout=5
local rc timeout=5 lockfile
if ! exec 9> /var/lock/kdump; then
if [[ -d /run/lock ]]; then
lockfile=/run/lock/kdump
else
# when updating package using virt-customize, /run/lock doesn't exist
lockfile=/tmp/kdump.lock
fi
if ! exec 9> $lockfile; then
derror "Create file lock failed"
exit 1
fi
@ -1354,7 +1361,7 @@ _get_current_running_kernel_path()
fi
}
_update_grub()
_update_kernel_cmdline()
{
local _kernel_path=$1 _crashkernel=$2 _dump_mode=$3 _fadump_val=$4
@ -1365,15 +1372,14 @@ _update_grub()
rpm-ostree kargs --append="crashkernel=$_crashkernel"
fi
else
[[ -f /etc/zipl.conf ]] && zipl_arg="--zipl"
grubby --args "crashkernel=$_crashkernel" --update-kernel "$_kernel_path" $zipl_arg
grubby --args "crashkernel=$_crashkernel" --update-kernel "$_kernel_path"
if [[ $_dump_mode == kdump ]]; then
grubby --remove-args="fadump" --update-kernel "$_kernel_path"
else
grubby --args="fadump=$_fadump_val" --update-kernel "$_kernel_path"
fi
fi
[[ $zipl_arg ]] && zipl > /dev/null
[[ -f /etc/zipl.conf ]] && zipl > /dev/null
}
_valid_grubby_kernel_path()
@ -1421,6 +1427,10 @@ _update_kernel_arg_in_grub_etc_default()
{
local _para=$1 _val=$2 _para_val
if [[ $(uname -m) == s390x ]]; then
return
fi
if [[ -n $_val ]]; then
_para_val="$_para=$_val"
fi
@ -1499,7 +1509,7 @@ reset_crashkernel()
_new_dump_mode=kdump
_new_crashkernel=$(kdump_get_arch_recommend_crashkernel "$_new_dump_mode")
if [[ $_old_crashkernel != "$_new_crashkernel" ]]; then
_update_grub "" "$_new_crashkernel" "$_new_dump_mode" ""
_update_kernel_cmdline "" "$_new_crashkernel" "$_new_dump_mode" ""
if [[ $_reboot == yes ]]; then
systemctl reboot
fi
@ -1567,7 +1577,7 @@ reset_crashkernel()
_old_crashkernel=$(get_grub_kernel_boot_parameter "$_kernel" crashkernel)
_old_fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump)
if [[ $_old_crashkernel != "$_new_crashkernel" || $_old_fadump_val != "$_new_fadump_val" ]]; then
_update_grub "$_kernel" "$_new_crashkernel" "$_new_dump_mode" "$_new_fadump_val"
_update_kernel_cmdline "$_kernel" "$_new_crashkernel" "$_new_dump_mode" "$_new_fadump_val"
if [[ $_reboot != yes ]]; then
if [[ $_old_crashkernel != "$_new_crashkernel" ]]; then
_what_is_updated="Updated crashkernel=$_new_crashkernel"
@ -1636,7 +1646,7 @@ reset_crashkernel_after_update()
if [[ $_crashkernel == "$_old_default_crashkernel" ]] &&
[[ $_new_default_crashkernel != "$_old_default_crashkernel" ]]; then
_fadump_val=$(get_grub_kernel_boot_parameter "$_kernel" fadump)
if _update_grub "$_kernel" "$_new_default_crashkernel" "$_dump_mode" "$_fadump_val"; then
if _update_kernel_cmdline "$_kernel" "$_new_default_crashkernel" "$_dump_mode" "$_fadump_val"; then
echo "For kernel=$_kernel, crashkernel=$_new_default_crashkernel now."
fi
fi
@ -1692,7 +1702,7 @@ reset_crashkernel_for_installed_kernel()
_fadump_val_running=$(get_grub_kernel_boot_parameter "$_kernel" fadump)
if [[ $_crashkernel != "$_crashkernel_running" ]]; then
if _update_grub "$_installed_kernel" "$_crashkernel_running" "$_dump_mode_running" "$_fadump_val_running"; then
if _update_kernel_cmdline "$_installed_kernel" "$_crashkernel_running" "$_dump_mode_running" "$_fadump_val_running"; then
echo "kexec-tools has reset $_installed_kernel to use the new default crashkernel value $_crashkernel_running"
fi
fi

View File

@ -4,8 +4,8 @@
%global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7})
Name: kexec-tools
Version: 2.0.24
Release: 4%{?dist}
Version: 2.0.25
Release: 1%{?dist}
License: GPLv2
Summary: The kexec/kdump userspace component
@ -262,13 +262,19 @@ mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
%pre
# save the old default crashkernel values to /tmp/ when upgrading the package
if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then
# Save the old default crashkernel values to /tmp/ when upgrading the package
# so kdumpctl later can tell if it should update the kernel crashkernel
# parameter in the posttrans scriptlet. Note this feauture of auto-updating
# the kernel crashkernel parameter currently doesn't support ostree, so skip it
# for ostree.
if [ ! -f /run/ostree-booted ] && [ $1 == 2 ] && grep -q get-default-crashkernel /usr/bin/kdumpctl; then
kdumpctl get-default-crashkernel kdump > /tmp/old_default_crashkernel 2>/dev/null
%ifarch ppc64 ppc64le
kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null
%endif
fi
# don't block package update
:
%post
# Initial installation
@ -336,9 +342,14 @@ do
done
%posttrans
# try to reset kernel crashkernel value to new default value when upgrading
# the package
if ! grep -qs "ostree" /proc/cmdline && [ $1 == 1 ]; then
# Try to reset kernel crashkernel value to new default value based on the old
# default value or set up crasherkernel value for osbuild
#
# Note
# 1. Skip ostree systems as they are not supported.
# 2. "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade. The
# former case is used to set up crashkernel for osbuild
if [ ! -f /run/ostree-booted ] && [ $1 == 1 ]; then
kdumpctl reset-crashkernel-after-update
rm /tmp/old_default_crashkernel 2>/dev/null
%ifarch ppc64 ppc64le
@ -405,6 +416,15 @@ fi
%endif
%changelog
* Wed Aug 03 2022 Coiby <coxu@redhat.com> - 2.0.25-1
- Update kexec-tools to 2.0.25
- remind the users to run zipl after calling grubby on s390x
- remove useless --zipl when calling grubby to update kernel command line
- skip updating /etc/default/grub for s390x
- use /run/ostree-booted to tell if scriptlet is running on OSTree system
- Allow to update kexec-tools using virt-customize for cloud base image
- KDUMP_COMMANDLINE: remove irqpoll parameter on aws aarch64 platform
* Thu Jul 21 2022 Coiby <coxu@redhat.com> - 2.0.24-4
- Checking the existence of 40-redhat.rules before modifying
- kdump-lib: Add the CoreOS kernel dir to the boot_dirlist

View File

@ -1,3 +1,3 @@
SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763
SHA512 (kexec-tools-2.0.24.tar.xz) = ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822
SHA512 (kexec-tools-2.0.25.tar.xz) = 6fd3fe11d428c5bb2ce318744146e03ddf752cc77632064bdd7418ef3ad355ad2e2db212d68a5bc73554d78f786901beb42d72bd62e2a4dae34fb224b667ec6b
SHA512 (makedumpfile-1.7.1.tar.gz) = 93e36487b71f567d3685b151459806cf36017e52bf3ee68dd448382b279a422d1a8abef72e291ccb8206f2149ccd08ba484ec0027d1caab3fa1edbc3d28c3632

View File

@ -42,7 +42,7 @@ all: $(TEST_ROOT)/output/test-base-image
# to rebuild the rpm, currently use rpmbuild to have better control over the rpm building process
#
$(KEXEC_TOOLS_RPM): $(KEXEC_TOOLS_SRC)
sh -c "cd .. && fedpkg sources"
sh -c "cd .. && fedpkg --release f$(RELEASE) sources"
@echo Rebuilding RPM due to modification of sources: $?
rpmbuild $(RPMDEFINE) -ba $(REPO)/$(SPEC)

View File

@ -23,7 +23,7 @@ is_mounted()
clean_up()
{
for _mnt in ${MNTS[@]}; do
is_mounted $_mnt && $SUDO umount -f $_mnt
is_mounted $_mnt && $SUDO umount -f -R $_mnt
done
for _dev in ${DEVS[@]}; do
@ -81,6 +81,17 @@ get_mountable_dev() {
fi
}
# get the separate boot partition
# return the 2nd partition as boot partition
get_mount_boot() {
local dev=$1 _second_part=${dev}p2
if [[ $(lsblk -f $_second_part -n -o LABEL 2> /dev/null) == boot ]]; then
echo $_second_part
fi
}
prepare_loop() {
[ -n "$(lsmod | grep "^loop")" ] && return
@ -133,7 +144,7 @@ image_lock()
# Mount a device, will umount it automatially when shell exits
mount_image() {
local image=$1 fmt
local dev mnt mnt_dev
local dev mnt mnt_dev boot root
# Lock the image just in case user run this script in parrel
image_lock $image
@ -166,12 +177,20 @@ mount_image() {
$SUDO mount $mnt_dev $mnt
[ $? -ne 0 ] && perror_exit "failed to mount device '$mnt_dev'"
boot=$(get_mount_boot "$dev")
if [[ -n "$boot" ]]; then
root=$(get_image_mount_root $image)
$SUDO mount $boot $root/boot
[ $? -ne 0 ] && perror_exit "failed to mount the bootable partition for device '$mnt_dev'"
fi
}
get_image_mount_root() {
local image=$1
local root=${MNTS[$image]}
# Starting from Fedora 36, the root node is /root/root of the last partition
[ -d "$root/root/root" ] && root=$root/root
echo $root
if [ -z "$root" ]; then
@ -213,7 +232,7 @@ run_in_image() {
inst_in_image() {
local image=$1 src=$2 dst=$3
local root=${MNTS[$image]}
local root=$(get_image_mount_root $1)
$SUDO cp $src $root/$dst
}
@ -240,7 +259,7 @@ create_image_from_base_image() {
if [ "$image_fmt" != "raw" ]; then
if fmt_is_qcow2 "$image_fmt"; then
echo "Source image is qcow2, using snapshot..."
qemu-img create -f qcow2 -b $image $output
qemu-img create -f qcow2 -b $image -F qcow2 $output
else
perror_exit "Unrecognized base image format '$image_mnt'"
fi