all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Jakob Kirsch <jakob.kirsch@web.de>
Cc: 73992-done@debbugs.gnu.org
Subject: bug#73992: [Shepherd PATCH] shepherd: Add support for rebooting using kexec
Date: Sun, 03 Nov 2024 15:46:10 +0100	[thread overview]
Message-ID: <87r07sl6j1.fsf@gnu.org> (raw)
In-Reply-To: <ZxqMHnI0nNuvbK71@kernelpanicroom> (Jakob Kirsch's message of "Thu, 24 Oct 2024 20:04:14 +0200")

[-- Attachment #1: Type: text/plain, Size: 940 bytes --]

Hi Jakob,

Jakob Kirsch <jakob.kirsch@web.de> skribis:

> From 762fbee53fb890a7cf5e26abcc2dcfad03b1bab4 Mon Sep 17 00:00:00 2001
> From: Jakob Kirsch <jakob.kirsch@web.de>
> Date: Thu, 24 Oct 2024 19:45:31 +0200
> Subject: [PATCH v3] shepherd: Add support for rebooting using kexec
>
> ---
>  AUTHORS                             |  1 +
>  configure.ac                        |  4 ++++
>  doc/shepherd.texi                   |  9 +++++++++
>  modules/shepherd/scripts/reboot.scm | 12 ++++++++++--
>  modules/shepherd/service.scm        |  9 +++++++++
>  modules/shepherd/system.scm.in      | 10 ++++++++++
>  tests/status-sexp.sh                |  2 +-
>  7 files changed, 44 insertions(+), 3 deletions(-)

I applied it to the ‘devel’ branch after making the cosmetic changes
below (let me know if anything is amiss).  I also added a commit log
that follows the project’s conventions.

Thank you!

Ludo’.


[-- Attachment #2: Type: text/x-patch, Size: 4489 bytes --]

diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index faef6f1..b164fe8 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -516,12 +516,15 @@ Send commands to the socket special file @var{file}. If this option is
 not specified, @file{@var{localstatedir}/run/shepherd/socket} is taken.
 
 @item -k
-@itemx --do-kexec
-Reboot the system using kexec. The kernel that was previously loaded
-using @command{kexec -l @var{file}} is executed instead of rebooting
-into the BIOS in order to keep the down time to a minimum or to chainload
-another kernel. This feature is only available on Linux-based systems and will
-throw an exception on GNU/Hurd. This is also equivalent to running @command{herd kexec shepherd}.
+@itemx --kexec
+Reboot the system using Linux's kexec (this is equivalent to running
+@command{herd kexec root}).  The kernel that was previously loaded using
+the @command{kexec -l @var{file}} command is executed directly instead
+of rebooting into the BIOS, keeping the downtime to a minimum.  See the
+@uref{https://linux.die.net/man/8/kexec, @command{kexec} command
+documentation} for more information.
+
+This feature is only available on Linux-based systems.
 
 @end table
 
diff --git a/modules/shepherd/scripts/reboot.scm b/modules/shepherd/scripts/reboot.scm
index 4c2448e..0f3fc30 100644
--- a/modules/shepherd/scripts/reboot.scm
+++ b/modules/shepherd/scripts/reboot.scm
@@ -1,5 +1,6 @@
 ;; reboot.scm -- Reboot the system.
 ;; Copyright (C) 2013, 2014, 2015, 2016, 2018, 2023 Ludovic Courtès <ludo@gnu.org>
+;; Copyright (C) 2024 Jakob Kirsch <jakob.kirsch@web.de>
 ;;
 ;; This file is part of the GNU Shepherd.
 ;;
@@ -48,11 +49,11 @@
                       #:action (lambda (file)
                                  (set! socket-file file)))
                     (option
-                      #:long-name "do-kexec" #:short-name #\k
+                      #:long-name "kexec" #:short-name #\k
                       #:takes-argument? #f
                       #:description "reboot using kexec"
-                      #:action (lambda () (set! action 'kexec))
-                    ))
+                      #:action (lambda ()
+                                 (set! action 'kexec))))
 
       (set! command-args (reverse command-args))
       (with-system-error-handling
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 6a5e112..08a9df2 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -2709,13 +2709,14 @@ Clients such as 'herd' can read it and format it in a human-readable way."
             (power-off)))))
 
      (kexec
-       "Reboot the system and run kexec."
-       (lambda (running)
+      "Reboot the system and run kexec."
+      (lambda (running)
         (catch 'quit
-          (cut stop root-service)
+          (cut stop-service root-service)
           (lambda (key)
             (local-output (l10n "Rebooting with kexec..."))
             (reboot-kexec)))))
+
      ;; Evaluate arbitrary code.
      (load
       "Load the Scheme code from FILE into shepherd.  This is potentially
diff --git a/modules/shepherd/system.scm.in b/modules/shepherd/system.scm.in
index 1168c15..46f1848 100644
--- a/modules/shepherd/system.scm.in
+++ b/modules/shepherd/system.scm.in
@@ -2,6 +2,7 @@
 ;; Copyright (C) 2013-2014, 2016, 2018, 2020, 2022-2024 Ludovic Courtès <ludo@gnu.org>
 ;; Copyright (C) 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
 ;; Copyright (C) 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;; Copyright (C) 2024 Jakob Kirsch <jakob.kirsch@web.de>
 ;;
 ;; This file is part of the GNU Shepherd.
 ;;
@@ -98,12 +99,13 @@ ctrlaltdel(8) and see kernel/reboot.c in Linux."
   (%libc-reboot RB_AUTOBOOT))
 
 (define (reboot-kexec)
-  "Execute kernel loaded with 'kexec -l' now. Kexec is a feature of the
+  "Execute kernel loaded with 'kexec -l' now.  Kexec is a feature of the
 Linux kernel that allows you to instantly reboot into a new kernel while skipping
 the BIOS phase.  Return #f on failure or throw an exception on non-Linux systems."
   (if RB_KEXEC
-    (%libc-reboot RB_KEXEC)
-    (throw 'system-error 'kexec  "~A" (list (strerror ENOSYS)) (list ENOSYS))))
+      (%libc-reboot RB_KEXEC)
+      (throw 'system-error 'kexec  "~A" (list (strerror ENOSYS))
+             (list ENOSYS))))
 
 (define (halt)
   "Halt the system.  Return #f on failure."

      reply	other threads:[~2024-11-03 14:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24 18:04 [bug#73992] [Shepherd PATCH] shepherd: Add support for rebooting using kexec Jakob Kirsch via Guix-patches via
2024-11-03 14:46 ` Ludovic Courtès [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r07sl6j1.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=73992-done@debbugs.gnu.org \
    --cc=jakob.kirsch@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.