Re: The best way to execute kexec via dbus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 26. August 2022, 06:55:15 (+02:00), Andrei Borzenkov wrote:

> On 26.08.2022 03:59, Tomáš Hnyk wrote:
> > 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.
>
> There should be no difference between the two. Both do exactly the same
> D-Bus call. Debug logs in both cases would be interesting.
>
Indeed, it must have been the late night, they are the same. However, the following are not the same even the man page says they are:

sudo systemctl kexec # results in kexec

full log here: https://hastebin.com/gubivumaha.apache

srp 26 10:38:08 GreenOne systemd[1]: Reached target System Shutdown.
srp 26 10:38:08 GreenOne systemd[1]: Reached target Late Shutdown Services.
srp 26 10:38:08 GreenOne systemd[1]: Starting Reboot via kexec...
srp 26 10:38:08 GreenOne systemd[1]: Shutting down.
srp 26 10:38:08 GreenOne systemd-shutdown[1]: Syncing filesystems and block devices.
srp 26 10:38:08 GreenOne systemd-shutdown[1]: Sending SIGTERM to remaining processes...
srp 26 10:38:08 GreenOne systemd-journald[416]: Journal stopped


sudo systemctl start kexec.target --job-mode=replace-irreversibly --no-block # failed attempted kexec

full log here: https://hastebin.com/ruzunihepe.apache
 
srp 26 10:39:04 GreenOne systemd[1]: Starting Unload nvidia modesetting modules from kernel POTREBUJE NVIDIA PRO KEXEC...
srp 26 10:39:04 GreenOne kernel: [drm] [nvidia-drm] [GPU ID 0x00000100] Unloading driver
srp 26 10:39:04 GreenOne systemd[1]: lvm2-monitor.service: Deactivated successfully.
srp 26 10:39:04 GreenOne systemd[1]: Stopped Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling.
srp 26 10:39:04 GreenOne systemd[1]: Reached target System Shutdown.
srp 26 10:39:04 GreenOne systemd[1]: Reached target Late Shutdown Services.
srp 26 10:39:04 GreenOne systemd[1]: Starting Reboot via kexec...
srp 26 10:39:04 GreenOne systemctl[2041]: No kexec kernel loaded and autodetection failed.
srp 26 10:39:04 GreenOne systemctl[2041]: Cannot automatically load kernel: ESP mount point not found.
srp 26 10:39:04 GreenOne systemctl[2041]: Failed to load kexec kernel, continuing without.
srp 26 10:39:04 GreenOne systemd[1]: Shutting down.
srp 26 10:39:04 GreenOne systemd-shutdown[1]: Syncing filesystems and block devices.
srp 26 10:39:04 GreenOne systemd-shutdown[1]: Sending SIGTERM to remaining processes...
srp 26 10:39:04 GreenOne systemd-journald[419]: Journal stopped

Note that "Unload nvidia modesetting modules from kernel POTREBUJE NVIDIA PRO KEXEC..." is a systemd unit as per https://wiki.archlinux.org/title/kexec#No_kernel_mode-setting_(Nvidia) that is needed on my system to achieve kexec and which is WantedBy=kexec.target


I get almost the same results with the following:

qdbus --system org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager.StartUnit kexec.target replace-irreversibly # failed attempted kexec

 (for testing purposes, I got a polkit policy that allows my user to start systemd units, which I guess is not great security-wise)
full log here: https://hastebin.com/onesohuwik.apache

