[PATCH] gnu: Add kernel-module-loader-service.

DoneSubmitted by Brice Waegeneire.
Details
5 participants
  • Nicolò Balzarotti
  • Brice Waegeneire
  • Danny Milosavljevic
  • Mathieu Othacehe
  • pelzflorian (Florian Pelz)
Owner
unassigned
Severity
normal
B
B
Brice Waegeneire wrote on 28 Mar 14:59 +0100
(address . guix-patches@gnu.org)
20200328135908.2540-1-brice@waegenei.re
* doc/guix.texi (Linux Services): Add a new subsection and document thenew service and its configuration.* gnu/services/linux.scm (kernel-module-loader-service): New procedure.(kernel-module-loader-service-type, kernel-module-loader-configuration):New types.---
This patch is related to the following thread:https://lists.gnu.org/archive/html/guix-devel/2020-03/msg00381.html
doc/guix.texi | 48 ++++++++++++++++++++++++++++++++++ gnu/services/linux.scm | 58 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 105 insertions(+), 1 deletion(-)
Toggle diff (147 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 77a4b8ed71..a297ec249f 100644--- a/doc/guix.texi+++ b/doc/guix.texi@@ -75,6 +75,7 @@ Copyright @copyright{} 2020 Wiktor Żelazny@* Copyright @copyright{} 2020 Damien Cassou@* Copyright @copyright{} 2020 Jakub Kądziołka@* Copyright @copyright{} 2020 Jack Hill@*+Copyright @copyright{} 2020 Brice Waegeneire@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or@@ -25382,6 +25383,53 @@ notifications. @end table @end deftp +@cindex modprobe+@cindex kernel module loader+@subsubsection Kernel Module Loader Service++The @code{kernel-module-loader-service} provides a service to load+kernel modules at boot. This is especially usefull for modules that+don't autoload and need to be manually loaded, like it's the case with+@code{ddcci} for example.++@deffn {Scheme Procedure} kernel-module-loader-service @var{modules}+Return a service that run @command{modprobe} with arguments+@var{modules} at boot. For example loading the drivers provided by+@code{ddci-driver-linux} can be done as follow:++@lisp+(use-modules (gnu))+(use-package-modules linux)+(use-service-modules linux)+(operating-system+ ...+ (services (cons* (kernel-module-loader-service+ '("ddcci""ddcci_backlight"))+ %base-services))+ (kernel-loadable-modules (list ddcci-driver-linux)))+@end lisp+@end defvr++@deffn {Scheme Variable} kernel-module-loader-service-type+The service type for loading kernel modules, that can't autoload, at+boot, @command{modprobe}, on. Its value must be a+@code{kernel-module-loader-configuration} object, described below.++@deftp {Data Type} kernel-module-loader-configuration+The data type representing the configuration of @command{sysctl}.++@deftp {Data Type} kernel-module-loader-configuration+This is the configuration record for the+@code{kernel-module-loader-service-type}.++@table @asis+@item @code{modprobe} (default: @code{(file-append kmod "/bin/modprobe"})+The @command{modprobe} executable to use.++@item @code{modules} (default: @code{'()})+A list specifying the modules to load.+@end table+@end deftp @node Miscellaneous Services @subsection Miscellaneous Servicesdiff --git a/gnu/services/linux.scm b/gnu/services/linux.scmindex caa0326c31..99ab4a3329 100644--- a/gnu/services/linux.scm+++ b/gnu/services/linux.scm@@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -37,7 +38,14 @@ earlyoom-configuration-ignore-positive-oom-score-adj? earlyoom-configuration-show-debug-messages? earlyoom-configuration-send-notification-command- earlyoom-service-type))+ earlyoom-service-type++ kernel-module-loader-configuration+ kernel-module-loader-configuration?+ kernel-module-loader-configuration-modprobe+ kernel-module-loader-configuration-modules+ kernel-module-loader-service-type+ kernel-module-loader-service)) ;;;@@ -123,3 +131,51 @@ representation." (list (service-extension shepherd-root-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon.")))++;;;+;;; Kernel module loader.+;;;++(define-record-type* <kernel-module-loader-configuration>+ kernel-module-loader-configuration make-kernel-module-loader-configuration+ kernel-module-loader-configuration?+ (modprobe kernel-module-loader-configuration-modprobe ; path of the 'modprobe' command+ (default (file-append kmod "/bin/modprobe")))+ (modules kernel-module-loader-configuration-modules ; list of strings+ (default '())))++(define kernel-module-loader-shepherd-service+ (match-lambda+ (($ <kernel-module-loader-configuration> modprobe modules)+ (list+ (shepherd-service+ (documentation "Load kernel modules.")+ (provision '(kernel-module-loader))+ (respawn? #f)+ (one-shot? #t)+ (start+ #~(lambda _+ (zero? (system* #$modprobe #$@modules)))))))))++(define kernel-module-loader-service-type+ (service-type+ (name 'kernel-module-loader)+ (description "Load kernel modules.")+ (extensions+ (list+ (service-extension shepherd-root-service-type+ kernel-module-loader-shepherd-service)))+ (compose concatenate)+ (extend (lambda (config modules)+ (kernel-module-loader-configuration+ (inherit config)+ (modules (append+ (kernel-module-loader-configuration-modules config)+ modules)))))+ (default-value (kernel-module-loader-configuration))))++(define* (kernel-module-loader-service modules)+ "Return a service that loads kernel MODULES."+ (service kernel-module-loader-service-type+ (kernel-module-loader-configuration+ (modules modules))))-- 2.25.1
M
M
Mathieu Othacehe wrote on 28 Mar 21:51 +0100
(address . guix-patches@gnu.org)(address . 40274@debbugs.gnu.org)
87o8sgursy.fsf@gmail.com
Hello Brice,
Thanks for this patch! I think you could add this service to (gnu testslinux-modules). This way we would have a full-coverage of the mechanism.
Mathieu
B
B
Brice Waegeneire wrote on 31 Mar 19:19 +0200
[PATCH v2] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)
20200331171900.16356-1-brice@waegenei.re
* doc/guix.texi (Linux Services): Add a new subsection and document thenew service and its configuration.* gnu/services/linux.scm (kernel-module-loader-service): New procedure.(kernel-module-loader-service-type, kernel-module-loader-configuration):New types.* gnu/tests/linux-modules.scm (module-loader-program): Procedureremoved.(modules-loaded?-program): New procedure.(run-loadable-kernel-modules-test): 'module-loader-program' procedurereplaced by the new one. New format for last arguments[os]: Use 'kernel-module-loader-service'.(%test-loadable-kernel-modules-0, %test-loadable-kernel-modules-1,%test-loadable-kernel-modules-2): Use the new argument format.--- doc/guix.texi | 52 +++++++++++++++++++++++++++++++ gnu/services/linux.scm | 61 ++++++++++++++++++++++++++++++++++++- gnu/tests/linux-modules.scm | 45 ++++++++++++++++----------- 3 files changed, 140 insertions(+), 18 deletions(-)
Toggle diff (251 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 77a4b8ed71..e8ad830102 100644--- a/doc/guix.texi+++ b/doc/guix.texi@@ -75,6 +75,7 @@ Copyright @copyright{} 2020 Wiktor Żelazny@* Copyright @copyright{} 2020 Damien Cassou@* Copyright @copyright{} 2020 Jakub Kądziołka@* Copyright @copyright{} 2020 Jack Hill@*+Copyright @copyright{} 2020 Brice Waegeneire@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or@@ -25382,6 +25383,57 @@ notifications. @end table @end deftp +@cindex modprobe+@cindex kernel module loader+@subsubsection Kernel Module Loader Service++The @code{kernel-module-loader-service} provides a service to load+kernel modules at boot. This is especially usefull for modules that+don't autoload and need to be manually loaded, like it's the case with+@code{ddcci} for example.++@deffn {Scheme Procedure} kernel-module-loader-service @var{modules}+Return a service that run @command{modprobe} with arguments+@var{modules} at boot. For example loading the drivers provided by+@code{ddci-driver-linux} with @code{ddcci} in debugging mode can be done+as follow:++@lisp+(use-modules (gnu))+(use-package-modules linux)+(use-service-modules linux)+(operating-system+ ...+ (services (cons* (kernel-module-loader-service+ '(("ddcci" "dyndbg")+ ("ddcci_backlight")))+ %base-services))+ (kernel-loadable-modules (list ddcci-driver-linux)))+@end lisp+@end defvr++@deffn {Scheme Variable} kernel-module-loader-service-type+The service type for loading kernel modules at boot with+@command{modprobe}, for module that can't autoload. Its value must be a+@code{kernel-module-loader-configuration} object, described below.++@deftp {Data Type} kernel-module-loader-configuration+The data type representing the modules to be loaded by+@command{modprobe}.++@deftp {Data Type} kernel-module-loader-configuration+This is the configuration record for the+@code{kernel-module-loader-service-type}.++@table @asis+@item @code{modprobe} (default: @code{(file-append kmod "/bin/modprobe"})+The @command{modprobe} executable to use.++@item @code{modules} (default: @code{'()})+A list of list of strings specifying the modules to load with their+optional parameters.+@end table+@end deftp @node Miscellaneous Services @subsection Miscellaneous Servicesdiff --git a/gnu/services/linux.scm b/gnu/services/linux.scmindex caa0326c31..da71b275f1 100644--- a/gnu/services/linux.scm+++ b/gnu/services/linux.scm@@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -37,7 +38,14 @@ earlyoom-configuration-ignore-positive-oom-score-adj? earlyoom-configuration-show-debug-messages? earlyoom-configuration-send-notification-command- earlyoom-service-type))+ earlyoom-service-type++ kernel-module-loader-configuration+ kernel-module-loader-configuration?+ kernel-module-loader-configuration-modprobe+ kernel-module-loader-configuration-modules+ kernel-module-loader-service-type+ kernel-module-loader-service)) ;;;@@ -123,3 +131,54 @@ representation." (list (service-extension shepherd-root-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon.")))++;;;+;;; Kernel module loader.+;;;++(define-record-type* <kernel-module-loader-configuration>+ kernel-module-loader-configuration make-kernel-module-loader-configuration+ kernel-module-loader-configuration?+ (modprobe kernel-module-loader-configuration-modprobe ; path of the 'modprobe' command+ (default (file-append kmod "/bin/modprobe")))+ (modules kernel-module-loader-configuration-modules ; list of lists of strings+ (default '())))++(define kernel-module-loader-shepherd-service+ (match-lambda+ (($ <kernel-module-loader-configuration> modprobe modules)+ (list+ (shepherd-service+ (documentation "Load kernel modules.")+ (provision '(kernel-module-loader))+ (respawn? #f)+ (one-shot? #t)+ (start+ #~(lambda _+ (and-map (lambda (module-with-parameters)+ (zero? (apply system* #$modprobe "--"+ module-with-parameters)))+ '#$modules))))))))++(define kernel-module-loader-service-type+ (service-type+ (name 'kernel-module-loader)+ (description "Load kernel modules.")+ (extensions+ (list+ (service-extension shepherd-root-service-type+ kernel-module-loader-shepherd-service)))+ (compose concatenate)+ (extend (lambda (config modules)+ (kernel-module-loader-configuration+ (inherit config)+ (modules (append+ (kernel-module-loader-configuration-modules config)+ modules)))))+ (default-value (kernel-module-loader-configuration))))++(define* (kernel-module-loader-service modules)+ "Return a service that loads kernel MODULES."+ (service kernel-module-loader-service-type+ (kernel-module-loader-configuration+ (modules modules))))diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scmindex 39e11587c6..7b820a1269 100644--- a/gnu/tests/linux-modules.scm+++ b/gnu/tests/linux-modules.scm@@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -19,6 +20,7 @@ (define-module (gnu tests linux-modules) #:use-module (gnu packages linux)+ #:use-module (gnu services linux) #:use-module (gnu system) #:use-module (gnu system vm) #:use-module (gnu tests)@@ -37,25 +39,31 @@ ;;; ;;; Code: -(define* (module-loader-program os modules)- "Return an executable store item that, upon being evaluated, will dry-run-load MODULES."+(define* (modules-loaded?-program os modules)+ "Return an executable store item that, upon being evaluated, will verify+that MODULES are actually loaded." (program-file "load-kernel-modules.scm"- (with-imported-modules (source-module-closure '((guix build utils)))- #~(begin- (use-modules (guix build utils))- (for-each (lambda (module)- (invoke (string-append #$kmod "/bin/modprobe") "-n" "--"- module))- '#$modules)))))+ #~(begin+ (use-modules (ice-9 rdelim)+ (ice-9 popen))+ (let* ((port (open-input-pipe (string-append #$kmod "/bin/lsmod")))+ (output (read-string port))+ (status (close-pipe port)))+ (and-map (lambda (module) (string-contains output module))+ '#$modules))))) -(define* (run-loadable-kernel-modules-test module-packages module-names)- "Run a test of an OS having MODULE-PACKAGES, and modprobe MODULE-NAMES."+(define* (run-loadable-kernel-modules-test module-packages+ modules-with-parameters)+ "Run a test of an OS having MODULE-PACKAGES, and verify that+MODULES-WITH-PARAMETERS are loaded in memory." (define os (marionette-operating-system (operating-system (inherit (simple-operating-system))+ (services (cons (kernel-module-loader-service modules-with-parameters)+ (operating-system-user-services+ (simple-operating-system)))) (kernel-loadable-modules module-packages)) #:imported-modules '((guix combinators)))) (define vm (virtual-machine os))@@ -75,7 +83,9 @@ load MODULES." marionette)) (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0)))))- (gexp->derivation "loadable-kernel-modules" (test (module-loader-program os module-names))))+ (gexp->derivation+ "loadable-kernel-modules"+ (test (modules-loaded?-program os (map car modules-with-parameters))))) (define %test-loadable-kernel-modules-0 (system-test@@ -88,16 +98,17 @@ with no extra modules.") (system-test (name "loadable-kernel-modules-1") (description "Tests loadable kernel modules facility of <operating-system>-with one extra module.")+with one extra module with some parameters.") (value (run-loadable-kernel-modules-test (list ddcci-driver-linux)- '("ddcci")))))+ '(("ddcci" "dyndbg" "delay:120")))))) (define %test-loadable-kernel-modules-2 (system-test (name "loadable-kernel-modules-2") (description "Tests loadable kernel modules facility of <operating-system>-with two extra modules.")+with two extra modules without any parameters.") (value (run-loadable-kernel-modules-test (list acpi-call-linux-module ddcci-driver-linux)- '("acpi_call" "ddcci")))))+ '(("acpi_call")+ ("ddcci"))))))-- 2.25.1
B
B
Brice Waegeneire wrote on 31 Mar 19:22 +0200
Re: [bug#40274] [PATCH] gnu: Add kernel-module-loader-service.
(name . Mathieu Othacehe)(address . m.othacehe@gmail.com)
8b8e74d2584e5660688a741c00301400@waegenei.re
Hello Mathieu,
On 2020-03-28 20:51, Mathieu Othacehe wrote:
Toggle quote (8 lines)> Hello Brice,> > Thanks for this patch! I think you could add this service to (gnu tests> linux-modules). This way we would have a full-coverage of the > mechanism.> > Mathieu
I have done what you suggested in v2. It also fix some issues and add theability to optionally specify parameters for each module.
- Brice
B
B
Brice Waegeneire wrote on 31 Mar 22:00 +0200
[PATCH v3] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)
20200331200037.32346-1-brice@waegenei.re
* doc/guix.texi (Linux Services): Add a new subsection and document thenew service and its configuration.* gnu/services/linux.scm (kernel-module-loader-service): New procedure.(kernel-module-loader-service-type, kernel-module-loader-configuration):New types.* gnu/tests/linux-modules.scm (module-loader-program): Procedureremoved.(modules-loaded?-program): New procedure.(run-loadable-kernel-modules-test): 'module-loader-program' procedurereplaced by the new one. New format for last arguments[os]: Use 'kernel-module-loader-service'.(%test-loadable-kernel-modules-0, %test-loadable-kernel-modules-1,%test-loadable-kernel-modules-2): Use the new argument format.---
This version fix some markup issue in doc/guix.texi.
doc/guix.texi | 54 ++++++++++++++++++++++++++++++++ gnu/services/linux.scm | 61 ++++++++++++++++++++++++++++++++++++- gnu/tests/linux-modules.scm | 45 ++++++++++++++++----------- 3 files changed, 142 insertions(+), 18 deletions(-)
Toggle diff (253 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 77a4b8ed71..83c893ddb9 100644--- a/doc/guix.texi+++ b/doc/guix.texi@@ -75,6 +75,7 @@ Copyright @copyright{} 2020 Wiktor Żelazny@* Copyright @copyright{} 2020 Damien Cassou@* Copyright @copyright{} 2020 Jakub Kądziołka@* Copyright @copyright{} 2020 Jack Hill@*+Copyright @copyright{} 2020 Brice Waegeneire@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or@@ -25382,6 +25383,59 @@ notifications. @end table @end deftp +@cindex modprobe+@cindex kernel module loader+@subsubsection Kernel Module Loader Service++The @code{kernel-module-loader-service} provides a service to load+kernel modules at boot. This is especially usefull for modules that+don't autoload and need to be manually loaded, like it's the case with+@code{ddcci} for example.++@deffn {Scheme Procedure} kernel-module-loader-service @var{modules}+Return a service that run @command{modprobe} with arguments+@var{modules} at boot. For example loading the drivers provided by+@code{ddci-driver-linux} with @code{ddcci} in debugging mode can be done+as follow:++@lisp+(use-modules (gnu))+(use-package-modules linux)+(use-service-modules linux)+(operating-system+ ...+ (services (cons* (kernel-module-loader-service+ '(("ddcci" "dyndbg")+ ("ddcci_backlight")))+ %base-services))+ (kernel-loadable-modules (list ddcci-driver-linux)))+@end lisp+@end deffn++@deffn {Scheme Variable} kernel-module-loader-service-type+The service type for loading kernel modules at boot with+@command{modprobe}, for module that can't autoload. Its value must be a+@code{kernel-module-loader-configuration} object, described below.+@end deffn++@deftp {Data Type} kernel-module-loader-configuration+The data type representing the modules to be loaded by+@command{modprobe}.+@end deftp++@deftp {Data Type} kernel-module-loader-configuration+This is the configuration record for the+@code{kernel-module-loader-service-type}.++@table @asis+@item @code{modprobe} (default: @code{(file-append kmod "/bin/modprobe"})+The @command{modprobe} executable to use.++@item @code{modules} (default: @code{'()})+A list of list of strings specifying the modules to load with their+optional parameters.+@end table+@end deftp @node Miscellaneous Services @subsection Miscellaneous Servicesdiff --git a/gnu/services/linux.scm b/gnu/services/linux.scmindex caa0326c31..da71b275f1 100644--- a/gnu/services/linux.scm+++ b/gnu/services/linux.scm@@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -37,7 +38,14 @@ earlyoom-configuration-ignore-positive-oom-score-adj? earlyoom-configuration-show-debug-messages? earlyoom-configuration-send-notification-command- earlyoom-service-type))+ earlyoom-service-type++ kernel-module-loader-configuration+ kernel-module-loader-configuration?+ kernel-module-loader-configuration-modprobe+ kernel-module-loader-configuration-modules+ kernel-module-loader-service-type+ kernel-module-loader-service)) ;;;@@ -123,3 +131,54 @@ representation." (list (service-extension shepherd-root-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon.")))++;;;+;;; Kernel module loader.+;;;++(define-record-type* <kernel-module-loader-configuration>+ kernel-module-loader-configuration make-kernel-module-loader-configuration+ kernel-module-loader-configuration?+ (modprobe kernel-module-loader-configuration-modprobe ; path of the 'modprobe' command+ (default (file-append kmod "/bin/modprobe")))+ (modules kernel-module-loader-configuration-modules ; list of lists of strings+ (default '())))++(define kernel-module-loader-shepherd-service+ (match-lambda+ (($ <kernel-module-loader-configuration> modprobe modules)+ (list+ (shepherd-service+ (documentation "Load kernel modules.")+ (provision '(kernel-module-loader))+ (respawn? #f)+ (one-shot? #t)+ (start+ #~(lambda _+ (and-map (lambda (module-with-parameters)+ (zero? (apply system* #$modprobe "--"+ module-with-parameters)))+ '#$modules))))))))++(define kernel-module-loader-service-type+ (service-type+ (name 'kernel-module-loader)+ (description "Load kernel modules.")+ (extensions+ (list+ (service-extension shepherd-root-service-type+ kernel-module-loader-shepherd-service)))+ (compose concatenate)+ (extend (lambda (config modules)+ (kernel-module-loader-configuration+ (inherit config)+ (modules (append+ (kernel-module-loader-configuration-modules config)+ modules)))))+ (default-value (kernel-module-loader-configuration))))++(define* (kernel-module-loader-service modules)+ "Return a service that loads kernel MODULES."+ (service kernel-module-loader-service-type+ (kernel-module-loader-configuration+ (modules modules))))diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scmindex 39e11587c6..7b820a1269 100644--- a/gnu/tests/linux-modules.scm+++ b/gnu/tests/linux-modules.scm@@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -19,6 +20,7 @@ (define-module (gnu tests linux-modules) #:use-module (gnu packages linux)+ #:use-module (gnu services linux) #:use-module (gnu system) #:use-module (gnu system vm) #:use-module (gnu tests)@@ -37,25 +39,31 @@ ;;; ;;; Code: -(define* (module-loader-program os modules)- "Return an executable store item that, upon being evaluated, will dry-run-load MODULES."+(define* (modules-loaded?-program os modules)+ "Return an executable store item that, upon being evaluated, will verify+that MODULES are actually loaded." (program-file "load-kernel-modules.scm"- (with-imported-modules (source-module-closure '((guix build utils)))- #~(begin- (use-modules (guix build utils))- (for-each (lambda (module)- (invoke (string-append #$kmod "/bin/modprobe") "-n" "--"- module))- '#$modules)))))+ #~(begin+ (use-modules (ice-9 rdelim)+ (ice-9 popen))+ (let* ((port (open-input-pipe (string-append #$kmod "/bin/lsmod")))+ (output (read-string port))+ (status (close-pipe port)))+ (and-map (lambda (module) (string-contains output module))+ '#$modules))))) -(define* (run-loadable-kernel-modules-test module-packages module-names)- "Run a test of an OS having MODULE-PACKAGES, and modprobe MODULE-NAMES."+(define* (run-loadable-kernel-modules-test module-packages+ modules-with-parameters)+ "Run a test of an OS having MODULE-PACKAGES, and verify that+MODULES-WITH-PARAMETERS are loaded in memory." (define os (marionette-operating-system (operating-system (inherit (simple-operating-system))+ (services (cons (kernel-module-loader-service modules-with-parameters)+ (operating-system-user-services+ (simple-operating-system)))) (kernel-loadable-modules module-packages)) #:imported-modules '((guix combinators)))) (define vm (virtual-machine os))@@ -75,7 +83,9 @@ load MODULES." marionette)) (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0)))))- (gexp->derivation "loadable-kernel-modules" (test (module-loader-program os module-names))))+ (gexp->derivation+ "loadable-kernel-modules"+ (test (modules-loaded?-program os (map car modules-with-parameters))))) (define %test-loadable-kernel-modules-0 (system-test@@ -88,16 +98,17 @@ with no extra modules.") (system-test (name "loadable-kernel-modules-1") (description "Tests loadable kernel modules facility of <operating-system>-with one extra module.")+with one extra module with some parameters.") (value (run-loadable-kernel-modules-test (list ddcci-driver-linux)- '("ddcci")))))+ '(("ddcci" "dyndbg" "delay:120")))))) (define %test-loadable-kernel-modules-2 (system-test (name "loadable-kernel-modules-2") (description "Tests loadable kernel modules facility of <operating-system>-with two extra modules.")+with two extra modules without any parameters.") (value (run-loadable-kernel-modules-test (list acpi-call-linux-module ddcci-driver-linux)- '("acpi_call" "ddcci")))))+ '(("acpi_call")+ ("ddcci"))))))-- 2.25.1
N
N
Nicolò Balzarotti wrote on 31 Mar 22:10 +0200
Re: [bug#40274] [PATCH] gnu: Add kernel-module-loader-service.
87ftdoe155.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
Hi, I found a typo
/usefull/useful/
Nicolò
Brice Waegeneire <brice@waegenei.re> writes:
Toggle quote (161 lines)> * doc/guix.texi (Linux Services): Add a new subsection and document the> new service and its configuration.> * gnu/services/linux.scm (kernel-module-loader-service): New procedure.> (kernel-module-loader-service-type, kernel-module-loader-configuration):> New types.> --->> This patch is related to the following thread:> https://lists.gnu.org/archive/html/guix-devel/2020-03/msg00381.html>> doc/guix.texi | 48 ++++++++++++++++++++++++++++++++++> gnu/services/linux.scm | 58 +++++++++++++++++++++++++++++++++++++++++-> 2 files changed, 105 insertions(+), 1 deletion(-)>> diff --git a/doc/guix.texi b/doc/guix.texi> index 77a4b8ed71..a297ec249f 100644> --- a/doc/guix.texi> +++ b/doc/guix.texi> @@ -75,6 +75,7 @@ Copyright @copyright{} 2020 Wiktor Żelazny@*> Copyright @copyright{} 2020 Damien Cassou@*> Copyright @copyright{} 2020 Jakub Kądziołka@*> Copyright @copyright{} 2020 Jack Hill@*> +Copyright @copyright{} 2020 Brice Waegeneire@*> > Permission is granted to copy, distribute and/or modify this document> under the terms of the GNU Free Documentation License, Version 1.3 or> @@ -25382,6 +25383,53 @@ notifications.> @end table> @end deftp> > +@cindex modprobe> +@cindex kernel module loader> +@subsubsection Kernel Module Loader Service> +> +The @code{kernel-module-loader-service} provides a service to load> +kernel modules at boot. This is especially usefull for modules that> +don't autoload and need to be manually loaded, like it's the case with> +@code{ddcci} for example.> +> +@deffn {Scheme Procedure} kernel-module-loader-service @var{modules}> +Return a service that run @command{modprobe} with arguments> +@var{modules} at boot. For example loading the drivers provided by> +@code{ddci-driver-linux} can be done as follow:> +> +@lisp> +(use-modules (gnu))> +(use-package-modules linux)> +(use-service-modules linux)> +(operating-system> + ...> + (services (cons* (kernel-module-loader-service> + '("ddcci""ddcci_backlight"))> + %base-services))> + (kernel-loadable-modules (list ddcci-driver-linux)))> +@end lisp> +@end defvr> +> +@deffn {Scheme Variable} kernel-module-loader-service-type> +The service type for loading kernel modules, that can't autoload, at> +boot, @command{modprobe}, on. Its value must be a> +@code{kernel-module-loader-configuration} object, described below.> +> +@deftp {Data Type} kernel-module-loader-configuration> +The data type representing the configuration of @command{sysctl}.> +> +@deftp {Data Type} kernel-module-loader-configuration> +This is the configuration record for the> +@code{kernel-module-loader-service-type}.> +> +@table @asis> +@item @code{modprobe} (default: @code{(file-append kmod "/bin/modprobe"})> +The @command{modprobe} executable to use.> +> +@item @code{modules} (default: @code{'()})> +A list specifying the modules to load.> +@end table> +@end deftp> > @node Miscellaneous Services> @subsection Miscellaneous Services> diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm> index caa0326c31..99ab4a3329 100644> --- a/gnu/services/linux.scm> +++ b/gnu/services/linux.scm> @@ -1,5 +1,6 @@> ;;; GNU Guix --- Functional package management for GNU> ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>> +;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>> ;;;> ;;; This file is part of GNU Guix.> ;;;> @@ -37,7 +38,14 @@> earlyoom-configuration-ignore-positive-oom-score-adj?> earlyoom-configuration-show-debug-messages?> earlyoom-configuration-send-notification-command> - earlyoom-service-type))> + earlyoom-service-type> +> + kernel-module-loader-configuration> + kernel-module-loader-configuration?> + kernel-module-loader-configuration-modprobe> + kernel-module-loader-configuration-modules> + kernel-module-loader-service-type> + kernel-module-loader-service))> > > ;;;> @@ -123,3 +131,51 @@ representation."> (list (service-extension shepherd-root-service-type> (compose list earlyoom-shepherd-service))))> (description "Run @command{earlyoom}, the Early OOM daemon.")))> +> +;;;> +;;; Kernel module loader.> +;;;> +> +(define-record-type* <kernel-module-loader-configuration>> + kernel-module-loader-configuration make-kernel-module-loader-configuration> + kernel-module-loader-configuration?> + (modprobe kernel-module-loader-configuration-modprobe ; path of the 'modprobe' command> + (default (file-append kmod "/bin/modprobe")))> + (modules kernel-module-loader-configuration-modules ; list of strings> + (default '())))> +> +(define kernel-module-loader-shepherd-service> + (match-lambda> + (($ <kernel-module-loader-configuration> modprobe modules)> + (list> + (shepherd-service> + (documentation "Load kernel modules.")> + (provision '(kernel-module-loader))> + (respawn? #f)> + (one-shot? #t)> + (start> + #~(lambda _> + (zero? (system* #$modprobe #$@modules)))))))))> +> +(define kernel-module-loader-service-type> + (service-type> + (name 'kernel-module-loader)> + (description "Load kernel modules.")> + (extensions> + (list> + (service-extension shepherd-root-service-type> + kernel-module-loader-shepherd-service)))> + (compose concatenate)> + (extend (lambda (config modules)> + (kernel-module-loader-configuration> + (inherit config)> + (modules (append> + (kernel-module-loader-configuration-modules config)> + modules)))))> + (default-value (kernel-module-loader-configuration))))> +> +(define* (kernel-module-loader-service modules)> + "Return a service that loads kernel MODULES."> + (service kernel-module-loader-service-type> + (kernel-module-loader-configuration> + (modules modules))))> -- > 2.25.1
B
B
Brice Waegeneire wrote on 31 Mar 22:23 +0200
[PATCH v4] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)
20200331202340.10054-1-brice@waegenei.re
* doc/guix.texi (Linux Services): Add a new subsection and document thenew service and its configuration.* gnu/services/linux.scm (kernel-module-loader-service): New procedure.(kernel-module-loader-service-type, kernel-module-loader-configuration):New types.* gnu/tests/linux-modules.scm (module-loader-program): Procedureremoved.(modules-loaded?-program): New procedure.(run-loadable-kernel-modules-test): 'module-loader-program' procedurereplaced by the new one. New format for last arguments[os]: Use 'kernel-module-loader-service'.(%test-loadable-kernel-modules-0, %test-loadable-kernel-modules-1,%test-loadable-kernel-modules-2): Use the new argument format.---
Fix typo in doc/guix.texi.
doc/guix.texi | 54 ++++++++++++++++++++++++++++++++ gnu/services/linux.scm | 61 ++++++++++++++++++++++++++++++++++++- gnu/tests/linux-modules.scm | 45 ++++++++++++++++----------- 3 files changed, 142 insertions(+), 18 deletions(-)
Toggle diff (253 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 77a4b8ed71..125726a316 100644--- a/doc/guix.texi+++ b/doc/guix.texi@@ -75,6 +75,7 @@ Copyright @copyright{} 2020 Wiktor Żelazny@* Copyright @copyright{} 2020 Damien Cassou@* Copyright @copyright{} 2020 Jakub Kądziołka@* Copyright @copyright{} 2020 Jack Hill@*+Copyright @copyright{} 2020 Brice Waegeneire@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or@@ -25382,6 +25383,59 @@ notifications. @end table @end deftp +@cindex modprobe+@cindex kernel module loader+@subsubsection Kernel Module Loader Service++The @code{kernel-module-loader-service} provides a service to load+kernel modules at boot. This is especially useful for modules that+don't autoload and need to be manually loaded, like it's the case with+@code{ddcci} for example.++@deffn {Scheme Procedure} kernel-module-loader-service @var{modules}+Return a service that run @command{modprobe} with arguments+@var{modules} at boot. For example loading the drivers provided by+@code{ddci-driver-linux} with @code{ddcci} in debugging mode can be done+as follow:++@lisp+(use-modules (gnu))+(use-package-modules linux)+(use-service-modules linux)+(operating-system+ ...+ (services (cons* (kernel-module-loader-service+ '(("ddcci" "dyndbg")+ ("ddcci_backlight")))+ %base-services))+ (kernel-loadable-modules (list ddcci-driver-linux)))+@end lisp+@end deffn++@deffn {Scheme Variable} kernel-module-loader-service-type+The service type for loading kernel modules at boot with+@command{modprobe}, for module that can't autoload. Its value must be a+@code{kernel-module-loader-configuration} object, described below.+@end deffn++@deftp {Data Type} kernel-module-loader-configuration+The data type representing the modules to be loaded by+@command{modprobe}.+@end deftp++@deftp {Data Type} kernel-module-loader-configuration+This is the configuration record for the+@code{kernel-module-loader-service-type}.++@table @asis+@item @code{modprobe} (default: @code{(file-append kmod "/bin/modprobe"})+The @command{modprobe} executable to use.++@item @code{modules} (default: @code{'()})+A list of list of strings specifying the modules to load with their+optional parameters.+@end table+@end deftp @node Miscellaneous Services @subsection Miscellaneous Servicesdiff --git a/gnu/services/linux.scm b/gnu/services/linux.scmindex caa0326c31..da71b275f1 100644--- a/gnu/services/linux.scm+++ b/gnu/services/linux.scm@@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -37,7 +38,14 @@ earlyoom-configuration-ignore-positive-oom-score-adj? earlyoom-configuration-show-debug-messages? earlyoom-configuration-send-notification-command- earlyoom-service-type))+ earlyoom-service-type++ kernel-module-loader-configuration+ kernel-module-loader-configuration?+ kernel-module-loader-configuration-modprobe+ kernel-module-loader-configuration-modules+ kernel-module-loader-service-type+ kernel-module-loader-service)) ;;;@@ -123,3 +131,54 @@ representation." (list (service-extension shepherd-root-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon.")))++;;;+;;; Kernel module loader.+;;;++(define-record-type* <kernel-module-loader-configuration>+ kernel-module-loader-configuration make-kernel-module-loader-configuration+ kernel-module-loader-configuration?+ (modprobe kernel-module-loader-configuration-modprobe ; path of the 'modprobe' command+ (default (file-append kmod "/bin/modprobe")))+ (modules kernel-module-loader-configuration-modules ; list of lists of strings+ (default '())))++(define kernel-module-loader-shepherd-service+ (match-lambda+ (($ <kernel-module-loader-configuration> modprobe modules)+ (list+ (shepherd-service+ (documentation "Load kernel modules.")+ (provision '(kernel-module-loader))+ (respawn? #f)+ (one-shot? #t)+ (start+ #~(lambda _+ (and-map (lambda (module-with-parameters)+ (zero? (apply system* #$modprobe "--"+ module-with-parameters)))+ '#$modules))))))))++(define kernel-module-loader-service-type+ (service-type+ (name 'kernel-module-loader)+ (description "Load kernel modules.")+ (extensions+ (list+ (service-extension shepherd-root-service-type+ kernel-module-loader-shepherd-service)))+ (compose concatenate)+ (extend (lambda (config modules)+ (kernel-module-loader-configuration+ (inherit config)+ (modules (append+ (kernel-module-loader-configuration-modules config)+ modules)))))+ (default-value (kernel-module-loader-configuration))))++(define* (kernel-module-loader-service modules)+ "Return a service that loads kernel MODULES."+ (service kernel-module-loader-service-type+ (kernel-module-loader-configuration+ (modules modules))))diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scmindex 39e11587c6..7b820a1269 100644--- a/gnu/tests/linux-modules.scm+++ b/gnu/tests/linux-modules.scm@@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -19,6 +20,7 @@ (define-module (gnu tests linux-modules) #:use-module (gnu packages linux)+ #:use-module (gnu services linux) #:use-module (gnu system) #:use-module (gnu system vm) #:use-module (gnu tests)@@ -37,25 +39,31 @@ ;;; ;;; Code: -(define* (module-loader-program os modules)- "Return an executable store item that, upon being evaluated, will dry-run-load MODULES."+(define* (modules-loaded?-program os modules)+ "Return an executable store item that, upon being evaluated, will verify+that MODULES are actually loaded." (program-file "load-kernel-modules.scm"- (with-imported-modules (source-module-closure '((guix build utils)))- #~(begin- (use-modules (guix build utils))- (for-each (lambda (module)- (invoke (string-append #$kmod "/bin/modprobe") "-n" "--"- module))- '#$modules)))))+ #~(begin+ (use-modules (ice-9 rdelim)+ (ice-9 popen))+ (let* ((port (open-input-pipe (string-append #$kmod "/bin/lsmod")))+ (output (read-string port))+ (status (close-pipe port)))+ (and-map (lambda (module) (string-contains output module))+ '#$modules))))) -(define* (run-loadable-kernel-modules-test module-packages module-names)- "Run a test of an OS having MODULE-PACKAGES, and modprobe MODULE-NAMES."+(define* (run-loadable-kernel-modules-test module-packages+ modules-with-parameters)+ "Run a test of an OS having MODULE-PACKAGES, and verify that+MODULES-WITH-PARAMETERS are loaded in memory." (define os (marionette-operating-system (operating-system (inherit (simple-operating-system))+ (services (cons (kernel-module-loader-service modules-with-parameters)+ (operating-system-user-services+ (simple-operating-system)))) (kernel-loadable-modules module-packages)) #:imported-modules '((guix combinators)))) (define vm (virtual-machine os))@@ -75,7 +83,9 @@ load MODULES." marionette)) (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0)))))- (gexp->derivation "loadable-kernel-modules" (test (module-loader-program os module-names))))+ (gexp->derivation+ "loadable-kernel-modules"+ (test (modules-loaded?-program os (map car modules-with-parameters))))) (define %test-loadable-kernel-modules-0 (system-test@@ -88,16 +98,17 @@ with no extra modules.") (system-test (name "loadable-kernel-modules-1") (description "Tests loadable kernel modules facility of <operating-system>-with one extra module.")+with one extra module with some parameters.") (value (run-loadable-kernel-modules-test (list ddcci-driver-linux)- '("ddcci")))))+ '(("ddcci" "dyndbg" "delay:120")))))) (define %test-loadable-kernel-modules-2 (system-test (name "loadable-kernel-modules-2") (description "Tests loadable kernel modules facility of <operating-system>-with two extra modules.")+with two extra modules without any parameters.") (value (run-loadable-kernel-modules-test (list acpi-call-linux-module ddcci-driver-linux)- '("acpi_call" "ddcci")))))+ '(("acpi_call")+ ("ddcci"))))))-- 2.25.1
B
B
Brice Waegeneire wrote on 31 Mar 22:25 +0200
Re: [bug#40274] [PATCH] gnu: Add kernel-module-loader-service.
(name . Nicolò Balzarotti)(address . anothersms@gmail.com)
9ad47bb94ed179ae6fec73db28c7debb@waegenei.re
Hello,
On 2020-03-31 20:10, Nicolò Balzarotti wrote:
Toggle quote (6 lines)> Hi, I found a typo> > /usefull/useful/> > Nicolò
Thank you Nicolò I was missing flyspell in texinfo-mode, it's fixed in v4.
- Brice
M
M
Mathieu Othacehe wrote on 1 Apr 15:30 +0200
Re: [bug#40274] [PATCH v4] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)(address . 40274@debbugs.gnu.org)
87k12zcozy.fsf@gmail.com
Hello Brice,
Toggle quote (2 lines)> +@deffn {Scheme Procedure} kernel-module-loader-service @var{modules}> +Return a service that run @command{modprobe} with arguments
^ runs
Toggle quote (1 lines)> +@var{modules} at boot. For example loading the drivers provided by
^ What's modules?
Toggle quote (3 lines)> +@deffn {Scheme Variable} kernel-module-loader-service-type> +The service type for loading kernel modules at boot with> +@command{modprobe}, for module that can't autoload. Its value must be a
^ modules
You can add a separator here, C-q C-l with Emacs :)
Toggle quote (9 lines)> +;;;> +;;; Kernel module loader.> +;;;
> + (modprobe kernel-module-loader-configuration-modprobe ; path of the 'modprobe' command> + (default (file-append kmod "/bin/modprobe")))> + (modules kernel-module-loader-configuration-modules ; list of lists of strings> + (default '())))
Those lines are above the 78 columns limit.
Toggle quote (17 lines)> +> +(define kernel-module-loader-shepherd-service> + (match-lambda> + (($ <kernel-module-loader-configuration> modprobe modules)> + (list> + (shepherd-service> + (documentation "Load kernel modules.")> + (provision '(kernel-module-loader))> + (respawn? #f)> + (one-shot? #t)> + (start> + #~(lambda _> + (and-map (lambda (module-with-parameters)> + (zero? (apply system* #$modprobe "--"> + module-with-parameters)))> + '#$modules))))))))
I wonder if it would make sense to rmmod the modules on servicestop? Probably not.
Toggle quote (6 lines)> (value (run-loadable-kernel-modules-test> (list acpi-call-linux-module ddcci-driver-linux)> - '("acpi_call" "ddcci")))))> + '(("acpi_call")> + ("ddcci"))))))
When using multiple modules without any configuration, I find thenotation '(("module-a") ("module-b")) a bit unclear. Maybe we could adda special case handling '("module-a" "module-b") as two kernel modulestaking no arguments.
Or we could define a record with two fields: module-name and arguments.Not sure what's better.
Anyway, this looks good to me :). But let's wait for Danny opinionmaybe.
Thanks,
Mathieu
B
B
Brice Waegeneire wrote on 1 Apr 16:38 +0200
(name . Mathieu Othacehe)(address . m.othacehe@gmail.com)
58b435078b6055874686c2da7d411eaa@waegenei.re
Hello Mathieu,
On 2020-04-01 13:30, Mathieu Othacehe wrote:
Toggle quote (2 lines)> You can add a separator here, C-q C-l with Emacs :)
I never used pagination in Emacs, maybe I should start using it.
Toggle quote (19 lines)>> +(define kernel-module-loader-shepherd-service>> + (match-lambda>> + (($ <kernel-module-loader-configuration> modprobe modules)>> + (list>> + (shepherd-service>> + (documentation "Load kernel modules.")>> + (provision '(kernel-module-loader))>> + (respawn? #f)>> + (one-shot? #t)>> + (start>> + #~(lambda _>> + (and-map (lambda (module-with-parameters)>> + (zero? (apply system* #$modprobe "--">> + module-with-parameters)))>> + '#$modules))))))))> > I wonder if it would make sense to rmmod the modules on service> stop? Probably not.
This is a one-shot service so no.
Toggle quote (14 lines)>> (value (run-loadable-kernel-modules-test>> (list acpi-call-linux-module ddcci-driver-linux)>> - '("acpi_call" "ddcci")))))>> + '(("acpi_call")>> + ("ddcci"))))))> > When using multiple modules without any configuration, I find the> notation '(("module-a") ("module-b")) a bit unclear. Maybe we could add> a special case handling '("module-a" "module-b") as two kernel modules> taking no arguments.> > Or we could define a record with two fields: module-name and arguments.> Not sure what's better.
I asked about it on IRC before starting v2 but nobody responded so I went onwith this “list of lists of string” implementation. I'll be happy to use abetter format, the special case look nice but maybe confusing for the user.
I have fixed the typo you reported but I'll wait for further suggestion aboutthe format before sending the new version.
- Brice
P
P
pelzflorian (Florian Pelz) wrote on 1 Apr 21:34 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200401193458.evg46ygamtniby7k@pelzflorian.localdomain
Thank you for your patch.
I tried with your patch to make the Guix install image load theuvesafb kernel module, but it fails and I get no log. Is it possibleto make the service log failures?
I just get:
failed to load service: kernel-module-loader
printed on the console (but not to /var/log/messages).
I believe I pass parameters wrongly. I attach how I try to use yourkernel-module-loader.
Regards,Florian
Toggle diff (51 lines)diff --git a/gnu/system/install.scm b/gnu/system/install.scmindex c15c2c7814..aa42449098 100644--- a/gnu/system/install.scm+++ b/gnu/system/install.scm@@ -26,11 +26,13 @@ #:use-module (gnu bootloader u-boot) #:use-module (guix gexp) #:use-module (guix store)+ #:use-module (guix utils) #:use-module (guix monads) #:use-module ((guix packages) #:select (package-version)) #:use-module ((guix store) #:select (%store-prefix)) #:use-module (gnu installer) #:use-module (gnu services dbus)+ #:use-module (gnu services linux) #:use-module (gnu services networking) #:use-module (gnu services shepherd) #:use-module (gnu services ssh)@@ -50,6 +52,7 @@ #:use-module (gnu packages texinfo) #:use-module (gnu packages compression) #:use-module (gnu packages nvi)+ #:use-module (gnu packages xorg) #:use-module (ice-9 match) #:use-module (srfi srfi-26) #:export (installation-os@@ -304,7 +307,8 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m (define bare-bones-os (load "examples/bare-bones.tmpl")) - (list (service virtual-terminal-service-type)+ (cons*+ (service virtual-terminal-service-type) (service kmscon-service-type (kmscon-configuration@@ -408,7 +412,13 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m (list bare-bones-os glibc-utf8-locales texinfo- (canonical-package guile-2.2))))))+ (canonical-package guile-2.2)))+ (if (member (%current-system) '("x86_64-linux" "i686-linux"))+ ;; Load uvesafb to show installer when no KMS is available.+ `(,(kernel-module-loader-service+ '(("uvesafb" (string-append "v86d=" #$v86d "/sbin/v86d")+ "mode_option=1024x768"))))+ '())))) (define %issue ;; Greeting.
P
P
pelzflorian (Florian Pelz) wrote on 1 Apr 21:43 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200401194358.hamsw4q7but5jeon@pelzflorian.localdomain
On Wed, Apr 01, 2020 at 09:34:58PM +0200, pelzflorian (Florian Pelz) wrote:
Toggle quote (3 lines)> I believe I pass parameters wrongly. I attach how I try to use your> kernel-module-loader.
Of course my quoting was wrong.
Nonetheless could you add logging/errors if possible?
P
P
pelzflorian (Florian Pelz) wrote on 1 Apr 21:48 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200401194826.uaarkyndzfbi3kqc@pelzflorian.localdomain
On Wed, Apr 01, 2020 at 09:34:58PM +0200, pelzflorian (Florian Pelz) wrote:
Toggle quote (3 lines)> I believe I pass parameters wrongly. I attach how I try to use your> kernel-module-loader.
Also I cannot use gexps in module parameters.
Regards,Florian
B
B
Brice Waegeneire wrote on 2 Apr 14:37 +0200
[PATCH v5] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)
20200402123712.338-1-brice@waegenei.re
* doc/guix.texi (Linux Services): Add a new subsection and document thenew service and its configuration.* gnu/services/linux.scm (kernel-module-loader-service): New procedure.(kernel-module-loader-service-type, kernel-module-loader-configuration):New types.* gnu/tests/linux-modules.scm (module-loader-program): Procedureremoved.(modules-loaded?-program): New procedure.(run-loadable-kernel-modules-test): 'module-loader-program' procedurereplaced by the new one. New format for last arguments[os]: Use 'kernel-module-loader-service'.(%test-loadable-kernel-modules-0, %test-loadable-kernel-modules-1,%test-loadable-kernel-modules-2): Use the new argument format.---
In this version the typos reported by Mathieu have been fixed and if modprobefail the error is logged by shepherd.
doc/guix.texi | 53 +++++++++++++++++++++++++++ gnu/services/linux.scm | 72 ++++++++++++++++++++++++++++++++++++- gnu/tests/linux-modules.scm | 45 ++++++++++++++--------- 3 files changed, 152 insertions(+), 18 deletions(-)
Toggle diff (270 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 8cb85fe62c..ea1d363efc 100644--- a/doc/guix.texi+++ b/doc/guix.texi@@ -76,6 +76,7 @@ Copyright @copyright{} 2020 Damien Cassou@* Copyright @copyright{} 2020 Jakub Kądziołka@* Copyright @copyright{} 2020 Jack Hill@* Copyright @copyright{} 2020 Naga Malleswari@*+Copyright @copyright{} 2020 Brice Waegeneire@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or@@ -25383,6 +25384,58 @@ notifications. @end table @end deftp +@cindex modprobe+@cindex kernel module loader+@subsubsection Kernel Module Loader Service++The @code{kernel-module-loader-service} provides a service to load+kernel modules at boot. This is especially useful for modules that+don't autoload and need to be manually loaded, like it's the case with+@code{ddcci} for example.++@deffn {Scheme Procedure} kernel-module-loader-service @var{modules}+Return a service that runs @command{modprobe} for each given module.+For example loading the drivers provided by @code{ddci-driver-linux}+with @code{ddcci} in debugging mode can be done as follow:++@lisp+(use-modules (gnu))+(use-package-modules linux)+(use-service-modules linux)+(operating-system+ ...+ (services (cons* (kernel-module-loader-service+ '(("ddcci" "dyndbg")+ ("ddcci_backlight")))+ %base-services))+ (kernel-loadable-modules (list ddcci-driver-linux)))+@end lisp+@end deffn++@deffn {Scheme Variable} kernel-module-loader-service-type+The service type for loading kernel modules at boot with+@command{modprobe}, for modules that can't autoload. Its value must be+a @code{kernel-module-loader-configuration} object, described below.+@end deffn++@deftp {Data Type} kernel-module-loader-configuration+The data type representing the modules to be loaded by+@command{modprobe}.+@end deftp++@deftp {Data Type} kernel-module-loader-configuration+This is the configuration record for the+@code{kernel-module-loader-service-type}.++@table @asis+@item @code{modprobe} (default: @code{(file-append kmod "/bin/modprobe"})+The @command{modprobe} executable to use.++@item @code{modules} (default: @code{'()})+A list of list of strings specifying the modules to load with their+optional parameters.+@end table+@end deftp @node Miscellaneous Services @subsection Miscellaneous Servicesdiff --git a/gnu/services/linux.scm b/gnu/services/linux.scmindex caa0326c31..e3942f693d 100644--- a/gnu/services/linux.scm+++ b/gnu/services/linux.scm@@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -25,6 +26,8 @@ #:use-module (gnu packages linux) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26)+ #:use-module (srfi srfi-34)+ #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:export (earlyoom-configuration earlyoom-configuration?@@ -37,7 +40,14 @@ earlyoom-configuration-ignore-positive-oom-score-adj? earlyoom-configuration-show-debug-messages? earlyoom-configuration-send-notification-command- earlyoom-service-type))+ earlyoom-service-type++ kernel-module-loader-configuration+ kernel-module-loader-configuration?+ kernel-module-loader-configuration-modprobe+ kernel-module-loader-configuration-modules+ kernel-module-loader-service-type+ kernel-module-loader-service)) ;;;@@ -123,3 +133,63 @@ representation." (list (service-extension shepherd-root-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon.")))++ +;;;+;;; Kernel module loader.+;;;++(define-record-type* <kernel-module-loader-configuration>+ kernel-module-loader-configuration make-kernel-module-loader-configuration+ kernel-module-loader-configuration?+ ;; path of the 'modprobe' command+ (modprobe kernel-module-loader-configuration-modprobe+ (default (file-append kmod "/bin/modprobe")))+ ;; list of lists of strings+ (modules kernel-module-loader-configuration-modules+ (default '())))++(define kernel-module-loader-shepherd-service+ (match-lambda+ (($ <kernel-module-loader-configuration> modprobe kernel-modules)+ (list+ (shepherd-service+ (documentation "Load kernel modules.")+ (provision '(kernel-module-loader))+ (respawn? #f)+ (one-shot? #t)+ (modules `((srfi srfi-34)+ (srfi srfi-35)+ ,@%default-modules))+ (start+ #~(lambda _+ (guard (c ((message-condition? c)+ (display (condition-message c))+ #f))+ (map (lambda (module-with-parameters)+ (apply invoke/quiet #$modprobe "--"+ module-with-parameters))+ '#$kernel-modules)))))))))++(define kernel-module-loader-service-type+ (service-type+ (name 'kernel-module-loader)+ (description "Load kernel modules.")+ (extensions+ (list+ (service-extension shepherd-root-service-type+ kernel-module-loader-shepherd-service)))+ (compose concatenate)+ (extend (lambda (config modules)+ (kernel-module-loader-configuration+ (inherit config)+ (modules (append+ (kernel-module-loader-configuration-modules config)+ modules)))))+ (default-value (kernel-module-loader-configuration))))++(define* (kernel-module-loader-service modules)+ "Return a service that loads kernel MODULES."+ (service kernel-module-loader-service-type+ (kernel-module-loader-configuration+ (modules modules))))diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scmindex 39e11587c6..2532850d34 100644--- a/gnu/tests/linux-modules.scm+++ b/gnu/tests/linux-modules.scm@@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -19,6 +20,7 @@ (define-module (gnu tests linux-modules) #:use-module (gnu packages linux)+ #:use-module (gnu services linux) #:use-module (gnu system) #:use-module (gnu system vm) #:use-module (gnu tests)@@ -37,25 +39,31 @@ ;;; ;;; Code: -(define* (module-loader-program os modules)- "Return an executable store item that, upon being evaluated, will dry-run-load MODULES."+(define* (modules-loaded?-program os modules)+ "Return an executable store item that, upon being evaluated, will verify+that MODULES are actually loaded." (program-file "load-kernel-modules.scm"- (with-imported-modules (source-module-closure '((guix build utils)))- #~(begin- (use-modules (guix build utils))- (for-each (lambda (module)- (invoke (string-append #$kmod "/bin/modprobe") "-n" "--"- module))- '#$modules)))))+ #~(begin+ (use-modules (ice-9 rdelim)+ (ice-9 popen))+ (let* ((port (open-input-pipe (string-append #$kmod "/bin/lsmod")))+ (output (read-string port))+ (status (close-pipe port)))+ (and-map (lambda (module) (string-contains output module))+ '#$modules))))) -(define* (run-loadable-kernel-modules-test module-packages module-names)- "Run a test of an OS having MODULE-PACKAGES, and modprobe MODULE-NAMES."+(define* (run-loadable-kernel-modules-test module-packages+ modules-with-parameters)+ "Run a test of an OS having MODULE-PACKAGES, and verify that+MODULES-WITH-PARAMETERS are loaded in memory." (define os (marionette-operating-system (operating-system (inherit (simple-operating-system))+ (services (cons (kernel-module-loader-service modules-with-parameters)+ (operating-system-user-services+ (simple-operating-system)))) (kernel-loadable-modules module-packages)) #:imported-modules '((guix combinators)))) (define vm (virtual-machine os))@@ -75,7 +83,9 @@ load MODULES." marionette)) (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0)))))- (gexp->derivation "loadable-kernel-modules" (test (module-loader-program os module-names))))+ (gexp->derivation+ "loadable-kernel-modules"+ (test (modules-loaded?-program os (map car modules-with-parameters))))) (define %test-loadable-kernel-modules-0 (system-test@@ -88,16 +98,17 @@ with no extra modules.") (system-test (name "loadable-kernel-modules-1") (description "Tests loadable kernel modules facility of <operating-system>-with one extra module.")+with one extra module with some parameters.") (value (run-loadable-kernel-modules-test (list ddcci-driver-linux)- '("ddcci")))))+ '(("ddcci" "dyndbg" "delay=120")))))) (define %test-loadable-kernel-modules-2 (system-test (name "loadable-kernel-modules-2") (description "Tests loadable kernel modules facility of <operating-system>-with two extra modules.")+with two extra modules without any parameters.") (value (run-loadable-kernel-modules-test (list acpi-call-linux-module ddcci-driver-linux)- '("acpi_call" "ddcci")))))+ '(("acpi_call")+ ("ddcci"))))))-- 2.25.1
B
B
Brice Waegeneire wrote on 2 Apr 14:40 +0200
Re: [bug#40274] [PATCH v4] gnu: Add kernel-module-loader-service.
(name . pelzflorian (Florian Pelz))(address . pelzflorian@pelzflorian.de)(address . 40274@debbugs.gnu.org)
64e7eade2865209e84940a1cbca3313a@waegenei.re
Hello Florian,
Thank you for trying out this new service.
On 2020-04-01 19:34, pelzflorian (Florian Pelz) wrote:
Toggle quote (10 lines)> I tried with your patch to make the Guix install image load the> uvesafb kernel module, but it fails and I get no log. Is it possible> to make the service log failures?> > I just get:> > failed to load service: kernel-module-loader> > printed on the console (but not to /var/log/messages).
This a message saying it can't load that service, in this case becauseit's parameters weren't formatted correctly, this is not specific tothis service that's how shepherd handle failing to load a service.Please open a new issue about it if you think (as I do) that shepherdshould be more explicit when it fails to load a service.
Regarding this service, logging has been implemented in v5; the outputof modprobe will be logged if it fails, for example when trying to loadan invalid kernel module like “foo”.
- Brice
D
D
Danny Milosavljevic wrote on 2 Apr 15:56 +0200
Re: [bug#40274] [PATCH v5] gnu: Add kernel-module-loader-service.
(name . Brice Waegeneire)(address . brice@waegenei.re)
20200402155640.121e4879@scratchpost.org
Hi Brice,
I wonder how common it is to pass arguments to the modules explicitly in normaloperation.
I haven't done it often even in other distributions--and I'm a kernel hacker.
See also https://linux.die.net/man/5/modprobe.dfor an alternative.
I'm not necessarily against doing it like you do it, but just want to bring upthe possibility of just omitting the functionality and let it besomeone-else's-problem, possibly another guix service that prepares/etc/modprobe.d with module options and other things (aliases, installation andremoval invocations).
That's also important because Linux tries to (lazy-)autoload modules wheneverpossible (via invoking modprobe). In that case, the argument handling wouldbe inconsistent between if it was lazy-autoloaded compared to if it was loadedby your loader.
(I even wonder if it were better for kernel-module-loader-service to read themodprobe to use from /proc/sys/kernel/modprobe in order to make the situationsa little more consistent)
For example let's say the following happened:
(1) Linux boots up.(2) Someone accesses some device so "modprobe foo" is invoked by Linux.(3) foo is loaded, gets options from /etc/modprobe.d (usually none).[Time passes, other stuff happens](4) Your kernel-module-loader-service is started, invokes "modprobe foo x=2".(5) x=2 is not passed to the Linux kernel module ever.
I'm just saying maybe not invite this kind of trouble in the first place.
I don't think it fits Guix's declarative configuration style to do thateither.
Also, when reconfiguring the Guix system, kernel-module-loader-service won'tunload the kernel modules and thus also wouldn't load it with new options.
Also, it could happen that two different guix services require the same modulebut with different options. That's an insane problem to have and I wouldn'ttry to support it.
(I've reviewed your patch, otherwise OK!)
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6F7xgACgkQ5xo1VCwwuqVSlAf/cXcL9VlmptSSYEBlNbKXibrRYJdMtw07amj16IrYtnX5oiLcqEm/jkWFN6Vl/uu1PZn/592Ifx2+2Dc7bJ3NMP1S7hvFy9b5/cQIz5nGxmf+CgDbHGdIKt76wl4pfmGGzTE7qVdU9x+BBUFkU1Aq1qv0wMbAUJFqXecueKYb15SnH7+5aHCklBInwqtQAq01NKzgPz0iONAohl0WXAlws9D+Ru+Kugo94Pt5Lzp8K+hecx7UPpWoh9pd71GWgybbYIEvjlm5AijdbykGXL/wkJi7Y6VpbesfgH7fMpZGThUFqoW5z6Ej7lwlMZnb3knRZSgmeHt3P40zEN422HIIPQ===R/Dn-----END PGP SIGNATURE-----

M
M
Mathieu Othacehe wrote on 2 Apr 16:22 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
87sghm0xyc.fsf@gmail.com
Hello Brice,
Thanks for this new version.
Toggle quote (3 lines)> + (guard (c ((message-condition? c)> + (display (condition-message c))
Maybe `(format (current-error-port) "~a~%" (condition-message c))'instead of display.
Thanks,
Mathieu
B
B
Brice Waegeneire wrote on 2 Apr 19:13 +0200
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
2b32956fc10fd3012388722e1b00ce21@waegenei.re
On 2020-04-02 13:56, Danny Milosavljevic wrote:
Toggle quote (61 lines)> Hi Brice,> > I wonder how common it is to pass arguments to the modules explicitly > in normal> operation.> > I haven't done it often even in other distributions--and I'm a kernel > hacker.> > See also https://linux.die.net/man/5/modprobe.d for an alternative.> > I'm not necessarily against doing it like you do it, but just want to > bring up> the possibility of just omitting the functionality and let it be> someone-else's-problem, possibly another guix service that prepares> /etc/modprobe.d with module options and other things (aliases, > installation and> removal invocations).> > That's also important because Linux tries to (lazy-)autoload modules > whenever> possible (via invoking modprobe). In that case, the argument handling > would> be inconsistent between if it was lazy-autoloaded compared to if it was > loaded> by your loader.> > (I even wonder if it were better for kernel-module-loader-service to > read the> modprobe to use from /proc/sys/kernel/modprobe in order to make the > situations> a little more consistent)> > For example let's say the following happened:> > (1) Linux boots up.> (2) Someone accesses some device so "modprobe foo" is invoked by Linux.> (3) foo is loaded, gets options from /etc/modprobe.d (usually none).> [Time passes, other stuff happens]> (4) Your kernel-module-loader-service is started, invokes "modprobe foo > x=2".> (5) x=2 is not passed to the Linux kernel module ever.> > I'm just saying maybe not invite this kind of trouble in the first > place.> > I don't think it fits Guix's declarative configuration style to do that> either.> > Also, when reconfiguring the Guix system, kernel-module-loader-service > won't> unload the kernel modules and thus also wouldn't load it with new > options.> > Also, it could happen that two different guix services require the same > module> but with different options. That's an insane problem to have and I > wouldn't> try to support it.> > (I've reviewed your patch, otherwise OK!)
Hello Danny,
Thank for taking the time to review this patch. Since I'm definitely *not*a kernel hacker --just a casual user-- I wasn't aware of the uselessness ofspecifying the module arguments to modprobe in such service. I wrote thispatch just to load this pesky non auto-loading `ddcci-backlight` module andI have no current use of specifying module arguments. I just thought it*could* be useful, to some, to pass arguments to modprobe since it ispresent in its API; but the edge-cases you brought up show that it wasn't agood idea after all.
Should I just go back to the first format, with just a list of modulenames, and we merge this patch? Or would it be better, regarding the userinterface, to start this patch anew by using `modprobe.d` API as a base.By that I mean defining a `modprobe-service-type` which populates`/etc/modprobe.d/` and can manually load a module at boot if needed (likekernel-module-loader does)? Would it be overkill? Following is an example ofwhat such service could look like:
#+begin_src scheme(service modprobe-service-type (list (modprobe-entry (module "ddcci") (load? #t) (options '("dyndbg" "delay=120")) (alises '("ddc/ci")) (install "") ; default (remove "")) ; default (modprobe-entry (module "acpi-call") (blacklist? #t))))#+end_src
- Brice
D
D
Danny Milosavljevic wrote on 3 Apr 12:20 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)
20200403122044.2f9e2552@scratchpost.org
Hi Brice,
On Thu, 02 Apr 2020 17:13:05 +0000Brice Waegeneire <brice@waegenei.re> wrote:
Toggle quote (3 lines)> *could* be useful, to some, to pass arguments to modprobe since it is> present in its API;
Definitely could be useful. The question is whether the complexity justifies itand whether it can be reliable.
Toggle quote (3 lines)> Should I just go back to the first format, with just a list of module> names, and we merge this patch?
I would like that more since it's very improbable to ever need changing.
Toggle quote (10 lines)>Or would it be better, regarding the > user> interface, to start this patch anew by using `modprobe.d` API as a base.> By that I mean defining a `modprobe-service-type` which populates> `/etc/modprobe.d/` and can manually load a module at boot if needed > (like> kernel-module-loader does)? Would it be overkill? Following is an > example of> what such service could look like:
I think the two things (loading a module and configuring a module) can beseperate, so I wouldn't mix it.
For example why would you load a module before the service that needsit actually starts up (if ever)? That just increases the attack surface for no reason. On the other hand, module configuration will probably bedone as part of some guix service presence--used or not.
That said, maybe there are upsides to--among other things easier-understandableconfiguration if it's central.
Toggle quote (13 lines)> #+begin_src scheme> (service modprobe-service-type> (list (modprobe-entry> (module "ddcci")> (load? #t)> (options '("dyndbg" "delay=120"))> (alises '("ddc/ci"))> (install "") ; default> (remove "")) ; default> (modprobe-entry> (module "acpi-call")> (blacklist? #t))))
A service to do that would still be nice. But maybe"kernel-module-configuration-service" ?
(Please don't think I have all the answers, let's see which way is better)
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6HDfwACgkQ5xo1VCwwuqUsAAgAob3KNEkmMLjYLY1uztGTqcAPd1mv51woMd5x9aaQtwYvgBBWzDXSl6nL2y7kM6AbtVxPSSrqlvZFk0OMZvqOJfq7oz/vBsyPFGJCVD9vISZqi0CyYgC9sRCqDoWIUc6Wvo2+hTGEvTabamitaIFIgyJfkm0UUsyXq7X13NqiS04ReCwabUbbRu0HYS+7a2CBJ2WvWmHhgANr7BTVNNlrPEdu4KWKFcB/NppSCjAnJfMF7VcQYlBxZDQ+9iRM9hBPAgNNAnS6KbROyZYcGzPEKE7T4mk3WlinF2CvlQ/pEzDuiDlbeYWOqgxLKeVAm4/pDTssRfVwKYcbAeR//4RYUg===jwhD-----END PGP SIGNATURE-----

P
P
pelzflorian (Florian Pelz) wrote on 3 Apr 14:58 +0200
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20200403125839.bci5jduvxrhvw673@pelzflorian.localdomain
On Fri, Apr 03, 2020 at 12:20:44PM +0200, Danny Milosavljevic wrote:
Toggle quote (6 lines)> On Thu, 02 Apr 2020 17:13:05 +0000 Brice Waegeneire <brice@waegenei.re> wrote:> > *could* be useful, to some, to pass arguments to modprobe since it is> > present in its API; > Definitely could be useful. The question is whether the complexity justifies it> and whether it can be reliable.
I need modprobe arguments in some way via some service to pass to theuvesafb module to make graphics and kmscon work on machines withoutKernel Mode Setting (see attachment), but the (string-append …) is notexecuted as a procedure, it seems.
Apr 3 14:54:45 localhost vmunix: [ 9.860831] shepherd[1]: Service user-homes has been started.Apr 3 14:54:45 localhost vmunix: [ 9.880505] shepherd[1]: '/gnu/store/d064bv2b1hrb07j2zj78i608db7qldx9-kmod-26/bin/modprobe -- uvesafb (string-append v86d= /gnu/store/0m780n5q4cr7rqmjn5zzd6adr3042f97-v86d-0.1.10 /sbin/v86d) mode_option=1024x768' exited with status 127; output follows:Apr 3 14:54:45 localhost vmunix: [ 9.881867] shepherd[1]: Apr 3 14:54:45 localhost vmunix: [ 9.883595] shepherd[1]: Service kernel-module-loader could not be started.
Regards,Florian
Toggle diff (52 lines)diff --git a/gnu/system/install.scm b/gnu/system/install.scmindex c15c2c7814..7327efe195 100644--- a/gnu/system/install.scm+++ b/gnu/system/install.scm@@ -26,11 +26,13 @@ #:use-module (gnu bootloader u-boot) #:use-module (guix gexp) #:use-module (guix store)+ #:use-module (guix utils) #:use-module (guix monads) #:use-module ((guix packages) #:select (package-version)) #:use-module ((guix store) #:select (%store-prefix)) #:use-module (gnu installer) #:use-module (gnu services dbus)+ #:use-module (gnu services linux) #:use-module (gnu services networking) #:use-module (gnu services shepherd) #:use-module (gnu services ssh)@@ -50,6 +52,7 @@ #:use-module (gnu packages texinfo) #:use-module (gnu packages compression) #:use-module (gnu packages nvi)+ #:use-module (gnu packages xorg) #:use-module (ice-9 match) #:use-module (srfi srfi-26) #:export (installation-os@@ -304,7 +307,8 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m (define bare-bones-os (load "examples/bare-bones.tmpl")) - (list (service virtual-terminal-service-type)+ (cons*+ (service virtual-terminal-service-type) (service kmscon-service-type (kmscon-configuration@@ -408,7 +412,14 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m (list bare-bones-os glibc-utf8-locales texinfo- (canonical-package guile-2.2))))))+ (canonical-package guile-2.2)))+ (if (member (%current-system) '("x86_64-linux" "i686-linux"))+ ;; Load uvesafb to show installer when no KMS is available.+ `(,(kernel-module-loader-service+ (list (list "uvesafb"+ #~(string-append "v86d=" #$v86d "/sbin/v86d")+ "mode_option=1024x768"))))+ '())))) (define %issue ;; Greeting.
P
P
pelzflorian (Florian Pelz) wrote on 3 Apr 15:03 +0200
Re: [bug#40274] [PATCH v4] gnu: Add kernel-module-loader-service.
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200403130316.ksrqtl6eq2amjmcl@pelzflorian.localdomain
On Thu, Apr 02, 2020 at 12:40:00PM +0000, Brice Waegeneire wrote:
Toggle quote (8 lines)> On 2020-04-01 19:34, pelzflorian (Florian Pelz) wrote:> > failed to load service: kernel-module-loader> This a message saying it can't load that service, in this case because> it's parameters weren't formatted correctly, this is not specific to> this service that's how shepherd handle failing to load a service.> Please open a new issue about it if you think (as I do) that shepherd> should be more explicit when it fails to load a service.
I meant compilation could fail if the parameters are incorrect. I donot know how else Shepherd should fail. But this is not veryimportant and applies to many other services as well.
Thank you for adding logging. All this works well (in testing, I havenot read the code).
Regards,Florian
D
D
Danny Milosavljevic wrote on 4 Apr 12:51 +0200
Re: [bug#40274] [PATCH v5] gnu: Add kernel-module-loader-service.
(name . Brice Waegeneire)(address . brice@waegenei.re)
20200404125135.5bef66bf@scratchpost.org
Furthermore, many modules could be built-into the kernel (instead of loadable), too. Then the "module" options somehow have to make it into the kernel command line as "module_name.parameter_name=parameter_value".
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6IZrcACgkQ5xo1VCwwuqXwNwf9F0lOrnFhZZRfRUkRGwkNsVdB3rrFLiTmpZ5ULyEGqjd9UejYhI+aQNlcHLMroX7F3pkfamCUMAzbpElVi69lWzO0UucdxfzICCtGtHzSzrA132AyI0MGO1BHlkto37el0OEqhFOKYVv7c+L6xx36HqnbXZVyYefrJOvdGv8F3VNLWHZP28H4Fa3x3wAsEAvpjcWft1YPOMUM0d46/jjVYq+AzdMnX0HEAjLDfknZFIRY/QmqFrfBFu5VPeCjdVJcEl68YnCGjVmdKvHT/l/OkHmhAShDsn6QwQ7jMVsHNJpeR76iTLq9sjLtn6wHj/5l8szdcgYlR1juoj/dabHAhw===qlAe-----END PGP SIGNATURE-----

B
B
Brice Waegeneire wrote on 4 Apr 17:17 +0200
[PATCH v6 0/2] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)
20200404151732.20341-1-brice@waegenei.re
Hello,
The following modification have been made since the previous patch version:- The format to specify kernel modules has been reverted to a simple list of strings.- The `modprobe` command used is retrieved from "/proc/sys/kernel/modprobe".- Thanks to the previously listed modifications, `kernel-module-loader-service-type` has been removed together with the helper function `kernel-module-loader-service`. No need to bother with a record now that we only need a list of strings.- A temporary crutch to force `modprobe` from loading "/etc/modprobe.d" has been added. The permanent fix has been submitted as #40422[0] but it needs to go trough the core-updates branch.- The documentation has been updated accordingly.- An example showing how to specify module arguments using "/etc/modprobe.d/" has been added to the documentation.
[0]: https://issues.guix.info/issue/40422
- Brice
Brice Waegeneire (2): services: Allow modprobe to use "/etc/modprobe.d". gnu: Add kernel-module-loader-service.
doc/guix.texi | 38 +++++++++++++++++++++++++++ gnu/services.scm | 4 +++ gnu/services/linux.scm | 52 ++++++++++++++++++++++++++++++++++++- gnu/tests/linux-modules.scm | 33 ++++++++++++++--------- 4 files changed, 114 insertions(+), 13 deletions(-)
-- 2.26.0
B
B
Brice Waegeneire wrote on 4 Apr 17:17 +0200
[PATCH v6 1/2] services: Allow modprobe to use "/etc/modprobe.d".
(address . guix-patches@gnu.org)
20200404151732.20341-2-brice@waegenei.re
This is a temporary crutch allowing 'modprobe' to load it'sconfiguration from "/etc/modprobe.d". The definitive fix is contained inhttps://issues.guix.info/issue/40422 which need to go trough thecore-upates branch as it rebuild over 2200 packages.
* gnu/services.scm (%modprobe-wrapper): Set 'MODPROBE_OPTIONS'environment variable.--- gnu/services.scm | 4 ++++ 1 file changed, 4 insertions(+)
Toggle diff (17 lines)diff --git a/gnu/services.scm b/gnu/services.scmindex e7a3a95e43..1c39c779a7 100644--- a/gnu/services.scm+++ b/gnu/services.scm@@ -579,6 +579,10 @@ ACTIVATION-SCRIPT-TYPE." #~(begin (setenv "LINUX_MODULE_DIRECTORY" "/run/booted-system/kernel/lib/modules")+ ;; FIXME: Remove this crutch when the patch #40422,+ ;; updating to kmod 27 is merged+ (setenv "MODPROBE_OPTIONS"+ "-C /etc/modprobe.d") (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))) -- 2.26.0
B
B
Brice Waegeneire wrote on 4 Apr 17:17 +0200
[PATCH v6 2/2] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)
20200404151732.20341-3-brice@waegenei.re
* doc/guix.texi (Linux Services): Add a new subsection and document thenew service and its configuration.* gnu/services/linux.scm (kernel-module-loader-service-type): New type.(kernel-module-loader-shepherd-service): New procedure.* gnu/tests/linux-modules.scm (module-loader-program): Procedureremoved.(modules-loaded?-program): New procedure.(run-loadable-kernel-modules-test): 'module-loader-program' procedurereplaced by the new one.[os]: Use 'kernel-module-loader-service'.--- doc/guix.texi | 38 +++++++++++++++++++++++++++ gnu/services/linux.scm | 52 ++++++++++++++++++++++++++++++++++++- gnu/tests/linux-modules.scm | 33 ++++++++++++++--------- 3 files changed, 110 insertions(+), 13 deletions(-)
Toggle diff (211 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 8cb85fe62c..b18413f685 100644--- a/doc/guix.texi+++ b/doc/guix.texi@@ -76,6 +76,7 @@ Copyright @copyright{} 2020 Damien Cassou@* Copyright @copyright{} 2020 Jakub Kądziołka@* Copyright @copyright{} 2020 Jack Hill@* Copyright @copyright{} 2020 Naga Malleswari@*+Copyright @copyright{} 2020 Brice Waegeneire@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or@@ -25383,6 +25384,43 @@ notifications. @end table @end deftp +@cindex modprobe+@cindex kernel module loader+@subsubsection Kernel Module Loader Service++The kernel module loader service allows one to load, at boot, loadable+kernel modules---in opposition to built-in kernel modules which should+be added to the @code{kernel-arguments} field instead. This is+especially useful for modules that don't autoload and need to be+manually loaded, as it's the case with @code{ddcci} for example.++@deffn {Scheme Variable} kernel-module-loader-service-type+The service type for loading loadable kernel modules at boot with+@command{modprobe}. Its value must be a list of strings representing+module names. For example loading the drivers provided by+@code{ddci-driver-linux}, in debugging mode by passing some module+parameters, can be done as follow:++@lisp+(use-modules (gnu) (gnu services))+(use-package-modules linux)+(use-service-modules linux)++(define ddcci-config+ (plain-file "ddcci.conf"+ "options ddcci dyndbg delay=120"))++(operating-system+ ...+ (services (cons* (service kernel-module-loader-service-type+ '("ddcci" "ddcci_backlight"))+ (simple-service 'ddcci-config etc-service-type+ (list `("modprobe.d/ddcci.conf"+ ,ddcci-config)))+ %base-services))+ (kernel-loadable-modules (list ddcci-driver-linux)))+@end lisp+@end deffn @node Miscellaneous Services @subsection Miscellaneous Servicesdiff --git a/gnu/services/linux.scm b/gnu/services/linux.scmindex caa0326c31..621d26fcff 100644--- a/gnu/services/linux.scm+++ b/gnu/services/linux.scm@@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -25,6 +26,8 @@ #:use-module (gnu packages linux) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26)+ #:use-module (srfi srfi-34)+ #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:export (earlyoom-configuration earlyoom-configuration?@@ -37,7 +40,9 @@ earlyoom-configuration-ignore-positive-oom-score-adj? earlyoom-configuration-show-debug-messages? earlyoom-configuration-send-notification-command- earlyoom-service-type))+ earlyoom-service-type++ kernel-module-loader-service-type)) ;;;@@ -123,3 +128,48 @@ representation." (list (service-extension shepherd-root-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon.")))++ +;;;+;;; Kernel module loader.+;;;++(define kernel-module-loader-shepherd-service+ (match-lambda+ ((and (? list? kernel-modules) ((? string?) ...))+ (list+ (shepherd-service+ (documentation "Load kernel modules.")+ (provision '(kernel-module-loader))+ (requirement '(file-systems))+ (respawn? #f)+ (one-shot? #t)+ (modules `((srfi srfi-34)+ (srfi srfi-35)+ ,@%default-modules))+ (start+ #~(lambda _+ (if (file-exists? "/proc/sys/kernel/modprobe")+ (let ((modprobe (call-with-input-file+ "/proc/sys/kernel/modprobe" get-line)))+ (guard (c ((message-condition? c)+ (format (current-error-port) "~a~%"+ (condition-message c))+ #f))+ (map (lambda (module)+ (invoke/quiet modprobe "--" module))+ '#$kernel-modules)))+ (begin (format (current-error-port) "error: ~a~%"+ "Kernel is missing loadable module support.")+ #f)))))))))++(define kernel-module-loader-service-type+ (service-type+ (name 'kernel-module-loader)+ (description "Load kernel modules.")+ (extensions+ (list (service-extension shepherd-root-service-type+ kernel-module-loader-shepherd-service)))+ (compose concatenate)+ (extend append)+ (default-value '())))diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scmindex 39e11587c6..f1c4feb7a0 100644--- a/gnu/tests/linux-modules.scm+++ b/gnu/tests/linux-modules.scm@@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -19,6 +20,8 @@ (define-module (gnu tests linux-modules) #:use-module (gnu packages linux)+ #:use-module (gnu services)+ #:use-module (gnu services linux) #:use-module (gnu system) #:use-module (gnu system vm) #:use-module (gnu tests)@@ -37,25 +40,30 @@ ;;; ;;; Code: -(define* (module-loader-program os modules)- "Return an executable store item that, upon being evaluated, will dry-run-load MODULES."+(define* (modules-loaded?-program os modules)+ "Return an executable store item that, upon being evaluated, will verify+that MODULES are actually loaded." (program-file "load-kernel-modules.scm"- (with-imported-modules (source-module-closure '((guix build utils)))- #~(begin- (use-modules (guix build utils))- (for-each (lambda (module)- (invoke (string-append #$kmod "/bin/modprobe") "-n" "--"- module))- '#$modules)))))+ #~(begin+ (use-modules (ice-9 rdelim)+ (ice-9 popen))+ (let* ((port (open-input-pipe (string-append #$kmod "/bin/lsmod")))+ (output (read-string port))+ (status (close-pipe port)))+ (and-map (lambda (module) (string-contains output module))+ '#$modules))))) (define* (run-loadable-kernel-modules-test module-packages module-names)- "Run a test of an OS having MODULE-PACKAGES, and modprobe MODULE-NAMES."+ "Run a test of an OS having MODULE-PACKAGES, and verify that MODULE-NAMES+are loaded in memory." (define os (marionette-operating-system (operating-system (inherit (simple-operating-system))+ (services (cons (service kernel-module-loader-service-type module-names)+ (operating-system-user-services+ (simple-operating-system)))) (kernel-loadable-modules module-packages)) #:imported-modules '((guix combinators)))) (define vm (virtual-machine os))@@ -75,7 +83,8 @@ load MODULES." marionette)) (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0)))))- (gexp->derivation "loadable-kernel-modules" (test (module-loader-program os module-names))))+ (gexp->derivation "loadable-kernel-modules"+ (test (modules-loaded?-program os module-names)))) (define %test-loadable-kernel-modules-0 (system-test-- 2.26.0
M
M
Mathieu Othacehe wrote on 4 Apr 17:53 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
87h7xztfg4.fsf@gmail.com
Hello Brice,
I think what you discussed with Danny, separating module loading fromconfiguration is very wise.
Toggle quote (4 lines)> +The kernel module loader service allows one to load, at boot, loadable> +kernel modules---in opposition to built-in kernel modules which should> +be added to the @code{kernel-arguments} field instead. This is
Using kernel-arguments you can configure built-in modules but you cannotforce them to show-up, at least for most device drivers. For thosedevice drivers, loading of built-in modules is based on hardware probingat boot-time.
So I would just stick with:
"The kernel module loader service allows one to load, at boot time,specific kernel modules."
Toggle quote (4 lines)> +(define ddcci-config> + (plain-file "ddcci.conf"> + "options ddcci dyndbg delay=120"))
Having the modprobe-service-type you proposed earlier, would be supernice to do that :)
Toggle quote (9 lines)> +> +(operating-system> + ...> + (services (cons* (service kernel-module-loader-service-type> + '("ddcci" "ddcci_backlight"))> + (simple-service 'ddcci-config etc-service-type> + (list `("modprobe.d/ddcci.conf"> + ,ddcci-config)))
Great!
This seems really nice to me.
Mathieu
P
P
pelzflorian (Florian Pelz) wrote on 4 Apr 18:09 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200404160954.js2zya4un7ohngy7@pelzflorian.localdomain
On Sat, Apr 04, 2020 at 05:17:30PM +0200, Brice Waegeneire wrote:
Toggle quote (11 lines)> Hello,> > The following modification have been made since the previous patch version:> - The format to specify kernel modules has been reverted to a simple list of> strings.> - The `modprobe` command used is retrieved from "/proc/sys/kernel/modprobe".> - Thanks to the previously listed modifications,> `kernel-module-loader-service-type` has been removed together with the> helper function `kernel-module-loader-service`. No need to bother with a> record now that we only need a list of strings.
You mean you removed kernel-module-loader-configuration.
Regarding patch 2/2:
On Sat, Apr 04, 2020 at 05:17:32PM +0200, Brice Waegeneire wrote:
Toggle quote (3 lines)> +module names. For example loading the drivers provided by> +@code{ddci-driver-linux}, in debugging mode by passing some module
This is a typo. I can only find ddcci-driver-linux.

Thank you for this patch. I do not know enough to judge the code. Iwill try again if it helps me load uvesafb.
Regards,Florian
B
B
Brice Waegeneire wrote on 4 Apr 18:49 +0200
(name . pelzflorian (Florian Pelz))(address . pelzflorian@pelzflorian.de)
b8d6e200afca02da22e275f6d87be8a4@waegenei.re
Hello Florian,
Thank you for the interest you have in this patch series.
On 2020-04-04 16:09, pelzflorian (Florian Pelz) wrote:
Toggle quote (10 lines)> On Sat, Apr 04, 2020 at 05:17:30PM +0200, Brice Waegeneire wrote:>> - Thanks to the previously listed modifications,>> `kernel-module-loader-service-type` has been removed together with >> the>> helper function `kernel-module-loader-service`. No need to bother >> with a>> record now that we only need a list of strings.> > You mean you removed kernel-module-loader-configuration.
Yes.
Toggle quote (8 lines)> Regarding patch 2/2:> > On Sat, Apr 04, 2020 at 05:17:32PM +0200, Brice Waegeneire wrote:>> +module names. For example loading the drivers provided by>> +@code{ddci-driver-linux}, in debugging mode by passing some module> > This is a typo. I can only find ddcci-driver-linux.
Good catch! DDC/CI what a silly name...
Toggle quote (3 lines)> Thank you for this patch. I do not know enough to judge the code. I> will try again if it helps me load uvesafb.
Please do send feedback on using it, especially since you are the only onein need of specifying module parameters ATM. I kept your usage in mind whenwriting this patch version.
- Brice
P
P
pelzflorian (Florian Pelz) wrote on 4 Apr 19:46 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)
20200404174634.2iswkauau7wmzzsu@pelzflorian.localdomain
On Sat, Apr 04, 2020 at 04:49:16PM +0000, Brice Waegeneire wrote:
Toggle quote (6 lines)> Please do send feedback on using it, especially since you are the only one> in need of specifying module parameters ATM. I kept your usage in mind when> writing this patch version.> > - Brice
It does not seem to work. There is nothing in /var/log/messages butwhen I do
root@gnu.org # herd start kernel-module-loaderherd: exception caught while executing 'start' on service 'kernel-module-loader':In procedure module-lookup: Unbound variable: get-line
I attach my changes.
Regards,Florian
Toggle diff (61 lines)diff --git a/gnu/system/install.scm b/gnu/system/install.scmindex c15c2c7814..1348c63f25 100644--- a/gnu/system/install.scm+++ b/gnu/system/install.scm@@ -26,11 +26,13 @@ #:use-module (gnu bootloader u-boot) #:use-module (guix gexp) #:use-module (guix store)+ #:use-module (guix utils) #:use-module (guix monads) #:use-module ((guix packages) #:select (package-version)) #:use-module ((guix store) #:select (%store-prefix)) #:use-module (gnu installer) #:use-module (gnu services dbus)+ #:use-module (gnu services linux) #:use-module (gnu services networking) #:use-module (gnu services shepherd) #:use-module (gnu services ssh)@@ -50,6 +52,7 @@ #:use-module (gnu packages texinfo) #:use-module (gnu packages compression) #:use-module (gnu packages nvi)+ #:use-module (gnu packages xorg) #:use-module (ice-9 match) #:use-module (srfi srfi-26) #:export (installation-os@@ -304,7 +307,8 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m (define bare-bones-os (load "examples/bare-bones.tmpl")) - (list (service virtual-terminal-service-type)+ (cons*+ (service virtual-terminal-service-type) (service kmscon-service-type (kmscon-configuration@@ -408,7 +412,23 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m (list bare-bones-os glibc-utf8-locales texinfo- (canonical-package guile-2.2))))))+ (canonical-package guile-2.2)))+ (if (member (%current-system) '("x86_64-linux" "i686-linux"))+ ;; Load uvesafb to show installer when no KMS is available.+ `(,(service kernel-module-loader-service-type '("uvesafb"))+ ,(let ((uvesafb-options+ #~(with-output-to-file #$output+ (lambda _+ (format #t+ (string-join `("options" "uvesafb"+ ,(string-append "v86d=" #$v86d+ "/sbin/v86d")+ "mode_option=1024x768")))))))+ (simple-service 'uvesafb-configuration etc-service-type+ (list `("modprobe.d/uvesafb.conf"+ ,(computed-file "uvesafb-options"+ uvesafb-options))))))+ '())))) (define %issue ;; Greeting.
B
B
Brice Waegeneire wrote on 4 Apr 19:58 +0200
Re: [bug#40274] [PATCH v5] gnu: Add kernel-module-loader-service.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
9ed8ed843f7a66dc306679885a641514@waegenei.re
Hello,
On 2020-04-03 10:20, Danny Milosavljevic wrote:
Toggle quote (18 lines)> On Thu, 02 Apr 2020 17:13:05 +0000> Brice Waegeneire <brice@waegenei.re> wrote:>> #+begin_src scheme>> (service modprobe-service-type>> (list (modprobe-entry>> (module "ddcci")>> (load? #t)>> (options '("dyndbg" "delay=120"))>> (alises '("ddc/ci"))>> (install "") ; default>> (remove "")) ; default>> (modprobe-entry>> (module "acpi-call")>> (blacklist? #t))))> > A service to do that would still be nice. But maybe> "kernel-module-configuration-service" ?
A lengthy one but a better one for sure.
Toggle quote (3 lines)> (Please don't think I have all the answers, let's see which way is > better)
I don't but you seems to have more answers than I have on this specific subject.We are on the same page here, the best interface should be the one that getmerged!
As you suggested, I choose to go back to the list of string format. It simplifiedthe boilerplate a lot: no record and no helper function. Yet it still allows passingarguments to modules by extending `etc-service-type` to create"/etc/modprobe.d/*.conf" files, and avoids all the pitfalls of the previous methodyou made me aware off.
As `kernel-module-loader-service-type` is extensible it would be possible, in another patch series, if the need arises, to create a `kernel-module-configuration-service`centralizing loadable modules configuration. But like you noted it would be specificto loadable modules and not built-in ones since `kernel-arguments` is just an OSfield, which AFAIK can't be influenced by a service.
Thank you for your help Danny.
- Brice
D
D
Danny Milosavljevic wrote on 4 Apr 20:31 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)
20200404203128.0cc37fca@scratchpost.org
Hi Brice,
Toggle quote (6 lines)>But like you noted it would > be specific> to loadable modules and not built-in ones since `kernel-arguments` is > just an OS> field, which AFAIK can't be influenced by a service.
There's no one stopping us from extending operating-system-kernel-arguments,which already exists as a helper procedure, to also calloperating-system-services and check those for the command line argumentsto add (see gnu/system.scm).
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6I0oAACgkQ5xo1VCwwuqUPXAgAlOS3yl9VVopUcmRf2TjjcNEM0sUdPf8oGtxJ2LqvJQxgsk8Tpcs16qEqv+DiVxh/+uWJLEDakTkYrTXfl6GRMC3ODCLGtcTn1DJq373mE3SNVGxh+CvhMyQLqIUEVgXw86Y6sKRU+kPXbrb0l1MJ7bVLLQkSac5qWE8K6x3dSL766E4EqhcZ8zPmDPhhJ6dKr7bVLSHjv+aGNnIFD93XfgUXjSVXLNGYLTc4cQtMPC2dJM9LroOhvwvCN0ms2yimzmBL9e7uZSZmlyBUWGfjGRS43syk+AK5a1ZiMrbfXU2tQSmsK+cDbIr181L8MvmOEfxp/wOuZjvNFecLrnawqg===9wOr-----END PGP SIGNATURE-----

D
D
Danny Milosavljevic wrote on 4 Apr 23:10 +0200
Re: [bug#40274] [PATCH v6 2/2] gnu: Add kernel-module-loader-service.
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200404231004.0097cf70@scratchpost.org
On Sat, 4 Apr 2020 17:17:32 +0200Brice Waegeneire <brice@waegenei.re> wrote:
Toggle quote (2 lines)> get-line
Missing (ice-9 rdelim) ?
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6I96wACgkQ5xo1VCwwuqVCyAf/W+A/jxGIS9Ek+tK5+vvHPhZGzWc/fImkHtZLTAz8muc7833o78FtwS7dm85AjjWiOqdOQMx178QI3y0BPJdJu8ClqljliFZmzxvP/tDBzBbRDXdni9NTl14P6McGvZVgTYhqBcB7KIrDFTMSusXoaIFk2kHVqCtJQDrbsQhSulOUbACJ/pJfpgaObk8vRESo3ZoJ2T6FhAtwf0bcaoE3pRHyv3j4DlajPaB0JW14rcT9Fhhl1Vn/MsQroM8dOn/h81AnSeUzqoP37wsVtj8EXv0wVAqHQPOcxsMTHfzcqUsyHgJgfZ9L/tXvPuFaUv7oCPjlQ7ed5tweFrRwz5gnBQ===iA0r-----END PGP SIGNATURE-----

D
D
Danny Milosavljevic wrote on 4 Apr 23:11 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200404231144.05552175@scratchpost.org
On Sat, 4 Apr 2020 23:10:04 +0200Danny Milosavljevic <dannym@scratchpost.org> wrote:
Toggle quote (7 lines)> On Sat, 4 Apr 2020 17:17:32 +0200> Brice Waegeneire <brice@waegenei.re> wrote:> > > get-line > > Missing (ice-9 rdelim) ?
I meant (ice-9 textual-ports)
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6I+BAACgkQ5xo1VCwwuqUm1wf+LXtRiJKp/P3Z2KF3OB+AVc8L7WxZ6RqVpx6SP1JhbQebLwUUir9O5dRnv+Qfg5r6P5VJuqnc5pYHA1pK38P1F2K3YXuGJzQA8UoTzc1B6hFjyGBlHI8hmiYeK0T29IJLYTjOhgCKHkfdkQh1jwvX1Y9Buva+1cRREv6GMmpx2kpVsLC3fnTM0eztJl4fTxgew7K0Q6GcZo84jHioOPsYIRXDzacUkqEtbLfaYyIgwjcFiIQtuAC6RtTppy+SK4qRrq5U2dLmK0jluRnkKnDqbamcA2ZwRDKA3rHg8U+AN5QrhNO6lWjuBWN6v2b1ifrwNe5eWv6K+bGZUlvJ2wdBwQ===NaJ3-----END PGP SIGNATURE-----

D
D
Danny Milosavljevic wrote on 4 Apr 23:16 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200404231655.0dfd60d7@scratchpost.org
What happens in the case that kernel-module-loader-service is used but nomodules to load are specified? IMO that should be succeeding even in thepresence of a Linux kernel with no loadable module support.
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6I+UcACgkQ5xo1VCwwuqVCaAf/Z4rH3r5+yo2SbjK/RNCCcJL1Y/w3qBdPZP50+GmLB0psbVtUOz3u1+j08vLJ866zg1eNuzOUmClYL9XzU7M3jnjxkupZAIbt16Qw64ITMlGN9JHwIGOLYRrlSts5LGvPYdCInCauhgm1OZ7/+6sdT2gERXM8gejr/lDM6s96YMkQKxSX14CyLBYHmsABXOckzrNUwdVtTS5Mfmx3asAouK3wSxY5SOI90qiBRs4ZDLagnqmHsqEcW4nbYwwgabgowwhtMdc7HUSz8KD+TZ5+XyI7v4zGphcM37FCnlFJZwgkOrzQXdaqCp4vlNeQQoNbHq6GonMqCARbSPaSaOFFxw===vrXc-----END PGP SIGNATURE-----

P
P
pelzflorian (Florian Pelz) wrote on 5 Apr 01:06 +0200
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20200404230610.obw47uab3utwhge4@pelzflorian.localdomain
On Sat, Apr 04, 2020 at 11:11:44PM +0200, Danny Milosavljevic wrote:
Toggle quote (2 lines)> I meant (ice-9 textual-ports)
Yes. I change Brice’s kernel-module-loader-shepherd-service (seeattachment) and everything works perfectly.
Thank you!
Regards,Florian
Toggle diff (14 lines)diff --git a/gnu/services/linux.scm b/gnu/services/linux.scmindex 621d26fcff..61a7dbb9a1 100644--- a/gnu/services/linux.scm+++ b/gnu/services/linux.scm@@ -151,7 +151,8 @@ representation." #~(lambda _ (if (file-exists? "/proc/sys/kernel/modprobe") (let ((modprobe (call-with-input-file- "/proc/sys/kernel/modprobe" get-line)))+ "/proc/sys/kernel/modprobe"+ (@ (ice-9 textual-ports) get-line)))) (guard (c ((message-condition? c) (format (current-error-port) "~a~%" (condition-message c))
B
B
Brice Waegeneire wrote on 5 Apr 07:28 +0200
[PATCH v7 0/2] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)
20200405052803.15711-1-brice@waegenei.re
This new revision:- fix a typo in the documentation- remove the part about built-in modules in the documentation- add a missing Guile module to `kernel-module-loader-shepherd-service`- `kernel-module-loader-shepherd-service` doesn't fail when the kernel don't support loadable module and there if no module are to be loaded
Brice Waegeneire (2): services: Allow modprobe to use "/etc/modprobe.d". gnu: Add kernel-module-loader-service.
doc/guix.texi | 37 +++++++++++++++++++++++++ gnu/services.scm | 4 +++ gnu/services/linux.scm | 54 ++++++++++++++++++++++++++++++++++++- gnu/tests/linux-modules.scm | 33 ++++++++++++++--------- 4 files changed, 115 insertions(+), 13 deletions(-)
-- 2.26.0
B
B
Brice Waegeneire wrote on 5 Apr 07:28 +0200
[PATCH v7 1/2] services: Allow modprobe to use "/etc/modprobe.d".
(address . guix-patches@gnu.org)
20200405052803.15711-2-brice@waegenei.re
This is a temporary crutch allowing 'modprobe' to load it'sconfiguration from "/etc/modprobe.d". The definitive fix is contained inhttps://issues.guix.info/issue/40422 which need to go trough thecore-upates branch as it rebuild over 2200 packages.
* gnu/services.scm (%modprobe-wrapper): Set 'MODPROBE_OPTIONS'environment variable.--- gnu/services.scm | 4 ++++ 1 file changed, 4 insertions(+)
Toggle diff (17 lines)diff --git a/gnu/services.scm b/gnu/services.scmindex e7a3a95e43..1c39c779a7 100644--- a/gnu/services.scm+++ b/gnu/services.scm@@ -579,6 +579,10 @@ ACTIVATION-SCRIPT-TYPE." #~(begin (setenv "LINUX_MODULE_DIRECTORY" "/run/booted-system/kernel/lib/modules")+ ;; FIXME: Remove this crutch when the patch #40422,+ ;; updating to kmod 27 is merged+ (setenv "MODPROBE_OPTIONS"+ "-C /etc/modprobe.d") (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))) -- 2.26.0
B
B
Brice Waegeneire wrote on 5 Apr 07:28 +0200
[PATCH v7 2/2] gnu: Add kernel-module-loader-service.
(address . guix-patches@gnu.org)
20200405052803.15711-3-brice@waegenei.re
* doc/guix.texi (Linux Services): Add a new subsection and document thenew service and its configuration.* gnu/services/linux.scm (kernel-module-loader-service-type): New type.(kernel-module-loader-shepherd-service): New procedure.* gnu/tests/linux-modules.scm (module-loader-program): Procedureremoved.(modules-loaded?-program): New procedure.(run-loadable-kernel-modules-test): 'module-loader-program' procedurereplaced by the new one.[os]: Use 'kernel-module-loader-service'.--- doc/guix.texi | 37 +++++++++++++++++++++++++ gnu/services/linux.scm | 54 ++++++++++++++++++++++++++++++++++++- gnu/tests/linux-modules.scm | 33 ++++++++++++++--------- 3 files changed, 111 insertions(+), 13 deletions(-)
Toggle diff (212 lines)diff --git a/doc/guix.texi b/doc/guix.texiindex 8cb85fe62c..bc5602474e 100644--- a/doc/guix.texi+++ b/doc/guix.texi@@ -76,6 +76,7 @@ Copyright @copyright{} 2020 Damien Cassou@* Copyright @copyright{} 2020 Jakub Kądziołka@* Copyright @copyright{} 2020 Jack Hill@* Copyright @copyright{} 2020 Naga Malleswari@*+Copyright @copyright{} 2020 Brice Waegeneire@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or@@ -25383,6 +25384,42 @@ notifications. @end table @end deftp +@cindex modprobe+@cindex kernel module loader+@subsubsection Kernel Module Loader Service++The kernel module loader service allows one to load loadable kernel+modules at boot. This is especially useful for modules that don't+autoload and need to be manually loaded, as it's the case with+@code{ddcci}.++@deffn {Scheme Variable} kernel-module-loader-service-type+The service type for loading loadable kernel modules at boot with+@command{modprobe}. Its value must be a list of strings representing+module names. For example loading the drivers provided by+@code{ddcci-driver-linux}, in debugging mode by passing some module+parameters, can be done as follow:++@lisp+(use-modules (gnu) (gnu services))+(use-package-modules linux)+(use-service-modules linux)++(define ddcci-config+ (plain-file "ddcci.conf"+ "options ddcci dyndbg delay=120"))++(operating-system+ ...+ (services (cons* (service kernel-module-loader-service-type+ '("ddcci" "ddcci_backlight"))+ (simple-service 'ddcci-config etc-service-type+ (list `("modprobe.d/ddcci.conf"+ ,ddcci-config)))+ %base-services))+ (kernel-loadable-modules (list ddcci-driver-linux)))+@end lisp+@end deffn @node Miscellaneous Services @subsection Miscellaneous Servicesdiff --git a/gnu/services/linux.scm b/gnu/services/linux.scmindex caa0326c31..536d5f8c76 100644--- a/gnu/services/linux.scm+++ b/gnu/services/linux.scm@@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -25,6 +26,8 @@ #:use-module (gnu packages linux) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26)+ #:use-module (srfi srfi-34)+ #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:export (earlyoom-configuration earlyoom-configuration?@@ -37,7 +40,9 @@ earlyoom-configuration-ignore-positive-oom-score-adj? earlyoom-configuration-show-debug-messages? earlyoom-configuration-send-notification-command- earlyoom-service-type))+ earlyoom-service-type++ kernel-module-loader-service-type)) ;;;@@ -123,3 +128,50 @@ representation." (list (service-extension shepherd-root-service-type (compose list earlyoom-shepherd-service)))) (description "Run @command{earlyoom}, the Early OOM daemon.")))++ +;;;+;;; Kernel module loader.+;;;++(define kernel-module-loader-shepherd-service+ (match-lambda+ ((and (? list? kernel-modules) ((? string?) ...))+ (list+ (shepherd-service+ (documentation "Load kernel modules.")+ (provision '(kernel-module-loader))+ (requirement '(file-systems))+ (respawn? #f)+ (one-shot? #t)+ (modules `((srfi srfi-34)+ (srfi srfi-35)+ (rnrs io ports)+ ,@%default-modules))+ (start+ #~(lambda _+ (unless (null? '#$kernel-modules)+ (if (file-exists? "/proc/sys/kernel/modprobe")+ (let ((modprobe (call-with-input-file+ "/proc/sys/kernel/modprobe" get-line)))+ (guard (c ((message-condition? c)+ (format (current-error-port) "~a~%"+ (condition-message c))+ #f))+ (map (lambda (module)+ (invoke/quiet modprobe "--" module))+ '#$kernel-modules)))+ (begin (format (current-error-port) "error: ~a~%"+ "Kernel is missing loadable module support.")+ #f))))))))))++(define kernel-module-loader-service-type+ (service-type+ (name 'kernel-module-loader)+ (description "Load kernel modules.")+ (extensions+ (list (service-extension shepherd-root-service-type+ kernel-module-loader-shepherd-service)))+ (compose concatenate)+ (extend append)+ (default-value '())))diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scmindex 39e11587c6..f1c4feb7a0 100644--- a/gnu/tests/linux-modules.scm+++ b/gnu/tests/linux-modules.scm@@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re> ;;; ;;; This file is part of GNU Guix. ;;;@@ -19,6 +20,8 @@ (define-module (gnu tests linux-modules) #:use-module (gnu packages linux)+ #:use-module (gnu services)+ #:use-module (gnu services linux) #:use-module (gnu system) #:use-module (gnu system vm) #:use-module (gnu tests)@@ -37,25 +40,30 @@ ;;; ;;; Code: -(define* (module-loader-program os modules)- "Return an executable store item that, upon being evaluated, will dry-run-load MODULES."+(define* (modules-loaded?-program os modules)+ "Return an executable store item that, upon being evaluated, will verify+that MODULES are actually loaded." (program-file "load-kernel-modules.scm"- (with-imported-modules (source-module-closure '((guix build utils)))- #~(begin- (use-modules (guix build utils))- (for-each (lambda (module)- (invoke (string-append #$kmod "/bin/modprobe") "-n" "--"- module))- '#$modules)))))+ #~(begin+ (use-modules (ice-9 rdelim)+ (ice-9 popen))+ (let* ((port (open-input-pipe (string-append #$kmod "/bin/lsmod")))+ (output (read-string port))+ (status (close-pipe port)))+ (and-map (lambda (module) (string-contains output module))+ '#$modules))))) (define* (run-loadable-kernel-modules-test module-packages module-names)- "Run a test of an OS having MODULE-PACKAGES, and modprobe MODULE-NAMES."+ "Run a test of an OS having MODULE-PACKAGES, and verify that MODULE-NAMES+are loaded in memory." (define os (marionette-operating-system (operating-system (inherit (simple-operating-system))+ (services (cons (service kernel-module-loader-service-type module-names)+ (operating-system-user-services+ (simple-operating-system)))) (kernel-loadable-modules module-packages)) #:imported-modules '((guix combinators)))) (define vm (virtual-machine os))@@ -75,7 +83,8 @@ load MODULES." marionette)) (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0)))))- (gexp->derivation "loadable-kernel-modules" (test (module-loader-program os module-names))))+ (gexp->derivation "loadable-kernel-modules"+ (test (modules-loaded?-program os module-names)))) (define %test-loadable-kernel-modules-0 (system-test-- 2.26.0
B
B
Brice Waegeneire wrote on 5 Apr 09:06 +0200
Re: [bug#40274] [PATCH v6 2/2] gnu: Add kernel-module-loader-service.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
7bd4926abb753f09593c8451906f88d2@waegenei.re
On 2020-04-04 21:11, Danny Milosavljevic wrote:
Toggle quote (12 lines)> On Sat, 4 Apr 2020 23:10:04 +0200> Danny Milosavljevic <dannym@scratchpost.org> wrote:> >> On Sat, 4 Apr 2020 17:17:32 +0200>> Brice Waegeneire <brice@waegenei.re> wrote:>> >> > get-line>> >> Missing (ice-9 rdelim) ?> > I meant (ice-9 textual-ports)
The tests reported a warning when (ice-9 textual-ports) was imported,using (rnrs io ports) instead didn't.
B
B
Brice Waegeneire wrote on 5 Apr 09:19 +0200
Re: [bug#40274] [PATCH v5] gnu: Add kernel-module-loader-service.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
791aa8961859e013e713f5f47f11ca77@waegenei.re
On 2020-04-04 18:31, Danny Milosavljevic wrote:
Toggle quote (13 lines)>> But like you noted it would>> be specific>> to loadable modules and not built-in ones since `kernel-arguments` is>> just an OS>> field, which AFAIK can't be influenced by a service.> > There's no one stopping us from extending > operating-system-kernel-arguments,> which already exists as a helper procedure, to also call> operating-system-services and check those for the command line > arguments> to add (see gnu/system.scm).
Thank you for pointing this to me, I didn't thought it was working this way.So writing such a service is totally doable, interesting.
P
P
pelzflorian (Florian Pelz) wrote on 5 Apr 12:06 +0200
Re: [bug#40274] [PATCH v7 2/2] gnu: Add kernel-module-loader-service.
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200405100646.glyvza7cy4eeomr7@pelzflorian.localdomain
On Sun, Apr 05, 2020 at 07:28:03AM +0200, Brice Waegeneire wrote:
Toggle quote (2 lines)> […]
I can use kernel-module-loader v6 without modifications just fine foruvesafb. Thank you!
Regards,Florian
D
D
Danny Milosavljevic wrote on 5 Apr 13:10 +0200
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274-done@debbugs.gnu.org)
20200405131016.1c30a6c0@scratchpost.org
Hi Brice,
I've pushed a variant of this to guix master ascommit 044d1478c9a63a64547c9cc320008f8d8fbf6791 with the following changes:
* Massively over-engineered the tests* Made the shepherd conditional more readable
Thanks!
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6JvJgACgkQ5xo1VCwwuqVM9Af/ZV3vn3kdRt6YWEmCuc+X9uU2yon2KsmCj2mJolWCT6sXgB46UKnTL0VgusXmlOf0rTv3XPiw0+/tw7sty5BunyvMwqUCIfup4xNuU1UU2kYBhDbigDx88Rizb7vBkhD5myNiyIdxqnww+iOaEjS4QzADFbJGBgxBze393IeagyjQnO40EcwQjXR0S9wSGktKY6YBGUZt38X4soXtVnxsNLTa0VFuTFfBDSn7Jtb1rT9LpJlNMYU8tbGNx3NnSPlynv1Oyo7czjhdTAX5AHTLjdxLPSGRmJRqy5RimMaxgpSS8uqU1gr2gghr3Reh3VQh7Z9Ar4miUe2/5APy1MthaA===YJRC-----END PGP SIGNATURE-----

Closed
D
D
Danny Milosavljevic wrote on 5 Apr 13:11 +0200
Re: [bug#40274] [PATCH v7 1/2] services: Allow modprobe to use "/etc/modprobe.d".
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40274@debbugs.gnu.org)
20200405131148.2eab72fb@scratchpost.org
Pushed to guix master as commit 8c88e242292db9b35b4ae6ad788a0f8f3c94bb53.
I think core-updates will be merged to master pretty soon anyway, but thequestion is whether we want to update it in core-updates before that, givenhow many dependencies that has (WTF! What's up with that?).
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6JvPQACgkQ5xo1VCwwuqWImAf8CLubE2tYDe0XbISiOgoGL4mLXVf9uhGalkJgQQ/MJdtgXEG21bJCOl5tFCbXAsTyY+3BE0D+W1cSS/l9wIV+DoR5u4WWLrZIoMYjf2M33ixKC/1mKqeCQzdH8FXMjUEsz8fyAsOwhww+Myio9nS+xRd3rHK4jDjGQ8/Ct1cBujLoG1VZ9stLwhpg3cnz0KFDVsfiFcJ2HFjK6dVDFuH3GmnSlaR/+dAQW5LqhWr1FE1IcOGJB1XtWClNXpVqq6I6wDhQN1/M2PWCPneDRxPnc9o2+rTqP/FVK6wJTYLGrccGoLskTQ9fjPOEL6GKapURaO33i9n4fTAPIupEGPvaKw===qjWF-----END PGP SIGNATURE-----

B
B
Brice Waegeneire wrote on 5 Apr 14:38 +0200
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 40274@debbugs.gnu.org)
02eceeabef1367df39b19f0174ea5dcd@waegenei.re
On 2020-04-05 11:11, Danny Milosavljevic wrote:
Toggle quote (9 lines)> Pushed to guix master as commit > 8c88e242292db9b35b4ae6ad788a0f8f3c94bb53.> > I think core-updates will be merged to master pretty soon anyway, but > the> question is whether we want to update it in core-updates before that, > given> how many dependencies that has (WTF! What's up with that?).
Thank you for helping with that!
I thought that core-updates was frozen which would delay #40422 for some time.I wrote the crutch patch to avoid having to wait before supporting modulearguments, especially since Florian already had a need for it.
?