Hi Bhupesh,
Thanks for raising up the topic.
On 05/12/20 at 12:21am, Bhupesh Sharma wrote:
> Hi All,
>
> Dave and I talked a bit last week about having a service for
> kexec/kexec-load similar to what we have for kdump right now in
> RHEL/Fedora (/usr/lib/systemd/system/kdump.service).
> My plan is to enable it first in Fedora and then in RHEL-8.
>
> Now, similar two services 'kexec-load.service' and 'kexec.service'
> also exist in other distribution(s) like Suse (see:
>
<
https://documentation.suse.com/sles/15-SP1/html/SLES-all/cha-tuning-kexec...
> for example). I talked to a Suse guy privately today on IRC and he
> mentioned the following steps they use on Suse to run kexec:
>
> To use Kexec, ensure the respective service is enabled and running:
> > sudo systemctl enable kexec-load.service
> > sudo systemctl start kexec-load.service
>
> > systemctl kexec (try rebooting into a new Kernel with Kexec)
>
> On our RHEL kexec-tools, we also seem to have a left-over 'kexec'
> service, but it seems broken currently. See some logs from my arm64
> board below:
> [root@cav-sabre-cn99xx-01 ~]# systemctl kexec
> Failed to open "/boot/efi/loader/loader.conf": No such file or directory
> Failed to read boot config from "/boot/efi/loader/loader.conf": No
> such file or directory
> Failed to load bootspec config from "/boot/efi/loader": No such file
> or directory
It seems work fine on my x86 legacy vm.
Actually we do not need to use systemctl kexec, just run "reboot" it
will go to kexec path automatically.
>
> So, I am thinking to having two services (similar to Suse) for Fedora
> and RHEL as well:
> - One for kexec-load (i.e. kexec -l or kexec -l -s),
> - Second for kexec'ing into 2nd kernel (i.e. kexec -e).
The second one is up to systemd and installed by default so if we have
any bugs just open to systemd then.
>
> I wanted to get more opinions from the team about this (having 2
> services or 1, naming etc), before I send the first Fedora patch for
> review
> Here is some RFC code I have added so far:
>
> For the 1st RFC, I am thinking of having a simple service like (it
> actually executes a new executable '/usr/sbin/kexecctl') :
>
> /usr/lib/systemd/system/kexec-load.service
> ------------------------------------------------------------
> [Unit]
> Description=loads the kernel
> Documentation=man:kexec(8)
> DefaultDependencies=no
> Before=shutdown.target umount.target final.target
>
> [Service]
> Type=oneshot
> ExecStart=/usr/sbin/kexecctl
"kexectl"? and maybe also need some "start" "stop"
"restart" "reload" etc
>
> [Install]
> WantedBy=kexec.target
The default behavior of systemctl kexec is
* run kexec reboot in case kexec kernel loaded
* otherwise just go to physical reboot
So it is not strictly blocked by us:
https://lists.freedesktop.org/archives/systemd-devel/2012-March/004764.html
But there are above discussion we can refer to.
>
> A simple implementation of ''/usr/sbin/kexecctl' looks like this (we
> can add further details as we go further):
>
> /usr/sbin/kexecctl:
> -------------------------
>
> standard_kexec_args="-l"
It would be good to use a sysconfig like kdump so that people can tune
the args easily, eg.
/etc/sysconfig/kexec
> load_kexec()
> {
> KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}")
>
> if [ "$KEXEC_FILE_LOAD" == "on" ]; then
> echo "Using kexec file based syscall."
> KEXEC_ARGS="$KEXEC_ARGS -s"
> fi
>
> $KEXEC $KEXEC_ARGS $standard_kexec_args \
> --initrd=$TARGET_INITRD $kdump_kernel
> if [ $? == 0 ]; then
> echo "kexec: loaded kexec kernel"
> return 0
> else
> echo "kexec: failed to load kexec kernel" >&2
> if [ "$KEXEC_FILE_LOAD" == "on" ]; then
> echo "kexec_file_load() failed, please try kexec_load()"
>&2
> fi
> return 1
> fi
> }
>
> Please help me by sharing your comments.
>
> Thanks,
> Bhupesh
>
Thanks
Dave