[systemd-devel] The best way to execute kexec via dbus

Tomáš Hnyk tomashnyk at gmail.com
Fri Aug 26 00:59:45 UTC 2022


Hello,I am trying to be able to reboot with kexec from a GUI (I am 
modifying this: https://github.com/varlesh/org.kde.plasma.compact-shutdown 
). As far as I can tell, I need to use qdbus. Via command line, I can 
successfully reboot with kexec with:
systemctl start kexec.target --job-mode=replace-irreversibly --no-block

When I remove the --noblock parameter, the kexed reboot fails and normal 
reboot is performed. If I read the docs ( 
https://www.freedesktop.org/wiki/Software/systemd/dbus/ ) correctly, I 
cannot start a unit with no-block via D-Bus. Is that a bug or a feature? 
And can I somehow get around it? I am now using this:
qdbus --system org.freedesktop.systemd1 /org/freedesktop/systemd1 
org.freedesktop.systemd1.Manager.StartUnit kexec.target 
replace-irreversibly


Which results in attempt at kexec that fails.


I could call:
  qdbus --system org.freedesktop.login1 /org/freedesktop/login1 
org.freedesktop.login1.Manager.RebootWithFlags 2


but since /sys/kernel/kexec_loaded by default is 0, the command above only 
works if I first run:
kexec -l /boot/vmlinuz --initrd=/boot/initrd.img --reuse-cmdline

But this feels like reinventing the wheel, because systemd already knows 
how to load the kernel if I just call "systemctl kexec".

Am I missing something or there is no easy way to do kexec via qdbus?

Kind regards,
Tomas



More information about the systemd-devel mailing list