Hi, All
Now upon failure kdump script might not be called at all and it might not be able to execute default action. It results in a hang.
Because we disable emergency shell and rely on kdump.sh being invoked through dracut-pre-pivot hook. But it might happen that we never call into dracut-pre-pivot hook because certain systemd targets could not reach due to failure in their dependencies. In those cases error handling code does not run and system hangs.
To solve this problem, we need to separate the error handling code from dracut-pre-pivot hook, and every time when a failure shows up, the separated code can be called by the emergency service.
By default systemd provides an emergency service which will drop us into shell every time upon a critical failure. It's very convenient for us to re-use the framework of systemd emergency, because we don't have to touch the other parts of systemd. We can use our own script instead of the default one.
This new scheme will overwrite emergency shell and replace with kdump error handling code. And this code will do the error handling as needed. Now, we will not rely on dracut-pre-pivot hook running always. Instead whenever error happens and it is serious enough that emergency shell needed to run, now kdump error handler will run.
This patchset introduce a new kdump emergency service. It will override the existing emergency.service. When fatal error occurs, this emergency service will be triggered and systemd will isolate to emergency path.
This kdump emergency service can will read kdump.conf and act according to the configired "default action" (reboot/poweroff/halt/shell/dump_to_rootfs).
Along with this patchset, kdump-capture.service is introduced as a service unit to run kdump.sh. When kdump-capture.service fails, systemd will isolate to kdump emergency service. I copied all the dependencies from dracut-pre-pivot.service to kdump-capture.service so that kdump.sh will be called at the correct time window.
v2: Address several comments from Vivek: - split [patch 1] into 1/6 and 2/6 - remove several unnecessary lines in service unit. - modify the description of kdump-capture.service - introduce another kdump lib kdump-lib-2.sh used in 2nd kernel.
V3: Address several comments from Vivek: - update description of [PATCH 1/5] and [PATCH 5/5] - separate the patch of cleanup to kdump-lib-initramfs.sh
V4: Address several comments from Vivek and Dave: - meld the original [PATCH 3/5] into [PATCH 1/5] - add GPL license for kdump-error-handler.service and kdump-capture.service - separate the "x-initrd.mount" and "mount under /sysroot" patch to another patchset
WANG Chao (2): Introduce kdump error handling service Introduce kdump capture service
dracut-kdump-capture.service | 30 ++++++++++++++++++++++++++++++ dracut-kdump-emergency.service | 30 ++++++++++++++++++++++++++++++ dracut-kdump-error-handler.sh | 10 ++++++++++ dracut-kdump.sh | 9 ++------- dracut-module-setup.sh | 7 ++++++- kdump-lib-initramfs.sh | 34 ++++++++++++++++++++++++++++++---- kexec-tools.spec | 7 ++++++- 7 files changed, 114 insertions(+), 13 deletions(-) create mode 100644 dracut-kdump-capture.service create mode 100644 dracut-kdump-emergency.service create mode 100755 dracut-kdump-error-handler.sh