RFC: Reboot behavior for kexec-tools package

2023-09-22 Thread Khalid Aziz

Hello,

I implemented automatic kexec reboot support to kexec-tools package many 
years ago when Debian used init. It worked well except for some corner 
cases. To support this, I also added a package config option to enable 
kexec reboots on reboot command. Since Debian started using systemd, 
automatic kexec reboot had been hit or miss depending upon the changes 
in systemd. I got it back to working state by requiring users to do 
kexec reboots using "systemctl kexec". Now Debian has switched to 
systemd fully and I am removing init scripts from kexec-tools package. 
Systemd maintainers made a change to systemctl command around 2021 that 
caused "systemctl kexec" to no longer work the same way again. In short, 
systemctl now has taken over the task of loading a kexec kernel which 
was previously delegated to systemd service provided by kexec-tools. 
systemctl loads kexec'able kernel only on the systems that support boot 
loader spec which Debian does not. Now kexec-tools package no longer has 
working automatic kexec reboot.


To solve this problem in a reliable and consistent way, I am considering 
changing the way kexec reboots are handled by kexec-tools package. 
Current behavior (when it worked) is:


- If config option "Should kexec-tools handle reboots?" is set to true, 
a reboot command will cause a kexec reboot.
- With config option "Should kexec-tools handle reboots?" set to true, a 
cold reboot requires using the command "coldreboot" which is a script 
installed by kexec-tools package.


I want to change the behavior to:

- No package config option to do automatic kexec reboot.
- "reboot" command causes a cold reboot
- Use "kexec-reboot" command to do a kexec reboot. "kexec-reboot" is a 
script installed by kexec-tools package.
- kexec-tools package no longer provides coldreboot script which is no 
longer necessary.


Any comments/feedback? I intend to proceed with implementing new 
behavior next week after Wednesday unless there are objections or other 
ideas.


Thanks,
Khalid



Re: RFC: Reboot behavior for kexec-tools package

2023-09-22 Thread Khalid Aziz

On 9/22/23 2:01 PM, Luca Boccassi wrote:

On Fri, 22 Sept 2023 at 20:41, Khalid Aziz  wrote:


Any comments/feedback? I intend to proceed with implementing new
behavior next week after Wednesday unless there are objections or other
ideas.


Hi,

In the next version of systemd, due in trixie in a couple of months,
we are going to move the kexec-if-loaded behaviour from systemctl to
logind itself. Also, we are going to integrate it with the new
soft-reboot feature, so that it also automatically soft-reboots if a
new rootfs has been loaded. So I would recommend to do no automation
at all in kexec-tools, and let systemd handle it, so that it can be
integrated with other reboot types and so on. Thanks.


Hi Luca,

I am planning to include a new script in kexec-tools package which will 
be installed as /sbin/kexec-load-kernel. This script uses 
/etc/default/kexec to determine which kexec kernel to load and loads it 
ready for kexec reboot. My plan was to also include a kexec-reboot 
script which simply does "/sbin/kexec-load-kernel; /usr/bin/systemctl 
kexec". Neither of those automates kexec reboots but I can leave the 
kexec-reboot script out if that works better with upcoming systemd 
changes. kexec-load-kernel just makes the task of loading a kexec image 
more user-friendly. Opinion?


Thanks,
Khalid



Re: RFC: Reboot behavior for kexec-tools package

2023-09-22 Thread Khalid Aziz

On 9/22/23 4:26 PM, Michael Biebl wrote:

Am 22.09.23 um 21:40 schrieb Khalid Aziz:


I want to change the behavior to:

- No package config option to do automatic kexec reboot.
- "reboot" command causes a cold reboot
- Use "kexec-reboot" command to do a kexec reboot. "kexec-reboot" is a 
script installed by kexec-tools package.
- kexec-tools package no longer provides coldreboot script which is no 
longer necessary.


Any comments/feedback? I intend to proceed with implementing new 
behavior next week after Wednesday unless there are objections or 
other ideas.



I assume you are aware of https://github.com/systemd/systemd/issues/15029 ?


Hello Michael,

Thanks for pointing that out. Yes, I have seen it and I have been 
working on finding a working solution for Debian. The kexec image loader 
in systemctl works with systems that create a boot loader spec file 
which Debian doesn't. In the absence of boot loader spec file, you get 
that message. The script I am adding, kexec-load-kernel, allows 
systemctl kexec to work if one runs this script before calling systemctl 
kexec.


Since we have more automation coming to systemd in trixie, I am going to 
limit kexec-tools package to providing only helper scripts to load a 
kernel and call systemctl kexec. Hopefully we will have a working 
reliable solution with that in place.


Thanks,
Khalid