From patchwork Sat Jun 18 19:11:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brian Cully X-Patchwork-Id: 40113 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C6D1727BBE9; Sat, 18 Jun 2022 20:14:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6795B27BBE9 for ; Sat, 18 Jun 2022 20:14:17 +0100 (BST) Received: from localhost ([::1]:58068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2dtg-0003nb-KK for patchwork@mira.cbaines.net; Sat, 18 Jun 2022 15:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2dtS-0003nD-PY for guix-patches@gnu.org; Sat, 18 Jun 2022 15:14:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2dtS-0006wM-Hr for guix-patches@gnu.org; Sat, 18 Jun 2022 15:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o2dtS-0000rB-Dt for guix-patches@gnu.org; Sat, 18 Jun 2022 15:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55231] [PATCH v3 1/2] Allows copying of out-of-tree modules to the Linux initrd. References: <87wnf3pv87.fsf@ditto.jhoto.spork.org> In-Reply-To: <87wnf3pv87.fsf@ditto.jhoto.spork.org> Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 18 Jun 2022 19:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55231 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55231@debbugs.gnu.org Cc: Brian Cully Received: via spool by 55231-submit@debbugs.gnu.org id=B55231.16555796003228 (code B ref 55231); Sat, 18 Jun 2022 19:14:02 +0000 Received: (at 55231) by debbugs.gnu.org; 18 Jun 2022 19:13:20 +0000 Received: from localhost ([127.0.0.1]:50035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2dsl-0000pt-JC for submit@debbugs.gnu.org; Sat, 18 Jun 2022 15:13:20 -0400 Received: from coleridge.kublai.com ([166.84.7.167]:64925 helo=mail.spork.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2dsf-0000pi-Ou for 55231@debbugs.gnu.org; Sat, 18 Jun 2022 15:13:17 -0400 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id 1926633AE; Sat, 18 Jun 2022 15:13:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1655579593; bh=F1VZwcsd7B/Nola2WyyesUnE8/NzZ9xsRP626NcddsA=; h=From:To:Cc:Subject:Date; b=mB+v1oDq34ayn7lI1Rqw92Qx+qX98Ajm+R46/xUFDKAHtLZoEfi5KEzfo0Byh43JR sLQWjd+x51zBpjbcFthXl9d8Adpn4KveDeZrHznptMywXkgLczu1mUaY7LyKtMbVYm Qpdj7TF4qyuX6YGqe/AVGHJ6rZIiuBpu4dYOxGJY= Date: Sat, 18 Jun 2022 15:11:17 -0400 Message-Id: <10a6842d1a6bde797d82d6b8107660bedce8b956.1655579477.git.bjc@spork.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Brian Cully X-ACL-Warn: , Brian Cully via Guix-patches X-Patchwork-Original-From: Brian Cully via Guix-patches via From: Brian Cully X-getmail-retrieved-from-mailbox: Patches With this patch, modules for ‘initrd-modules’ will not only be searched for in the in-tree Linux modules, but also any additional modules specified in ‘kernel-loadable-modules’. * gnu/build/linux-modules.scm (find-module-file): change DIRECTORY argument to DIRECTORIES. Now takes a list of directories to search, rather than a single one. * gnu/system/linux-initrd.scm (flat-linux-module-directory): change LINUX argument to PACKAGES. Now contains a list of file-likes to search for modules. (raw-initrd): Add LINUX-EXTRA-MODULE-DIRECTORIES keyword argument. Pass it to (flat-linux-module-directory) along with the selected LINUX package. (base-initrd): Add LINUX-EXTRA-MODULE-DIRECTORIES keyword argument. Pass it to (raw-initrd). * gnu/system.scm (operating-system-initrd-file): pass in operating system definition's kernel-loadable-modules into (make-initrd) as LINUX-EXTRA-MODULE-DIRECTORIES. --- This version removes the redundant (package+out->input) procedure, and renames ‘linux-extra-module-paths’ to ‘linux-extra-module-directories’. gnu/build/linux-modules.scm | 19 ++++++++------ gnu/system.scm | 2 ++ gnu/system/linux-initrd.scm | 49 ++++++++++++++++++++++++------------- 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm index 053720574b..97b7e429ea 100644 --- a/gnu/build/linux-modules.scm +++ b/gnu/build/linux-modules.scm @@ -225,8 +225,8 @@ (define (file-name->module-name file) '.ko[.gz|.xz]' and normalizing it." (normalize-module-name (strip-extension (basename file)))) -(define (find-module-file directory module) - "Lookup module NAME under DIRECTORY, and return its absolute file name. +(define (find-module-file directories module) + "Lookup module NAME under DIRECTORIES, and return its absolute file name. NAME can be a file name with or without '.ko', or it can be a module name. Raise an error if it could not be found. @@ -247,16 +247,19 @@ (define (find-module-file directory module) (else chr))) module)))) - (match (find-files directory - (lambda (file stat) - (member (strip-extension - (basename file)) names))) + (match (append-map (lambda (directory) + (find-files directory + (lambda (file _stat) + (member (strip-extension + (basename file)) + names)))) + directories) ((file) file) (() - (error "kernel module not found" module directory)) + (error "kernel module not found" module directories)) ((_ ...) - (error "several modules by that name" module directory)))) + (error "several modules by that name" module directories)))) (define* (recursive-module-dependencies files #:key (lookup-module dot-ko)) diff --git a/gnu/system.scm b/gnu/system.scm index ba1b7b5152..2439560671 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1313,6 +1313,8 @@ (define (operating-system-initrd-file os) #:linux (operating-system-kernel os) #:linux-modules (operating-system-initrd-modules os) + #:linux-extra-module-directories + (operating-system-kernel-loadable-modules os) #:mapped-devices mapped-devices #:keyboard-layout (operating-system-keyboard-layout os))) diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 4c4c78e444..f6e8f75efa 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -119,13 +119,20 @@ (define* (expression->initrd exp `(#:references-graphs (("closure" ,init)))) "/initrd.cpio.gz")) -(define (flat-linux-module-directory linux modules) +(define (flat-linux-module-directory packages modules) "Return a flat directory containing the Linux kernel modules listed in -MODULES and taken from LINUX." +MODULES and taken from PACKAGES." (define imported-modules (source-module-closure '((gnu build linux-modules) (guix build utils)))) + (define package-inputs + (map (lambda (p) + (match p + ((p o) (gexp-input p o)) + (p (gexp-input p "out")))) + packages)) + (define build-exp (with-imported-modules imported-modules (with-extensions (list guile-zlib) @@ -135,11 +142,12 @@ (define (flat-linux-module-directory linux modules) (srfi srfi-1) (srfi srfi-26)) - (define module-dir - (string-append #$linux "/lib/modules")) + (define module-dirs + (map (cut string-append <> "/lib/modules") + '#$package-inputs)) (define modules - (let* ((lookup (cut find-module-file module-dir <>)) + (let* ((lookup (cut find-module-file module-dirs <>)) (modules (map lookup '#$modules))) (append modules (recursive-module-dependencies @@ -172,20 +180,23 @@ (define* (raw-initrd file-systems #:key (linux linux-libre) (linux-modules '()) + (linux-extra-module-directories '()) (mapped-devices '()) (keyboard-layout #f) (helper-packages '()) qemu-networking? volatile-root? (on-error 'debug)) - "Return as a file-like object a raw initrd, with kernel -modules taken from LINUX. FILE-SYSTEMS is a list of file-systems to be -mounted by the initrd, possibly in addition to the root file system specified -on the kernel command line via 'root'. LINUX-MODULES is a list of kernel -modules to be loaded at boot time. MAPPED-DEVICES is a list of device -mappings to realize before FILE-SYSTEMS are mounted. -HELPER-PACKAGES is a list of packages to be copied in the initrd. It may include -e2fsck/static or other packages needed by the initrd to check root partition. + "Return as a file-like object a raw initrd, with kernel modules taken from +LINUX. FILE-SYSTEMS is a list of file-systems to be mounted by the initrd, +possibly in addition to the root file system specified on the kernel command +line via 'root'. LINUX-MODULES is a list of kernel modules to be loaded at +boot time. LINUX-EXTRA-MODULE-DIRECTORIES is a list of file-like objects which +will be searched for modules in addition to the linux kernel. MAPPED-DEVICES +is a list of device mappings to realize before FILE-SYSTEMS are mounted. +HELPER-PACKAGES is a list of packages to be copied in the initrd. It may +include e2fsck/static or other packages needed by the initrd to check root +partition. When true, KEYBOARD-LAYOUT is a record denoting the desired console keyboard layout. This is done before MAPPED-DEVICES are set up and @@ -221,7 +232,8 @@ (define* (raw-initrd file-systems #~()))) (define kodir - (flat-linux-module-directory linux linux-modules)) + (flat-linux-module-directory (cons linux linux-extra-module-directories) + linux-modules)) (expression->initrd (with-imported-modules (source-module-closure @@ -366,6 +378,7 @@ (define* (base-initrd file-systems #:key (linux linux-libre) (linux-modules '()) + (linux-extra-module-directories '()) (mapped-devices '()) (keyboard-layout #f) qemu-networking? @@ -386,9 +399,10 @@ (define* (base-initrd file-systems QEMU-NETWORKING? and VOLATILE-ROOT? behaves as in raw-initrd. The initrd is automatically populated with all the kernel modules necessary -for FILE-SYSTEMS and for the given options. Additional kernel -modules can be listed in LINUX-MODULES. They will be added to the initrd, and -loaded at boot time in the order in which they appear." +for FILE-SYSTEMS and for the given options. Additional kernel modules can be +listed in LINUX-MODULES. Additional directories for modules can be listed in +LINUX-EXTRA-MODULE-DIRECTORIES. They will be added to the initrd, and loaded +at boot time in the order in which they appear." (define linux-modules* ;; Modules added to the initrd and loaded from the initrd. `(,@linux-modules @@ -408,6 +422,7 @@ (define* (base-initrd file-systems (raw-initrd file-systems #:linux linux #:linux-modules linux-modules* + #:linux-extra-module-directories linux-extra-module-directories #:mapped-devices mapped-devices #:helper-packages helper-packages #:keyboard-layout keyboard-layout From patchwork Sat Jun 18 19:11:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cully X-Patchwork-Id: 40112 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9F20027BBEA; Sat, 18 Jun 2022 20:14:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AFF8E27BBEB for ; Sat, 18 Jun 2022 20:14:17 +0100 (BST) Received: from localhost ([::1]:58078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2dtg-0003o9-Rk for patchwork@mira.cbaines.net; Sat, 18 Jun 2022 15:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2dtT-0003nM-CG for guix-patches@gnu.org; Sat, 18 Jun 2022 15:14:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2dtT-0006wS-34 for guix-patches@gnu.org; Sat, 18 Jun 2022 15:14:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o2dtS-0000rI-Q1 for guix-patches@gnu.org; Sat, 18 Jun 2022 15:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55231] [PATCH v3 2/2] doc: =?utf-8?b?4oCYaW5pdHJkLW1vZHVsZXM=?= =?utf-8?b?4oCZ?= will search =?utf-8?b?4oCYa2VybmVsLWxvYWRhYmxlLW1vZHVsZXM=?= =?utf-8?b?4oCZLg==?= Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 18 Jun 2022 19:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55231 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55231@debbugs.gnu.org Cc: Brian Cully Received: via spool by 55231-submit@debbugs.gnu.org id=B55231.16555796023237 (code B ref 55231); Sat, 18 Jun 2022 19:14:02 +0000 Received: (at 55231) by debbugs.gnu.org; 18 Jun 2022 19:13:22 +0000 Received: from localhost ([127.0.0.1]:50038 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2dso-0000q9-91 for submit@debbugs.gnu.org; Sat, 18 Jun 2022 15:13:22 -0400 Received: from coleridge.kublai.com ([166.84.7.167]:61435 helo=mail.spork.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o2dsl-0000pu-Lr for 55231@debbugs.gnu.org; Sat, 18 Jun 2022 15:13:19 -0400 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id 7FE673262; Sat, 18 Jun 2022 15:13:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1655579599; bh=8Hj0+6AubqJc/k/UlmV9m/THDcoZ/oLyzmsaF1PAe8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Jfye6PufZCK0phSgQjFpzTxoLjyNRtUtKRUwDj4Pklac924Pe6g0f4gjrbgGe+0gT v4oUt9rZMGj/WelXc8hXsOjaOGcQmSxOqu5nIhWbdwIoE66ia9DjZUHELivdIZWWmy viJbOjcysqODBBaM2g/YJ9lrepkKltfylPS4L96A= Date: Sat, 18 Jun 2022 15:11:18 -0400 Message-Id: <65cf1060a7ce60b1b91a25f809af6264abdcfa59.1655579477.git.bjc@spork.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <10a6842d1a6bde797d82d6b8107660bedce8b956.1655579477.git.bjc@spork.org> References: <10a6842d1a6bde797d82d6b8107660bedce8b956.1655579477.git.bjc@spork.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Brian Cully X-ACL-Warn: , Brian Cully via Guix-patches X-Patchwork-Original-From: Brian Cully via Guix-patches via From: Brian Cully X-getmail-retrieved-from-mailbox: Patches --- doc/guix.texi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index eda0956260..d97909695f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36461,6 +36461,19 @@ Initial RAM Disk (initrd-modules (cons "megaraid_sas" %base-initrd-modules))) @end lisp +If a module listed in @code{initrd-modules} is not included in the +Linux-libre kernel, then the location to it must be added to the +@code{kernel-loadable-modules} list. For example, if your root file +system exists on a ZFS pool, then your configuration might look like the +following: + +@lisp +(operating-system + ;; @dots{} + (initrd-modules (cons "zfs" %base-initrd-modules)) + (kernel-loadable-modules (list (list zfs "module")))) +@end lisp + @defvr {Scheme Variable} %base-initrd-modules This is the list of kernel modules included in the initrd by default. @end defvr