Hi Kairui,
On 07/20/18 at 12:02am, Kairui Song wrote:
Currently, we only rebuilt kdump initramfs on config file change,
fs change, or watchdog related change. This will not cover the case
that hardware changed but fs layout and other configurations still
stays the same, and kdump may fail.
To cover such case, we can detect and compare loaded kernel modules,
if a hardware change requires the image to be rebuilt, loaded kernel
modules must have changed.
Starting from commit 7047294 dracut will record loaded kernel modules
Not sure if this commit has been merged in Fedora branch of dracut, if
not this will not work
when the image is built if hostonly mode is enabled. With this
patch,
kdumpctl will compare the recorded value with currently loaded kernel
modules, and rebuild the image on change.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdumpctl | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index 13b8209..12289fa 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -458,6 +458,29 @@ check_wdt_modified()
return 1
}
+check_kmodules_modified()
+{
+ # always sort again to avoid LANG/LC inconsistent problem
+ local _old_modules="$(lsinitrd $TARGET_INITRD -f
/usr/lib/dracut/loaded-kernel-modules.txt | sort)"
Seems you missed the comment about lsinitrd. Can you add a new patch
for getting all the files in one callback of lsinitrd?
lsinitrd is using too much time and cause kdumpctl start slowly.
+ local _new_modules="$(get_loaded_kernel_modules | sort)"
I saw your function get_loaded_kernel_modules already sorted the module
list, so do we need another |sort?
+
+ local _added_modules=$(comm -13 <(echo "$_old_modules") <(echo
"$_new_modules"))
+ local _dropped_modules=$(comm -23 <(echo "$_old_modules") <(echo
"$_new_modules"))
+
+ if [ "$_old_modules" != "$_new_modules" ]; then
+ echo "Detected change(s) of loaded kernel modules list:"
+ [[ -n $_added_modules ]] && for _module in $_added_modules; do
+ echo " +$_module"
+ done
+ [[ -n $_dropped_modules ]] && for _module in $_dropped_modules; do
+ echo " -$_module"
+ done
+ return 1
+ fi
Can the above chunk only be run when we are under some debug mode?
+
+ return 0
+}
+
# returns 0 if system is not modified
# returns 1 if system is modified
# returns 2 if system modification is invalid
@@ -485,6 +508,11 @@ check_system_modified()
return 1
fi
+ check_kmodules_modified
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+
return 0
}
--
2.17.1
_______________________________________________
kexec mailing list -- kexec(a)lists.fedoraproject.org
To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
Fedora Code of Conduct:
https://getfedora.org/code-of-conduct.html
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.o...
Thanks
Dave