civodul pushed a commit to branch main
in repository shepherd.

commit a3a80a7092caf31bf8b5c70db7126e569e6a8d00
Author: Ludovic Courtès <l...@gnu.org>
AuthorDate: Sun Dec 22 19:51:14 2024 +0100

    service: Call ‘reboot’ when ‘reboot-kexec’ fails.
    
    Previously, running “reboot -k” without first loading a kernel image
    would just hang after all the services have been stopped.
    
    * modules/shepherd/service.scm (root-service) <kexec>: Catch exception
    from ‘reboot-kexec’ and call ‘reboot’ in that case.
---
 modules/shepherd/service.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 23cccd2..8114e2a 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -2778,7 +2778,15 @@ Clients such as 'herd' can read it and format it in a 
human-readable way."
           (cut stop-service root-service)
           (lambda (key)
             (local-output (l10n "Rebooting with kexec..."))
-            (reboot-kexec)))))
+            (catch 'system-error
+              reboot-kexec
+              (lambda args
+                ;; It might be that kexec is unsupported or that no image had
+                ;; been loaded with 'kexec_file_load'.  At any rate, it's too
+                ;; late to roll back, so reboot normally.
+                (local-output (l10n "Failed to reboot with kexec: ~a")
+                              (strerror (system-error-errno args)))
+                (reboot)))))))
 
      ;; Evaluate arbitrary code.
      (load

Reply via email to