From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id GM5aAPaMJ2fTAwAAe85BDQ:P1 (envelope-from ) for ; Sun, 03 Nov 2024 14:47:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id GM5aAPaMJ2fTAwAAe85BDQ (envelope-from ) for ; Sun, 03 Nov 2024 15:47:18 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=KF0l41SY; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=iExh7tjE; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1730645237; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-to:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=hbQitByjXNU1SPKoefdnEoS1F/BdooOOeTPPd9izjEs=; b=bzY6UH3P0Qgfzho1+LTlIzpmMkp7TtvttfquXjGxnisZVaKCAD1EwKXnBLX1qgKoau9jwq gcr1qlGt9fMHyGEkK1sktIne6t+FSvvWCE0v11kHFsW3wSHMWWJq1wDNoQ8CTRGhUG6Ecg 0VUvUl6ERWsXZQxCJ424cOjW7HKf+5kxIKpTUeXxXQPWdiDANFWHSYCDjqSmDSsocXMIvc kghK0N97TTHOz8FtE6bOFQa6PRITG9lv4PMdCPkzxWdgt8bMnnJLIP2QigZwu/PFC1bFBW BJs4LVCxzJdEKleZBuxyNj3vtFNgVqvLbE5mBdVChp0eLSjHLCbLACcEeOGyvg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=KF0l41SY; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=iExh7tjE; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1730645237; a=rsa-sha256; cv=none; b=U1TBgwxY0aWllFsptcOXGXxX1KlGxjwUd6Ke2uJ4agDLYrlEvzUPCtPpTDgp8RGKaP6N9T WchcW2iBNwmMi8ZuqPVz8h2rwh0zuvFVsRB3ofpEtw2Gxi1hqZ8qGkp7msK0M+AG9jiH97 PZuir5t7OEDyi7v3yXRhXEOgZVCxXtWOC89vHlIFZ6EAIahWZpC5t/IFm1mubBojuQp1nP NGZ0z0DVI6RVJ8tFFKNnPhWnx7AJNEMCRGf1n0ZG+mgVDxuiP7437PU1RlbyAxeSa67SZU yjtXcOeIOs51dnPu1m9UdQryf8Lw4Qv02UPINK8Hx82tLEiaJ38yvtXSOFcVsQ== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2503B89613 for ; Sun, 03 Nov 2024 15:47:16 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7bse-00076F-6f; Sun, 03 Nov 2024 09:47:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t7bsd-00075i-6b for guix-patches@gnu.org; Sun, 03 Nov 2024 09:47:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t7bsc-0004YK-UY for guix-patches@gnu.org; Sun, 03 Nov 2024 09:47:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=hbQitByjXNU1SPKoefdnEoS1F/BdooOOeTPPd9izjEs=; b=KF0l41SY4CyPI79XNIQpQ5H+DGP81hQqyHIUvuUF+ci+57TZ/FRpYqDwasPFhYiC49QBHbd2zr1J63pu+4jGW+4gbZZBCuGSAj19rTECAYNcJTYr/Nv6ivFl6zx2YVAmNJT2+yS+kMVYbq/RDLDKw8CHCYmHJy1bQyHRi0QTev+CIz8yHYrC4Cj29ngJKufGrvAl6qD+14Bj3+irQgQbgXYIlCPpl6AM2VzmPVs0WqLWo8Q8wta54V6dCL8kM1fR83jYp0eMj0qRgKvYkoiBp0e/fYs8O1D+sAnvBeNBy+qB5jO8xKrUcJL2qh+W05CD4S3gBJGd0hJymoE6F80iCg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t7bsc-0001HM-LY for guix-patches@gnu.org; Sun, 03 Nov 2024 09:47:02 -0500 Subject: bug#73992: [Shepherd PATCH] shepherd: Add support for rebooting using kexec Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Sun, 03 Nov 2024 14:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 73992 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Jakob Kirsch Cc: 73992-done@debbugs.gnu.org Mail-Followup-To: 73992@debbugs.gnu.org, ludo@gnu.org, jakob.kirsch@web.de Received: via spool by 73992-done@debbugs.gnu.org id=D73992.17306451884857 (code D ref 73992); Sun, 03 Nov 2024 14:47:02 +0000 Received: (at 73992-done) by debbugs.gnu.org; 3 Nov 2024 14:46:28 +0000 Received: from localhost ([127.0.0.1]:60807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t7bs1-0001GD-3A for submit@debbugs.gnu.org; Sun, 03 Nov 2024 09:46:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t7brv-0001G3-LA for 73992-done@debbugs.gnu.org; Sun, 03 Nov 2024 09:46:23 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t7brp-0004RH-Sa; Sun, 03 Nov 2024 09:46:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=hbQitByjXNU1SPKoefdnEoS1F/BdooOOeTPPd9izjEs=; b=iExh7tjEouGHIhqsD3Dy jJ6Gp9LnSp03KfP3uXQXS7syTsY7EMx94/0LjTlAYicaPOjakgZxNwAI6MkJlqnUGKxT9Gk9N7v5M u5PApR8jMGBSpPUp6KZUbS34USUAD0Rx5LR7mbxtvrfrd8Lqh/vU4A5BECvTBJ6nRVARAEQSo0HGO ky1RvPqmCHcSNhFtpDj/kG2sxK43FayhCsM5TPmCSNw5KxS6XrhiIy7iwCiWzLceQXbRsWgry7/QF ZVvpMvgHCY94Yrs9NzktiisYuIycpQ+Wvnb8ceq6Uv30y6qlfihWLtR2u7z5vZSck2J/rMOZwGYKp SinaDy8ZbPuirQ==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: (Jakob Kirsch's message of "Thu, 24 Oct 2024 20:04:14 +0200") References: Date: Sun, 03 Nov 2024 15:46:10 +0100 Message-ID: <87r07sl6j1.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: 0.85 X-Spam-Score: 0.85 X-Migadu-Queue-Id: 2503B89613 X-TUID: 7nCLK4FFelGw --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Jakob, Jakob Kirsch skribis: > From 762fbee53fb890a7cf5e26abcc2dcfad03b1bab4 Mon Sep 17 00:00:00 2001 > From: Jakob Kirsch > 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 =E2=80=98devel=E2=80=99 branch after making the cosmeti= c changes below (let me know if anything is amiss). I also added a commit log that follows the project=E2=80=99s conventions. Thank you! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. =20 @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 @comman= d{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. =20 @end table =20 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=C3=A8s <= ludo@gnu.org> +;; Copyright (C) 2024 Jakob Kirsch ;; ;; 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)))) =20 (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))))) =20 (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=C3= =A8s ;; Copyright (C) 2018 Carlo Zancanaro ;; Copyright (C) 2020 Jan (janneke) Nieuwenhuizen +;; Copyright (C) 2024 Jakob Kirsch ;; ;; 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)) =20 (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 s= kipping the BIOS phase. Return #f on failure or throw an exception on non-Linux s= ystems." (if RB_KEXEC - (%libc-reboot RB_KEXEC) - (throw 'system-error 'kexec "~A" (list (strerror ENOSYS)) (list ENOSY= S)))) + (%libc-reboot RB_KEXEC) + (throw 'system-error 'kexec "~A" (list (strerror ENOSYS)) + (list ENOSYS)))) =20 (define (halt) "Halt the system. Return #f on failure." --=-=-=--