On 04/04/2014 10:59 AM, Dave Young wrote:
On 04/03/14 at 04:20pm, Hari Bathini wrote:
> On 04/01/2014 03:28 PM, Dave Young wrote:
>> On 02/27/14 at 01:51pm, Hari Bathini wrote:
>>> Take a backup of original initrd when fadump is used first time or
>>> when user has switched from kdump to fadump. This will allow us to
>>> fall back to original initrd when kdump service fails to rebuild
>>> the fadump ready default initrd. Also, if the user switches from
>>> fadump to kdump, then the original initrd will be restored when
>>> kdump script is run first time after the switch.
>>>
>>> Signed-off-by: Mahesh Salgaonkar<mahesh(a)linux.vnet.ibm.com>
>>> Signed-off-by: Hari Bathini<hbathini(a)linux.vnet.ibm.com>
>>> ---
>>> kdumpctl | 102
++++++++++++++++++++++++++++++++++++++++++++++++++------------
>>> 1 file changed, 83 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/kdumpctl b/kdumpctl
>>> index bbc2779..2eb52a5 100755
>>> --- a/kdumpctl
>>> +++ b/kdumpctl
>>> @@ -15,6 +15,7 @@
FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered"
>>> . /lib/kdump/kdump-lib.sh
>>> standard_kexec_args="-p"
>>> +declare -i image_time
>>> if [ -f /etc/sysconfig/kdump ]; then
>>> . /etc/sysconfig/kdump
>>> @@ -31,12 +32,25 @@ determine_dump_mode()
>>> # kdump shall be the default dump mode
>>> dump_mode="kdump"
>>> + if [ -z "$KDUMP_KERNELVER" ]; then
>>> + kdump_kver=`uname -r`
>>> + else
>>> + kdump_kver=$KDUMP_KERNELVER
>>> + fi
>>> +
>>> + default_initrd="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}.img"
>>> + kdump_initrd="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img"
>>> + default_initrd_bak="$default_initrd.default.bak"
>>> +
>>> # Check if firmware-assisted dump is enabled
>>> # if yes, set the dump mode as fadump
>>> if is_fadump_capable; then
>>> echo "Using dump mode fadump"
>>> dump_mode="fadump"
>>> fi
>>> +
>>> + # Handle dump mode switch from kdump to fadump OR fadump to kdump
>>> + handle_dump_mode_switch
>>> }
>>> # remove_cmdline_param <kernel cmdline> <param1>
[<param2>] ... [<paramN>]
>>> @@ -83,6 +97,10 @@ function save_core()
>>> function rebuild_initrd()
>>> {
>>> + if [ $dump_mode == "fadump" ]; then
>>> + backup_default_initrd
>>> + fi
>>> +
>>> $MKDUMPRD $kdump_initrd $kdump_kver
>>> if [ $? != 0 ]; then
>>> echo "mkdumprd: failed to make kdump initrd" >&2
>>> @@ -112,6 +130,61 @@ function check_executable()
>>> done
>>> }
>>> +backup_default_initrd()
>>> +{
>>> + # Check if backup initrd is already present. If not, then
>>> + # this is the first time fadump is being used OR user
>>> + # has switched from kdump to fadump.
>>> + # Take a backup of the original default initrd before
>>> + # we rebuild default initrd for fadump support.
>>> + if [ ! -e $default_initrd_bak ];then
>>> + echo "Backing up default initrd"
>>> + cp $default_initrd $default_initrd_bak
>>> + sync
>>> + fi
>>> +}
>>> +
>>> +handle_dump_mode_switch()
>>> +{
>>> + if [ $dump_mode == "fadump" ]; then
>>> + if [ -e $kdump_initrd ];then
>>> + # This means user has switched from kdump to fadump.
>>> + # Remove kdump initrd which is no longer needed
>>> + rm -f $kdump_initrd
>>> + fi
>>> + else
>>> + if [ -e $default_initrd_bak ];then
>>> + # !fadump and original initrd backup file exists.
>>> + # This means user has switched from fadump to kdump.
>>> + # Restore the original default initrd.
>>> + mv $default_initrd_bak $default_initrd
>>> + sync
>>> + fi
>>> + fi
>>> +}
>>> +
>>> +find_initrd_image_time()
>>> +{
>>> + image_time=0
>>> +
>>> + # Check to see if dependent files have been modified
>>> + # since last build of the image file
>>> + if [ $dump_mode == "fadump" ]; then
>>> + # If this is the 1st time we are using fadump then let image_time be
>>> + # zero to force rebuild initrd. The non-existance of backup initrd
>>> + # means this is the 1st time fadump is being used. If it exists then
>>> + # return the image time of default initrd.
>>> + if [ -e $default_initrd_bak ]; then
>>> + image_time=`stat -c "%Y" $default_initrd 2>/dev/null`
>>> + fi
>>> + else
>>> + if [ -f $kdump_initrd ]; then
>>> + image_time=`stat -c "%Y" $kdump_initrd 2>/dev/null`
>>> + return
>>> + fi
>>> + fi
>>> +}
>>> +
>>> function check_config()
>>> {
>>> local nr
>>> @@ -171,14 +244,7 @@ function check_rebuild()
>>> local extra_modules modified_files=""
>>> local _force_rebuild force_rebuild="0"
>>> - if [ -z "$KDUMP_KERNELVER" ]; then
>>> - kdump_kver=`uname -r`
>>> - else
>>> - kdump_kver=$KDUMP_KERNELVER
>>> - fi
>>> -
>>>
kdump_kernel="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}"
>>> - kdump_initrd="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img"
>>> _force_rebuild=`grep ^force_rebuild $KDUMP_CONFIG_FILE 2>/dev/null`
>>> if [ $? -eq 0 ]; then
>>> @@ -193,13 +259,9 @@ function check_rebuild()
>>> extra_modules=`grep ^extra_modules $KDUMP_CONFIG_FILE`
>>> [ -n "$extra_modules" ] && force_rebuild="1"
>>> - #check to see if dependent files has been modified
>>> - #since last build of the image file
>>> - if [ -f $kdump_initrd ]; then
>>> - image_time=`stat -c "%Y" $kdump_initrd 2>/dev/null`
>>> - else
>>> - image_time=0
>>> - fi
>>> + # Find initrd image time based on whether dependent files have been
>>> + # modified since last build of the image file
>>> + find_initrd_image_time
>>> #also rebuild when cluster conf is changed and fence kdump is enabled.
>>> check_fence_kdump $image_time &&
modified_files="cluster-cib"
>>> @@ -225,12 +287,14 @@ function check_rebuild()
>>> fi
>>> done
>>> - if [ $image_time -eq 0 ]; then
>>> - echo -n "No kdump initial ramdisk found."; echo
>>> - elif [ "$force_rebuild" != "0" ]; then
>>> - echo -n "Force rebuild $kdump_initrd"; echo
>>> + if [ $dump_mode == "kdump" ]; then
>>> + if [ $image_time -eq 0 ]; then
>>> + echo -n "No kdump initial ramdisk found."; echo
>>> + elif [ "$force_rebuild" != "0" ]; then
>>> + echo -n "Force rebuild $kdump_initrd"; echo
>>> + fi
>>> elif [ -n "$modified_files" ]; then
>> The above if elif logic looks different from original ones?
> Messages are put under "kdump" dump mode if condition because:
> 1. there is no separate initial ramdisk for fadump as in the case of
> "kdump" mode..
> 2. there is a message in rebuild_fadump_initrd() that conveys the same..
For below case
[[ $dump_mode == "kdump" ]] &&
[[ $image_time -ne 0 ]] &&
[[ "$force_rebuild" == "0" ]] &&
[[ -n "$modified_files" ]]
The kdump image will not be rebuilt, right? Am I missing some thing?
oops! Right. I missed out on that.
Thanks for pointing out. Will update accordingly..
Thanks
Hari
> Thanks
> Hari
>
>>> - echo "Detected change(s) the following file(s):"
>>> + echo "Detected change(s) in the following file(s):"
>>> echo -n " "; echo "$modified_files" | sed
's/\s/\n /g'
>>> else
>>> return 0
>>>
>>> _______________________________________________
>>> kexec mailing list
>>> kexec(a)lists.fedoraproject.org
>>>
https://lists.fedoraproject.org/mailman/listinfo/kexec