srp 26 10:39:57 GreenOne systemd[1]: Starting Unload nvidia modesetting modules from kernel POTREBUJE NVIDIA PRO KEXEC...
srp 26 10:39:57 GreenOne kernel: [drm] [nvidia-drm] [GPU ID 0x00000100] Unloading driver
srp 26 10:39:57 GreenOne systemd[1]: lvm2-monitor.service: Deactivated successfully.
srp 26 10:39:57 GreenOne systemd[1]: Stopped Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling.
srp 26 10:39:57 GreenOne systemd[1]: Reached target System Shutdown.
srp 26 10:39:57 GreenOne systemd[1]: Reached target Late Shutdown Services.
srp 26 10:39:57 GreenOne systemd[1]: Starting Reboot via kexec...
srp 26 10:39:57 GreenOne systemctl[1979]: No kexec kernel loaded and autodetection failed.
srp 26 10:39:57 GreenOne systemctl[1979]: Cannot automatically load kernel: ESP mount point not found.
srp 26 10:39:57 GreenOne systemctl[1979]: Failed to load kexec kernel, continuing without.
srp 26 10:39:57 GreenOne systemd[1]: Shutting down.
srp 26 10:39:57 GreenOne kernel: nvidia-modeset: Unloading
srp 26 10:39:57 GreenOne systemd-shutdown[1]: Syncing filesystems and block devices.
srp 26 10:39:57 GreenOne systemd-shutdown[1]: Sending SIGTERM to remaining processes...
srp 26 10:39:57 GreenOne systemd-journald[422]: Journal stopped

(the only difference here is that nvidia is actualy unloaded, it does not seem relevant to me, so I think these cases are identical)

> > 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
> >
>
> This method ends up doing exactly the same - it starts special
> kexec.target which calls "systemctl --force kexec". And *this*
> "sytsemctl kexec" invocation should (try to) load kexec kernel.

However, once it fails and once it does not:

dbus --system org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.RebootWithFlags 2 #seems to not even attempt kexec

full log here: https://hastebin.com/unuqijoguj.apache

srp 26 10:40:28 GreenOne systemd[1]: Reached target System Shutdown.
srp 26 10:40:28 GreenOne systemd[1]: Reached target Late Shutdown Services.
srp 26 10:40:28 GreenOne systemd[1]: systemd-reboot.service: Deactivated successfully.
srp 26 10:40:28 GreenOne systemd[1]: Finished System Reboot.
srp 26 10:40:28 GreenOne systemd[1]: Reached target System Reboot.
srp 26 10:40:28 GreenOne systemd[1]: Shutting down.
srp 26 10:40:28 GreenOne systemd-shutdown[1]: Syncing filesystems and block devices.
srp 26 10:40:28 GreenOne systemd-shutdown[1]: Sending SIGTERM to remaining processes...
srp 26 10:40:28 GreenOne systemd-journald[426]: Journal stopped

however, if I do:

sudo kexec -l /boot/vmlinuz --initrd=/boot/initrd.img --reuse-cmdline
qdbus --system org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.RebootWithFlags 2 #sucessful kexec

full log here: https://hastebin.com/ucamubofij.apache

srp 26 10:41:24 GreenOne systemd[1]: Reached target System Shutdown.
srp 26 10:41:24 GreenOne systemd[1]: Reached target Late Shutdown Services.
srp 26 10:41:24 GreenOne systemd[1]: Starting Reboot via kexec...
srp 26 10:41:24 GreenOne systemd[1]: Shutting down.
srp 26 10:41:25 GreenOne systemd-shutdown[1]: Syncing filesystems and block devices.
srp 26 10:41:25 GreenOne systemd-shutdown[1]: Sending SIGTERM to remaining processes...
srp 26 10:41:25 GreenOne systemd-journald[426]: Journal stopped


So, to sum it up, "systemctl kexec" works, starting kexec.target manually does not work either through systemctl or qdbus and RebootWithFlags only works when I manually load the kexec kernel - which mysteriously "systemctl kexec" manages to do too.

I am on Kubuntu 22.04, booting with systemd-boot (which is like 10 times faster than grub, 4s vs half a second or something, thanks!) following this https://blobfolio.com/2018/replace-grub2-with-systemd-boot-on-ubuntu-18-04/
I have these:
DefaultTimeoutStartSec=1s
DefaultTimeoutStopSec=1s
DefaultStartLimitIntervalSec=500ms
in /etc/systemd/system.conf (without them, rebooting sometimes took ages, I can try without if it would make a difference). All the tests above were done from the console (after reaching multi-user.target).

Any idea what is going on?

I am not sure if I can provide more detailed logs, I would be glad to if told how to do that.

Kind regards,
Tomas





[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux