GNU bug report logs - #30604
[PATCH 0/4] Load Linux module only when supported hardware is present.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Severity: important; Reported by: Danny Milosavljevic <dannym@HIDDEN>; Keywords: patch; dated Sun, 25 Feb 2018 11:47:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.
Severity set to 'important' from 'normal' Request was from ludo@HIDDEN (Ludovic Courtès) to control <at> debbugs.gnu.org. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 13 Mar 2018 09:28:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 13 05:28:56 2018
Received: from localhost ([127.0.0.1]:58078 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evgEq-000698-B7
	for submit <at> debbugs.gnu.org; Tue, 13 Mar 2018 05:28:56 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:58300)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evgEo-000690-QT
 for 30604 <at> debbugs.gnu.org; Tue, 13 Mar 2018 05:28:55 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 453C9125CD;
 Tue, 13 Mar 2018 10:28:54 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Yx1kwIue8iEg; Tue, 13 Mar 2018 10:28:53 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 6900D12592;
 Tue, 13 Mar 2018 10:28:53 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: 30604 <at> debbugs.gnu.org
Subject: Re: [bug#30604] [PATCH v11 5/6] linux-initrd: Provide our own
 'modprobe' program.
References: <87h8plkkkc.fsf@HIDDEN> <20180312221541.1886-1-ludo@HIDDEN>
 <20180312221541.1886-5-ludo@HIDDEN> <87fu54fjfj.fsf@HIDDEN>
Date: Tue, 13 Mar 2018 10:28:52 +0100
In-Reply-To: <87fu54fjfj.fsf@HIDDEN> ("Ludovic
 \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\=
 \=\?utf-8\?Q\?s\?\= message of "Tue, 13 Mar 2018 09:50:40 +0100")
Message-ID: <876060qq7f.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

ludo@HIDDEN (Ludovic Court=C3=A8s) skribis:

> Something annoying is that my external USB keyboard doesn=E2=80=99t work =
while
> in the initrd (when I type my passphrase).  I can see that it=E2=80=99s d=
etected
> early on, before I type my passphrase:

I tried looking up =E2=80=9Cmodalias=E2=80=9D right when entering a /sys/de=
vices
directory, like you did in the initial patch, but that didn=E2=80=99t help:


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 4515839e9..213a8bbb9 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -480,19 +480,22 @@ side-effect and would thus need to traverse /sys/devices again."
      (string-append module-directory "/modules.alias")))
 
   (define (enter? director stat result) result)
-  (define (down directory stat result) result)
-  (define (up directory stat result) result)
-  (define (skip entry stat result) result)
-  (define (error name stat errno result) result)
-  (define (leaf file stat result)
-    (if (string=? (basename file) "modalias")
+  (define (down directory stat result)
+    ;; Check for "modalias" right when entering DIRECTORY instead of waiting
+    ;; for LEAF to be called.  XXX: Doesn't help!
+    (let ((modalias (string-append directory "/modalias")))
+      (if (file-exists? modalias)
           (let* ((alias   (string-trim-right
-                         (call-with-input-file file get-string-all)))
+                           (call-with-input-file modalias get-string-all)))
                  (modules (matching-modules alias aliases)))
             (load-linux-modules-from-directory modules
                                                module-directory)
             (append modules result))
-        result))
+          result)))
+  (define (up directory stat result) result)
+  (define (skip entry stat result) result)
+  (define (error name stat errno result) result)
+  (define (leaf file stat result) file stat result)
 
   (file-system-fold enter? leaf down up skip error '() "/sys/devices"))
 

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64

DQpMdWRv4oCZLg0K
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 13 Mar 2018 09:27:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 13 05:27:15 2018
Received: from localhost ([127.0.0.1]:58073 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evgDC-00066U-VX
	for submit <at> debbugs.gnu.org; Tue, 13 Mar 2018 05:27:15 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:36556)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evgDB-00066M-1F
 for 30604 <at> debbugs.gnu.org; Tue, 13 Mar 2018 05:27:13 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id E6B2D33613E9;
 Tue, 13 Mar 2018 10:27:10 +0100 (CET)
Date: Tue, 13 Mar 2018 10:27:06 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v10 5/6] linux-initrd: Provide our own
 'modprobe' program.
Message-ID: <20180313100539.442c4aa9@HIDDEN>
In-Reply-To: <87h8plkkkc.fsf@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312123918.22645-5-ludo@HIDDEN>
 <20180312210936.7f89a29c@HIDDEN> <87h8plkkkc.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/sH6RIRsnItffXX8vE6x800c"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/sH6RIRsnItffXX8vE6x800c
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

On Mon, 12 Mar 2018 23:14:59 +0100
ludo@HIDDEN (Ludovic Court=C3=A8s) wrote:

> > One of the devnames created statically is the one for btrfs, so not wri=
ting or
> > using devnames is not going to end well. =20
>=20
> We=E2=80=99re fine because btrfs, 9p, overlay, etc. all have an =E2=80=9C=
fs-btrfs=E2=80=9D,
> =E2=80=9Cfs-9p=E2=80=9D, etc. alias, which shows up in =E2=80=9Cmodules.a=
lias=E2=80=9D.  No need for
> =E2=80=9Cmodules.devname=E2=80=9D AFAICS.

The other filesystems are not such a problem - but BTRFS has its own snapsh=
otting/
multivolume functionality - and it's possible that someone accesses /dev/bt=
rfs-control
"too early" for that.

I applied your patches to a fresh clone of guix master now, ran the btrfs-r=
oot-os
system check, and indeed I get (tried two rounds, happened both times):

$ make TESTS=3Dbtrfs-root-os check-system
[...]
Scanning for Btrfs filesystems
WARNING: failed to open /dev/btrfs-control, skipping device registration: N=
o suy
ERROR: there are 1 errors while registering devices
File system check on /dev/vda2 failed; spawning Bourne-like REPL
GNU Guile 2.2.3
Copyright (C) 1995-2017 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
(can't evaluate anything here)

> > (I'd also copy the modules.builtin (from Linux).
> >  Also, what happens if we load a module which has as dependency a built=
in?
> >  Will we try to load the builtin as a .ko file and fail the entire thin=
g?) =20
>=20
> The dependency of a builtin is necessarily a builtin,=20

Yes.

>and the kernel won=E2=80=99t invoke modprobe for a builtin, will it? =20

I've read Linux's __request_module and I can't find where they
pre-check anything - neither whether there's already a builtin
nor whether it's loaded already.

They probably don't check.  But I'll read it again, more carefully...

(request_module isn't that popular so it makes sense for them not to compli=
cate
the kernel by these checks when there are like 8 callers in total - and all=
 on init)

>Thanks for the insightful review!

You're welcome :)

--Sig_/sH6RIRsnItffXX8vE6x800c
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqnmWoACgkQ5xo1VCww
uqWYNQf+JldN8uxgw6yQsYw8jQ9KKV5ilkDItpc6iw+L5Sl3JsYovJ/ABc6JX5m6
nOuQHU4f1rjqJS5kqpFW/qOJbk+3tJSNfRuleJUdKjHfzp3qtTLLYOsN3fTF7OSI
fqN2zqS0y5o/C/T1Ienr7Qx+oC6u56smD1FyoLELJDmL8vGj0qUjNytilqavqxwR
cwtlGxaREEHmuIB2UjNCXUTUdgw5SDS8Dga/x53AvOEIBsc61Cjyd+j/jzoH3NYC
g/reldxXWMPq/DlSkil2293jbnK11+5K/6do+bf5a7uoEdE8E5gKZFqrze7ZiwRS
rfgNmo0u7rv146A2b1bNEw1XgZ9tPw==
=fti+
-----END PGP SIGNATURE-----

--Sig_/sH6RIRsnItffXX8vE6x800c--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 13 Mar 2018 08:56:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 13 04:56:43 2018
Received: from localhost ([127.0.0.1]:58005 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evfje-0005Eb-VS
	for submit <at> debbugs.gnu.org; Tue, 13 Mar 2018 04:56:43 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:58080)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evfjc-0005ET-Tn
 for 30604 <at> debbugs.gnu.org; Tue, 13 Mar 2018 04:56:41 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 62704125B2;
 Tue, 13 Mar 2018 09:56:40 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id jQWiA658I8Bs; Tue, 13 Mar 2018 09:56:39 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 7303D125B1;
 Tue, 13 Mar 2018 09:56:39 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v11 6/6] linux-modules: Add "modules.devname"
 writer.
References: <87h8plkkkc.fsf@HIDDEN> <20180312221541.1886-1-ludo@HIDDEN>
 <20180312221541.1886-6-ludo@HIDDEN>
 <20180312235547.6ac0af0a@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 23 =?utf-8?Q?Vent=C3=B4se?= an 226 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Tue, 13 Mar 2018 09:56:39 +0100
In-Reply-To: <20180312235547.6ac0af0a@HIDDEN> (Danny Milosavljevic's
 message of "Mon, 12 Mar 2018 23:55:46 +0100")
Message-ID: <873714fj5k.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Danny Milosavljevic <dannym@HIDDEN> skribis:

>> +  (call-with-output-file (string-append "/tmp" "/modules.devname")
>                                            ^^^^^^ directory
>
> Otherwise LGTM!

Oops, fixed!




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 13 Mar 2018 08:55:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 13 04:55:58 2018
Received: from localhost ([127.0.0.1]:58001 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evfiw-0005D8-J6
	for submit <at> debbugs.gnu.org; Tue, 13 Mar 2018 04:55:58 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:58064)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evfiv-0005Cz-5Q
 for 30604 <at> debbugs.gnu.org; Tue, 13 Mar 2018 04:55:57 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 3E3D2125B2;
 Tue, 13 Mar 2018 09:55:56 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id xeXLrwfJREpr; Tue, 13 Mar 2018 09:55:55 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 5B20F125B1;
 Tue, 13 Mar 2018 09:55:55 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v11 3/6] linux-modules: Add
 'load-needed-linux-modules'.
References: <87h8plkkkc.fsf@HIDDEN> <20180312221541.1886-1-ludo@HIDDEN>
 <20180312221541.1886-3-ludo@HIDDEN>
 <20180313000031.06767edf@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 23 =?utf-8?Q?Vent=C3=B4se?= an 226 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Tue, 13 Mar 2018 09:55:54 +0100
In-Reply-To: <20180313000031.06767edf@HIDDEN> (Danny Milosavljevic's
 message of "Tue, 13 Mar 2018 00:00:31 +0100")
Message-ID: <877eqgfj6t.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Danny Milosavljevic <dannym@HIDDEN> skribis:

>> +(define (load-needed-linux-modules module-directory)
> [...]
>> +  (file-system-fold enter? leaf down up skip error #t "/sys/devices"))
>
> Isn't #t a strange initial value?  Shouldn't it be '() ?

Indeed!  Fixed, thanks.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 13 Mar 2018 08:55:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 13 04:55:01 2018
Received: from localhost ([127.0.0.1]:57997 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evfhz-0005BM-Mc
	for submit <at> debbugs.gnu.org; Tue, 13 Mar 2018 04:55:01 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:58044)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evfhx-0005BC-7W
 for 30604 <at> debbugs.gnu.org; Tue, 13 Mar 2018 04:54:57 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 7A097125B1;
 Tue, 13 Mar 2018 09:54:56 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id koZNniL82WHx; Tue, 13 Mar 2018 09:54:55 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 7BEC712572;
 Tue, 13 Mar 2018 09:54:55 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v10 5/6] linux-initrd: Provide our own
 'modprobe' program.
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312123918.22645-5-ludo@HIDDEN>
 <20180312210936.7f89a29c@HIDDEN>
 <20180312221226.72eb6cb7@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 23 =?utf-8?Q?Vent=C3=B4se?= an 226 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Tue, 13 Mar 2018 09:54:55 +0100
In-Reply-To: <20180312221226.72eb6cb7@HIDDEN> (Danny Milosavljevic's
 message of "Mon, 12 Mar 2018 22:12:26 +0100")
Message-ID: <87bmfsfj8g.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Danny Milosavljevic <dannym@HIDDEN> skribis:

>> That was why earlier I kept /sbin/modprobe as the name (it's the
>> default Linux uses) and made sure that the file /sbin/modprobe is already
>> in the initrd (as opposed to created by boot-system).
>
> Note: The simplest change would be to keep this patch as-is but add=20
>
>     ;; Make sure that Linux can modprobe even before boot-system started =
up.
>     (when modprobe
>       (mkdir-p "sbin")
>       (symlink modprobe "sbin/modprobe")
>       (compile-to-cache "sbin/modprobe")) ; Note: without this line booti=
ng is dead slow. [Maybe in this case that wouldn't be so bad - since boot-s=
ystem switches away immediately anyway :)]
>
> to gnu/build/linux-initrd.scm

Yeah, done.  Ideally =E2=80=98program-file=E2=80=99 would take care of this=
.  Future
work!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 13 Mar 2018 08:50:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 13 04:50:46 2018
Received: from localhost ([127.0.0.1]:57993 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evfdt-00054z-VV
	for submit <at> debbugs.gnu.org; Tue, 13 Mar 2018 04:50:46 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:58012)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evfdr-00054p-Pe
 for 30604 <at> debbugs.gnu.org; Tue, 13 Mar 2018 04:50:44 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 96753125AF;
 Tue, 13 Mar 2018 09:50:42 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id NcE1BZd0W6ME; Tue, 13 Mar 2018 09:50:41 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 66D1F12572;
 Tue, 13 Mar 2018 09:50:41 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: 30604 <at> debbugs.gnu.org
Subject: Re: [bug#30604] [PATCH v11 5/6] linux-initrd: Provide our own
 'modprobe' program.
References: <87h8plkkkc.fsf@HIDDEN> <20180312221541.1886-1-ludo@HIDDEN>
 <20180312221541.1886-5-ludo@HIDDEN>
Date: Tue, 13 Mar 2018 09:50:40 +0100
In-Reply-To: <20180312221541.1886-5-ludo@HIDDEN> ("Ludovic
 \=\?utf-8\?Q\?Cour\?\= \=\?utf-8\?Q\?t\=C3\=A8s\=22's\?\= message
 of "Mon, 12 Mar 2018 23:15:40 +0100")
Message-ID: <87fu54fjfj.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello!

I=E2=80=99m using this on the bare metal.  \o/

I had to make this change so that dm-crypt would be loaded once I=E2=80=99ve
entered my passphrase:


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 7a167146f..ef81fe718 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -115,16 +115,19 @@ when modules need to be loaded."
             (current-error-port (%make-void-port "w"))
             (current-output-port (%make-void-port "w")))
 
-          (let ((modules (matching-modules alias %known-aliases)))
+          ;; Look up ALIAS in %KNOWN-ALIASES first, and then, if it fails,
+          ;; assume that ALIAS is a module name (some modules such as
+          ;; 'dm-crypt' don't have an alias.)  Note that
+          ;; 'kmod_module_new_from_lookup' uses a different search order.
+          (let ((modules (match (matching-modules alias %known-aliases)
+                           (()  (list alias))
+                           (lst lst))))
             (call-with-output-file "/dev/kmsg"
               (lambda (port)
                 (setvbuf port 'block 1024)
                 (format port "modprobe[~a]: alias ~s; modules ~s; args ~s~%"
                         (getpid) alias modules (program-arguments))))
 
-            (when (null? modules)
-              (error "alias resolution failed" alias))
-
             (load-linux-modules-from-directory modules
                                                linux-module-directory)))))
 

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable


FWIW I have:

--8<---------------cut here---------------start------------->8---
modprobe[146]: alias "net-pf-38"; modules ("net-pf-38"); args ("/gnu/store/=
v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "net-pf-38")
modprobe[152]: alias "dm-crypt"; modules ("dm-crypt"); args ("/gnu/store/v0=
ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "dm-crypt")
modprobe[157]: alias "crypto-xts(aes)"; modules ("crypto-xts(aes)"); args (=
"/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-xt=
s(aes)")
modprobe[162]: alias "crypto-xts(aes)-all"; modules ("crypto-xts(aes)-all")=
; args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "c=
rypto-xts(aes)-all")
modprobe[168]: alias "crypto-xts"; modules ("xts"); args ("/gnu/store/v0ay3=
02yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-xts")
nfo>  [1520929735.4127] manager[0x12950c0]: monitoring kernel firmware dire=
ctory '/lib/firmware'.
modprobe[173]: alias "crypto-aes"; modules ("crypto-aes"); args ("/gnu/stor=
e/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-aes")
modprobe[178]: alias "crypto-aes-all"; modules ("crypto-aes-all"); args ("/=
gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-aes-=
all")
modprobe[183]: alias "crypto-ecb(aes)"; modules ("crypto-ecb(aes)"); args (=
"/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-ec=
b(aes)")
modprobe[188]: alias "crypto-ecb(aes)-all"; modules ("crypto-ecb(aes)-all")=
; args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "c=
rypto-ecb(aes)-all")
--8<---------------cut here---------------end--------------->8---

Something annoying is that my external USB keyboard doesn=E2=80=99t work wh=
ile
in the initrd (when I type my passphrase).  I can see that it=E2=80=99s det=
ected
early on, before I type my passphrase:

--8<---------------cut here---------------start------------->8---
[    1.532237] usb 1-4.2: new low-speed USB device number 4 using xhci_hcd
[    1.648836] usb 1-4.2: New USB device found, idVendor=3D413c, idProduct=
=3D2105
[    1.649189] usb 1-4.2: New USB device strings: Mfr=3D1, Product=3D2, Ser=
ialNumber=3D0
[    1.649533] usb 1-4.2: Product: Dell USB Keyboard
[    1.649882] usb 1-4.2: Manufacturer: Dell
--8<---------------cut here---------------end--------------->8---

but its modules don=E2=80=99t get loaded until after eudev has been started=
, and
there=E2=80=99s no trace of a modprobe invocation for it.

--8<---------------cut here---------------start------------->8---
[   20.968938] input: Dell Dell USB Keyboard as /devices/pci0000:00/0000:00=
:14.0/usb1/1-4/1-4.2/1-4.2:1.0/0003:413C:2105.0001/input/input16
--8<---------------cut here---------------end--------------->8---

Any idea what we=E2=80=99re missing?

Thanks,
Ludo=E2=80=99.

--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 23:00:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 19:00:38 2018
Received: from localhost ([127.0.0.1]:57815 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evWQo-0006iX-P2
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 19:00:38 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:47852)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evWQm-0006iP-P9
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 19:00:37 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id AE84C3360290;
 Tue, 13 Mar 2018 00:00:35 +0100 (CET)
Date: Tue, 13 Mar 2018 00:00:31 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [bug#30604] [PATCH v11 3/6] linux-modules: Add
 'load-needed-linux-modules'.
Message-ID: <20180313000031.06767edf@HIDDEN>
In-Reply-To: <20180312221541.1886-3-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN> <20180312221541.1886-1-ludo@HIDDEN>
 <20180312221541.1886-3-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/DIw3c_UiGS0K62uF_LkfGGo"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/DIw3c_UiGS0K62uF_LkfGGo
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

> +(define (load-needed-linux-modules module-directory)
[...]
> +  (file-system-fold enter? leaf down up skip error #t "/sys/devices"))

Isn't #t a strange initial value?  Shouldn't it be '() ?

--Sig_/DIw3c_UiGS0K62uF_LkfGGo
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqnBo8ACgkQ5xo1VCww
uqUgxAgAjg3Z/ieFvl0Up29vWcWFDgAx7wbEyTmyPlzbcJv6Y64smPzrWawa05vJ
OUi80fg9cnoANXuEdVKslegj48YbpsYtcPC08hUS+Ccjl8KJc7frPtZHUXZ8mPzA
v4V0wUxvaT+SW5BxCI6ancAZJdRutQVh9Nxztb2bLqnnagxAVXn/Aeqy5tLQUYjR
HulvVPHEKyI7RwDAjhm8IFSvuks3IUp5yOnh36GxhQaqdwvuhW5o6iZHjS7R8LER
BXo8NiAK3/RhOiUx7I/i72avNHqp4tnAPDpSRGm2O1fSS3WD+ZCf1vdEvdq5u+E4
oUVZalTFyual5SDiC4ZsvDxtrM/00A==
=tBne
-----END PGP SIGNATURE-----

--Sig_/DIw3c_UiGS0K62uF_LkfGGo--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:55:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:55:56 2018
Received: from localhost ([127.0.0.1]:57811 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evWMG-0006a2-8o
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:55:56 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:47486)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evWME-0006Zu-7B
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:55:54 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 3E53833600C4;
 Mon, 12 Mar 2018 23:55:52 +0100 (CET)
Date: Mon, 12 Mar 2018 23:55:46 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [bug#30604] [PATCH v11 6/6] linux-modules: Add
 "modules.devname" writer.
Message-ID: <20180312235547.6ac0af0a@HIDDEN>
In-Reply-To: <20180312221541.1886-6-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN> <20180312221541.1886-1-ludo@HIDDEN>
 <20180312221541.1886-6-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/bBw2Tipy.+Q3VfgtMZPEXBM"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/bBw2Tipy.+Q3VfgtMZPEXBM
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

> +  (call-with-output-file (string-append "/tmp" "/modules.devname")
                                           ^^^^^^ directory

Otherwise LGTM!

--Sig_/bBw2Tipy.+Q3VfgtMZPEXBM
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqnBXMACgkQ5xo1VCww
uqUZ3Qf+MApqVj/sHxKgauy8+bnT5EbH1jEqXkqa/BGsD95wRG5WodT0AZi0iRBv
wv8mIC8vOl4VS9pcmQSPBvdkIX21RB29Bqrf8CtaThTDqYI8Z5N5izWJLqP2uFan
MJC6ckHcokY/WpTXB+kNZUCfyqvQgqLEaAWb/5JtuPNRQl8ogcX2ccpQosr16f7D
EUplZLt61zHZj90BJBmqmfUk7oWw/PMUw+A2+yNUk4PgQnDQ0R8it+tNDs20ahQX
6Gs2YkDOYtwteWXQnKQOL4cgy7lp9Xck5GnTDpJU21wSYxnePg1CwNjRdfJsGft0
kMS7X1UKiFxrZwg8TUNWxWGuMDLzGA==
=2nsk
-----END PGP SIGNATURE-----

--Sig_/bBw2Tipy.+Q3VfgtMZPEXBM--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:49:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:49:26 2018
Received: from localhost ([127.0.0.1]:57806 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evWFy-0006Pp-G5
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:49:26 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:47088)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evWFx-0006Pi-D7
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:49:25 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 56AA933600C4;
 Mon, 12 Mar 2018 23:49:24 +0100 (CET)
Date: Mon, 12 Mar 2018 23:49:22 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [PATCH v11 4/6] vm: Make the virtio-blk uniquely identifiable
 in /sys.
Message-ID: <20180312234922.14fc6425@HIDDEN>
In-Reply-To: <20180312221541.1886-4-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN> <20180312221541.1886-1-ludo@HIDDEN>
 <20180312221541.1886-4-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/MUUK7.39GCW=rUC2B8yCdwu"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/MUUK7.39GCW=rUC2B8yCdwu
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

LGTM!

--Sig_/MUUK7.39GCW=rUC2B8yCdwu
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqnA/IACgkQ5xo1VCww
uqUC9Qf9GftT17RdFjms1zaPaJXnpZKbClxAvlZD1xLNy3muQXYcznwdEl+rZs6s
YSeDaUhblppXsORQBjcuNJkgp0/dx6hsdZGmjgChwxNyGxcBHQgGUmf6BuUYwt//
2q4EFmcA/rjXGUj9BdX6n5tdPFXHFZtXA0dUNiWx95j+/6gY+8BqLuovn7vlxrBR
32MpR9o5gapDgRABtI+OYxwuPofwIAnSscyxnVFHkm/PA5Bh62KDyLuJYP6eMqpi
xdCEWuzaGpZw3TarvjTuqwsAoPdWsJ15kHeEU6I5cfH8/W9bqt/kJQt/Z3wERaQN
4WLepIiJ917ijx54RtGtMuUyj/Pkww==
=4Olm
-----END PGP SIGNATURE-----

--Sig_/MUUK7.39GCW=rUC2B8yCdwu--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:48:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:48:43 2018
Received: from localhost ([127.0.0.1]:57801 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evWFH-0006O4-8k
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:48:43 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:47014)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evWFF-0006Nt-Th
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:48:42 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id D7FF533600C4;
 Mon, 12 Mar 2018 23:48:40 +0100 (CET)
Date: Mon, 12 Mar 2018 23:48:36 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [bug#30604] [PATCH v11 2/6] linux-modules: Add
 'load-linux-modules-from-directory'.
Message-ID: <20180312234836.106e2eb0@HIDDEN>
In-Reply-To: <20180312221541.1886-2-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN> <20180312221541.1886-1-ludo@HIDDEN>
 <20180312221541.1886-2-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/qThaS.wj._AuZt.lYG_5z10"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/qThaS.wj._AuZt.lYG_5z10
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

LGTM!

--Sig_/qThaS.wj._AuZt.lYG_5z10
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqnA8QACgkQ5xo1VCww
uqU5RAf/RcXh3olPJFZykEZMmUHATzkHioRJD3XilWmU0row0mm1LZR4PzN/tuRm
ASvxkAvXbTc/FeoFU22rLJAv5vY8WfXCFk3NS2PDI7eNyVaeW3wt/qZE4FYiIi9C
oHFzAh+q1v+AHyxly4FhNpGID4XGoCPPDU4/FcRHDvVjBaDR7wjebBluZAxz7/DC
z9CYLPGLTdaxHeNIvW+BRaKfAQrj3tEtKim3RIQbE8rSWFEtj0wYZ/zEwB1IQBRA
oV4X40vz1FG1JkGSNWO/mDD8yJQ8m4XJfOIhfWK2pLWTgknh1X0ShfYUPQY7PbHk
PvMjaWU1xpdu2mOtnivV5Dr5NqkbHA==
=4f2L
-----END PGP SIGNATURE-----

--Sig_/qThaS.wj._AuZt.lYG_5z10--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:48:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:48:24 2018
Received: from localhost ([127.0.0.1]:57798 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evWEx-0006NC-WE
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:48:24 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:46992)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evWEw-0006N4-PG
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:48:23 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 1253233600C4;
 Mon, 12 Mar 2018 23:48:20 +0100 (CET)
Date: Mon, 12 Mar 2018 23:48:14 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [PATCH v11 1/6] linux-modules: Add "modules.alias" writer.
Message-ID: <20180312234814.6b89aecc@HIDDEN>
In-Reply-To: <20180312221541.1886-1-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN>
	<20180312221541.1886-1-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/0frEtQHqINaKL5_ykn_CP8K"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/0frEtQHqINaKL5_ykn_CP8K
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

On Mon, 12 Mar 2018 23:15:36 +0100
Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:

> (%not-dash): New variable.

Old commit message?

Otherwise LGTM!

--Sig_/0frEtQHqINaKL5_ykn_CP8K
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqnA64ACgkQ5xo1VCww
uqVHgwf7BoMySgvE89KaihiVsydHIYT6X+ewGMl4O+hJqVk/qLunMnIp9bEwSoOt
HzwIRt1iZwVPVkZUKkvnb3KDrL5OiDPGhTMOxntfdjHCnxU9WnCo/5K5SJEu5QJA
H0Bnr16fHa9O8e5Po+1fCbS8lASoNVRuod7/7MaHOy5Q8h/8k7smwXL5m4oNPxKL
Dc8CtM2bCOmr/WimkMqkdyWbEswZRQ/ZpX2qbKhGdaYkhvydQhxPmskSpkyWPga6
blmVj1z/7ylLux0YNGPB0Eg1Gatga+enCQlJmP8DqDKgCj1OXS2r58HQWKGCj4ZR
183Umm1tGLdgSgY49SGmEVEs9y2pXw==
=vuYP
-----END PGP SIGNATURE-----

--Sig_/0frEtQHqINaKL5_ykn_CP8K--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:16:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:16:33 2018
Received: from localhost ([127.0.0.1]:57783 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evVk8-0005V7-UR
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39157)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evVk3-0005U8-O4
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evVjx-0004U0-K1
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:22 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40062)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evVjv-0004TL-J6; Mon, 12 Mar 2018 18:16:19 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:48406 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evVjv-0001Ef-1U; Mon, 12 Mar 2018 18:16:19 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v11 6/6] linux-modules: Add "modules.devname" writer.
Date: Mon, 12 Mar 2018 23:15:41 +0100
Message-Id: <20180312221541.1886-6-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312221541.1886-1-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN>
 <20180312221541.1886-1-ludo@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

* gnu/build/linux-modules.scm (aliases->device-tuple)
(write-module-device-database): New procedures.

Co-authored-by: Danny Milosavljevic <dannym@HIDDEN>.
---
 gnu/build/linux-modules.scm | 51 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 55161e026..d3ba2c60a 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -47,6 +47,8 @@
             known-module-aliases
             matching-modules
             write-module-alias-database
+            write-module-device-database
+
             load-needed-linux-modules))
 
 ;;; Commentary:
@@ -415,6 +417,55 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                              aliases)))
                 aliases))))
 
+(define (aliases->device-tuple aliases)
+  "Traverse ALIASES, a list of module aliases, and search for
+\"char-major-M-N\", \"block-major-M-N\", or \"devname:\" aliases.  When they
+are found, return a tuple (DEVNAME TYPE MAJOR MINOR), otherwise return #f."
+  (define (char/block-major? alias)
+    (or (string-prefix? "char-major-" alias)
+        (string-prefix? "block-major-" alias)))
+
+  (define (char/block-major->tuple alias)
+    (match (string-tokenize alias %not-dash)
+      ((type "major" (= string->number major) (= string->number minor))
+       (list (match type
+               ("char" "c")
+               ("block" "b"))
+             major minor))))
+
+  (let* ((devname     (any (lambda (alias)
+                             (and (string-prefix? "devname:" alias)
+                                  (string-drop alias 8)))
+                           aliases))
+         (major/minor (match (find char/block-major? aliases)
+                        (#f #f)
+                        (str (char/block-major->tuple str)))))
+    (and devname major/minor
+         (cons devname major/minor))))
+
+(define %not-dash
+  (char-set-complement (char-set #\-)))
+
+(define (write-module-device-database directory)
+  "Traverse the '.ko' files in DIRECTORY and create the corresponding
+'modules.devname' file.  This file contains information about modules that can
+be loaded on-demand, such as file system modules."
+  (define aliases
+    (filter-map (lambda (file)
+                  (match (aliases->device-tuple (module-aliases file))
+                    (#f #f)
+                    (tuple (cons (file-name->module-name file) tuple))))
+                (find-files directory "\\.ko$")))
+
+  (call-with-output-file (string-append "/tmp" "/modules.devname")
+    (lambda (port)
+      (display "# Device nodes to trigger on-demand module loading.\n" port)
+      (for-each (match-lambda
+                  ((module devname type major minor)
+                   (format port "~a ~a ~a~a:~a~%"
+                           module devname type major minor)))
+                aliases))))
+
 (define (load-needed-linux-modules module-directory)
   "Examine /sys/devices to find out which modules are needed and load those we
 have in MODULE-DIRECTORY.  Return the list of modules loaded, not including
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:16:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:16:32 2018
Received: from localhost ([127.0.0.1]:57781 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evVk7-0005V1-2o
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:31 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39141)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evVk1-0005Tz-An
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evVju-0004T0-Hv
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:20 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40061)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evVju-0004Sp-Co; Mon, 12 Mar 2018 18:16:18 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:48406 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evVjt-0001Ef-6R; Mon, 12 Mar 2018 18:16:18 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v11 5/6] linux-initrd: Provide our own 'modprobe' program.
Date: Mon, 12 Mar 2018 23:15:40 +0100
Message-Id: <20180312221541.1886-5-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312221541.1886-1-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN>
 <20180312221541.1886-1-ludo@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

From: Danny Milosavljevic <dannym@HIDDEN>

This allows us to load modules on demand when the kernel asks for them.

* gnu/system/linux-initrd.scm (modprobe-program): New variable.
(flat-linux-module-directory): Call 'write-module-alias-database'.
(raw-initrd): Pass #:modprobe to 'boot-system' and to 'expression->initrd'.
(expression->initrd): Copy "closure" to $out/references.  Add #:modprobe
and pass it to 'build-initrd'.
* gnu/build/linux-initrd.scm (build-initrd): Add #:modprobe and honor
it.
* gnu/build/linux-boot.scm (boot-system): Add #:modprobe and honor it.
Call 'load-needed-linux-modules'.
* gnu/system/vm.scm (qemu-image): Add #:linux parameter.  Define
'modprobe-wrapper' and pass it to 'activate-modprobe'.  Pass #:linux to
'expression->derivation-in-linux-vm'.

Co-authored-by: Ludovic Courtès <ludo@HIDDEN>
---
 gnu/build/linux-boot.scm    | 13 +++++-
 gnu/build/linux-initrd.scm  | 16 ++++++--
 gnu/system/linux-initrd.scm | 97 ++++++++++++++++++++++++++++++++++++++++-----
 gnu/system/vm.scm           | 21 ++++++++++
 4 files changed, 133 insertions(+), 14 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index df0b2b2d1..eedc4bb9d 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -435,6 +435,7 @@ bailing out.~%root contents: ~s~%" (scandir "/"))
 
 
 (define* (boot-system #:key
+                      modprobe
                       (linux-modules '())
                       linux-module-directory
                       qemu-guest-networking?
@@ -449,6 +450,9 @@ QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file systems
 specified in MOUNTS, and finally booting into the new root if any.  The initrd
 supports kernel command-line options '--load', '--root', and '--repl'.
 
+MODPROBE must be #f or a program to install as the modprobe program that the
+kernel will invoke when it needs to load modules.
+
 Mount the root file system, specified by the '--root' command-line argument,
 if any.
 
@@ -482,9 +486,14 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
+       (when modprobe
+         ;; Tell the kernel to invoke MODPROBE.
+         (call-with-output-file "/proc/sys/kernel/modprobe"
+           (lambda (port)
+             (display modprobe port))))
+
        (display "loading kernel modules...\n")
-       (load-linux-modules-from-directory linux-modules
-                                          linux-module-directory)
+       (load-needed-linux-modules linux-module-directory)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..4fa2bee7d 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@HIDDEN>
+;;; Copyright © 2013, 2014, 2015, 2018 Ludovic Courtès <ludo@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -107,12 +107,18 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init modprobe
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
 at INIT, running GUILE.  It contains all the items referred to by
-REFERENCES-GRAPHS."
+REFERENCES-GRAPHS.
+
+When MODPROBE is true, make /sbin/modprobe a symlink to it.  This is useful
+because Linux invokes 'modprobe' when it needs to load a module and its
+default file name is '/sbin/modprobe' (see 'call_modprobe' in kernel/kmod.c).
+Creating this symlink allows us to make sure there's no time window during
+which 'modprobe' is unavailable."
   (mkdir "contents")
 
   ;; Copy the closures of all the items referenced in REFERENCES-GRAPHS.
@@ -131,6 +137,10 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+    (when modprobe
+      (mkdir-p "sbin")
+      (symlink modprobe "sbin/modprobe"))
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 1eb5f5130..7a167146f 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -63,16 +63,87 @@
 ;;;
 ;;; Code:
 
+(define* (modprobe-program linux-module-directory #:key
+                           (guile %guile-static-stripped))
+  "Return a minimal implementation of 'modprobe' for our initrd that looks up
+modules in LINUX-MODULE-DIRECTORY.  This program will be invoked by the kernel
+when modules need to be loaded."
+  (define program
+    (with-imported-modules (source-module-closure
+                            '((gnu build linux-modules)))
+      #~(begin
+          (use-modules (gnu build linux-modules)
+                       (ice-9 match)
+                       (srfi srfi-1)
+                       (srfi srfi-26)
+                       (srfi srfi-37))
+
+          (define option-spec
+            (list (option '(#\q "quiet") #f #f
+                          (lambda (opt name arg result)
+                            (alist-cons 'quiet? #t result)))))
+
+          (define options
+            ;; Alist of options and non-option arguments.
+            (args-fold (cdr (program-arguments))
+                       option-spec
+                       (lambda (opt name arg result)
+                         (error "unrecognized option" name))
+                       (lambda (arg result)
+                         (alist-cons 'argument arg result))
+                       '()))
+
+          (define alias
+            ;; The alias we are asked to load.  The remaining arguments are
+            ;; module parameters.  In practice the kernel doesn't pass module
+            ;; parameters so we ignore them here.
+            (any (match-lambda
+                   (('argument . alias) alias)
+                   (_ #f))
+                 options))
+
+          (define linux-module-directory
+            ;; The module directory.  Note: We expect a flat directory here.
+            #$linux-module-directory)
+
+          (define %known-aliases
+            ;; The alias database.
+            (known-module-aliases
+             (string-append linux-module-directory "/modules.alias")))
+
+          (when (assq-ref options 'quiet?)
+            (current-error-port (%make-void-port "w"))
+            (current-output-port (%make-void-port "w")))
+
+          (let ((modules (matching-modules alias %known-aliases)))
+            (call-with-output-file "/dev/kmsg"
+              (lambda (port)
+                (setvbuf port 'block 1024)
+                (format port "modprobe[~a]: alias ~s; modules ~s; args ~s~%"
+                        (getpid) alias modules (program-arguments))))
+
+            (when (null? modules)
+              (error "alias resolution failed" alias))
+
+            (load-linux-modules-from-directory modules
+                                               linux-module-directory)))))
+
+  (program-file "modprobe" program #:guile guile))
 
 (define* (expression->initrd exp
                              #:key
+                             modprobe
                              (guile %guile-static-stripped)
                              (gzip gzip)
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
 containing GUILE and that evaluates EXP, a G-expression, upon booting.  All
-the derivations referenced by EXP are automatically copied to the initrd."
+the derivations referenced by EXP are automatically copied to the initrd.
+
+When MODPROBE is true, '/sbin/modprobe' is created as a symlink pointing to
+it.  This allows Linux to call out to MODPROBE as soon as it boots if it needs
+to load modules."
 
   ;; General Linux overview in `Documentation/early-userspace/README' and
   ;; `Documentation/filesystems/ramfs-rootfs-initramfs.txt'.
@@ -89,20 +160,21 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (mkdir #$output)
 
           ;; The guile used in the initrd must be present in the store, so
-          ;; that module loading works once the root is switched.
+          ;; that module loading works once the root is switched.  Similarly,
+          ;; the 'modprobe' program installed in /proc/sys/kernel/modprobe by
+          ;; the initrd, if any, must be present after switch root.
           ;;
-          ;; To ensure that is the case, add an explicit reference to the
-          ;; guile package used in the initrd to the output.
+          ;; To ensure that is the case, add an explicit reference to these in
+          ;; the output.
           ;;
-          ;; This fixes guix-patches bug #28399, "Fix mysql activation, and
+          ;; This fixes <https://bugs.gnu.org/28399>, "Fix mysql activation, and
           ;; add a basic test".
-          (call-with-output-file (string-append #$ output "/references")
-            (lambda (port)
-              (simple-format port "~A\n" #$guile)))
+          (copy-file "closure" (string-append #$output "/references"))
 
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
+                        #:modprobe #$modprobe
                         ;; Copy everything INIT refers to into the initrd.
                         #:references-graphs '("closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
@@ -153,7 +225,9 @@ MODULES and taken from LINUX."
                       (copy-file module
                                  (string-append #$output "/"
                                                 (basename module))))
-                    (delete-duplicates modules)))))
+                    (delete-duplicates modules))
+
+          (write-module-alias-database #$output))))
 
   (computed-file "linux-modules" build-exp))
 
@@ -196,6 +270,9 @@ upon error."
   (define kodir
     (flat-linux-module-directory linux linux-modules))
 
+  (define modprobe
+    (modprobe-program kodir))
+
   (expression->initrd
    (with-imported-modules (source-module-closure
                            '((gnu build linux-boot)
@@ -229,9 +306,11 @@ upon error."
                                     (and #$@device-mapping-commands))
                       #:linux-modules '#$linux-modules
                       #:linux-module-directory '#$kodir
+                      #:modprobe #$modprobe
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:modprobe modprobe
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 4360adf15..7f552bef8 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -249,6 +249,7 @@ INPUTS is a list of inputs (as for packages)."
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
+                     (linux linux-libre)
                      (qemu qemu-minimal)
                      (disk-image-size 'guess)
                      (disk-image-format "qcow2")
@@ -275,18 +276,37 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (define modprobe-wrapper
+    ;; Wrapper for the 'modprobe' command that knows where modules live.
+    (let ((modprobe (file-append kmod "/bin/modprobe")))
+      (program-file "modprobe"
+                    #~(begin
+                        (setenv "LINUX_MODULE_DIRECTORY"
+                                #$(file-append linux "/lib/modules"))
+                        (apply execl #$modprobe
+                               (cons #$modprobe (cdr (command-line))))))))
+
+
   (expression->derivation-in-linux-vm
    name
    (with-imported-modules (source-module-closure '((gnu build bootloader)
                                                    (gnu build vm)
+                                                   (gnu build activation)
                                                    (guix build utils)))
      #~(begin
          (use-modules (gnu build bootloader)
                       (gnu build vm)
+                      ((gnu build activation) #:select (activate-modprobe))
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
+         ;; We may need to lazy-load Linux modules.  The initrd installs a
+         ;; 'modprobe' that can only search through the modules available in
+         ;; the initrd, but here we want to be able to use all the modules of
+         ;; LINUX.  Thus, install a real 'modprobe'.
+         (activate-modprobe #$modprobe-wrapper)
+
          (let ((inputs
                 '#$(append (list qemu parted e2fsprogs dosfstools)
                            (map canonical-package
@@ -361,6 +381,7 @@ the image."
                                    #$(bootloader-installer bootloader))
              (reboot)))))
    #:system system
+   #:linux linux
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:16:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:16:26 2018
Received: from localhost ([127.0.0.1]:57778 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evVk1-0005UU-Mu
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:26 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39129)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evVk0-0005Tq-GX
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evVju-0004Sv-I4
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:19 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40060)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evVjs-0004S4-Hb; Mon, 12 Mar 2018 18:16:16 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:48406 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evVjr-0001Ef-RW; Mon, 12 Mar 2018 18:16:16 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v11 4/6] vm: Make the virtio-blk uniquely identifiable in /sys.
Date: Mon, 12 Mar 2018 23:15:39 +0100
Message-Id: <20180312221541.1886-4-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312221541.1886-1-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN>
 <20180312221541.1886-1-ludo@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>,
 =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

From: Danny Milosavljevic <dannym@HIDDEN>

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.

Signed-off-by: Ludovic Courtès <ludo@HIDDEN>
---
 gnu/build/vm.scm  | 6 +++++-
 gnu/system/vm.scm | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..773b738ae 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,11 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+
+                       ;; QEMU seems to have a bug that it doesn't assign PCI
+                       ;; IDs properly, so force the address of our virtio-blk
+                       ;; device.
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 91ff32ce9..4360adf15 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -677,7 +677,12 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+
+     ;; QEMU seems to have a bug that it doesn't assign PCI IDs properly, so
+     ;; force the address of our virtio-blk device.
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:16:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:16:25 2018
Received: from localhost ([127.0.0.1]:57776 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evVk1-0005US-Ek
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:25 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39109)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evVjy-0005Ti-UI
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evVjt-0004SJ-0F
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:17 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40059)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evVjr-0004RG-0g; Mon, 12 Mar 2018 18:16:15 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:48406 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evVjq-0001Ef-FX; Mon, 12 Mar 2018 18:16:14 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v11 3/6] linux-modules: Add 'load-needed-linux-modules'.
Date: Mon, 12 Mar 2018 23:15:38 +0100
Message-Id: <20180312221541.1886-3-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312221541.1886-1-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN>
 <20180312221541.1886-1-ludo@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

Based on a patch by Danny Milosavljevic <dannym@HIDDEN>.

* gnu/build/linux-modules.scm (load-needed-linux-modules): New
procedure.
---
 gnu/build/linux-modules.scm | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 0084f972b..55161e026 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -30,6 +30,7 @@
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 ftw)
   #:export (dot-ko
             ensure-dot-ko
             module-aliases
@@ -45,7 +46,8 @@
             device-module-aliases
             known-module-aliases
             matching-modules
-            write-module-alias-database))
+            write-module-alias-database
+            load-needed-linux-modules))
 
 ;;; Commentary:
 ;;;
@@ -413,4 +415,34 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                              aliases)))
                 aliases))))
 
+(define (load-needed-linux-modules module-directory)
+  "Examine /sys/devices to find out which modules are needed and load those we
+have in MODULE-DIRECTORY.  Return the list of modules loaded, not including
+dependencies.
+
+Note: loading modules leads to the creation of new entries in /sys/devices,
+which is why we need traversal and loading to be interleaved.  If we walked
+/sys/devices and *then* loaded modules, we'd miss the entries added as a
+side-effect and would thus need to traverse /sys/devices again."
+  (define aliases
+    (known-module-aliases
+     (string-append module-directory "/modules.alias")))
+
+  (define (enter? director stat result) result)
+  (define (down directory stat result) result)
+  (define (up directory stat result) result)
+  (define (skip entry stat result) result)
+  (define (error name stat errno result) result)
+  (define (leaf file stat result)
+    (if (string=? (basename file) "modalias")
+        (let* ((alias   (string-trim-right
+                         (call-with-input-file file get-string-all)))
+               (modules (matching-modules alias aliases)))
+          (load-linux-modules-from-directory modules
+                                             module-directory)
+          (append modules result))
+        result))
+
+  (file-system-fold enter? leaf down up skip error #t "/sys/devices"))
+
 ;;; linux-modules.scm ends here
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:16:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:16:23 2018
Received: from localhost ([127.0.0.1]:57772 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evVjz-0005U9-4X
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:23 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39097)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evVjx-0005Tf-NH
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evVjr-0004Rf-Pr
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:16 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40057)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evVjp-0004Qj-Ra; Mon, 12 Mar 2018 18:16:13 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:48406 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evVjp-0001Ef-8P; Mon, 12 Mar 2018 18:16:13 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v11 2/6] linux-modules: Add
 'load-linux-modules-from-directory'.
Date: Mon, 12 Mar 2018 23:15:37 +0100
Message-Id: <20180312221541.1886-2-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312221541.1886-1-ludo@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN>
 <20180312221541.1886-1-ludo@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

* gnu/build/linux-modules.scm (load-linux-modules-from-directory): New
procedure.
* gnu/build/linux-boot.scm (boot-system)[lookup-module]: Remove.
Use 'load-linux-modules-from-directory' instead.
---
 gnu/build/linux-boot.scm    |  9 ++-------
 gnu/build/linux-modules.scm | 12 ++++++++++++
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..df0b2b2d1 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -469,10 +469,6 @@ upon error."
              mounts)
         "ext4"))
 
-  (define (lookup-module name)
-    (string-append linux-module-directory "/"
-                   (ensure-dot-ko name)))
-
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
 
@@ -487,9 +483,8 @@ upon error."
          (start-repl))
 
        (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (load-linux-modules-from-directory linux-modules
+                                          linux-module-directory)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index b444e6f90..0084f972b 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -38,6 +38,7 @@
             modules-loaded
             module-loaded?
             load-linux-module*
+            load-linux-modules-from-directory
 
             current-module-debugging-port
 
@@ -232,6 +233,17 @@ appears in BLACK-LIST are not loaded."
              (or (and recursive? (= EEXIST (system-error-errno args)))
                  (apply throw args)))))))
 
+(define (load-linux-modules-from-directory modules directory)
+  "Load MODULES and their dependencies from DIRECTORY, a directory containing
+the '.ko' files.  The '.ko' suffix is automatically added to MODULES if
+needed."
+  (define (lookup-module name)
+    (string-append directory "/" (ensure-dot-ko name)))
+
+  (for-each (cut load-linux-module* <>
+                 #:lookup-module lookup-module)
+            (map lookup-module modules)))
+
 
 ;;;
 ;;; Device modules.
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:16:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:16:20 2018
Received: from localhost ([127.0.0.1]:57768 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evVjv-0005Tr-Sr
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:20 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39068)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evVju-0005Tb-N5
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evVjo-0004Oo-O8
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:16:13 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40056)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evVjo-0004OC-Jn; Mon, 12 Mar 2018 18:16:12 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:48406 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evVjo-0001Ef-0P; Mon, 12 Mar 2018 18:16:12 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v11 1/6] linux-modules: Add "modules.alias" writer.
Date: Mon, 12 Mar 2018 23:15:36 +0100
Message-Id: <20180312221541.1886-1-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <87h8plkkkc.fsf@HIDDEN>
References: <87h8plkkkc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

From: Danny Milosavljevic <dannym@HIDDEN>

* gnu/build/linux-modules.scm (write-module-alias-database): New
procedure.
(%not-dash): New variable.

Co-authored-by: Ludovic Courtès <ludo@HIDDEN>
---
 gnu/build/linux-modules.scm | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 4fe673cca..b444e6f90 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2016, 2018 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@HIDDEN>
+;;; Copyright © 2018 Danny Milosavljevic <dannym@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,6 +22,7 @@
   #:use-module (guix elf)
   #:use-module (guix glob)
   #:use-module (guix build syscalls)
+  #:use-module ((guix build utils) #:select (find-files))
   #:use-module (rnrs io ports)
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
@@ -41,7 +43,8 @@
 
             device-module-aliases
             known-module-aliases
-            matching-modules))
+            matching-modules
+            write-module-alias-database))
 
 ;;; Commentary:
 ;;;
@@ -380,4 +383,22 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                       module)))
               known-aliases))
 
+(define (write-module-alias-database directory)
+  "Traverse the '.ko' files in DIRECTORY and create the corresponding
+'modules.alias' file."
+  (define aliases
+    (map (lambda (file)
+           (cons (file-name->module-name file) (module-aliases file)))
+         (find-files directory "\\.ko$")))
+
+  (call-with-output-file (string-append directory "/modules.alias")
+    (lambda (port)
+      (display "# Aliases extracted from modules themselves.\n" port)
+      (for-each (match-lambda
+                  ((module . aliases)
+                   (for-each (lambda (alias)
+                               (format port "alias ~a ~a\n" alias module))
+                             aliases)))
+                aliases))))
+
 ;;; linux-modules.scm ends here
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 22:15:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 18:15:13 2018
Received: from localhost ([127.0.0.1]:57764 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evVir-0005Rc-GU
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:15:13 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:54978)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evVio-0005RT-KP
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 18:15:11 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id B844B12478;
 Mon, 12 Mar 2018 23:15:09 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id PWm2jtYsnegY; Mon, 12 Mar 2018 23:15:08 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 1F0B212456;
 Mon, 12 Mar 2018 23:15:08 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v10 5/6] linux-initrd: Provide our own
 'modprobe' program.
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312123918.22645-5-ludo@HIDDEN>
 <20180312210936.7f89a29c@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 22 =?utf-8?Q?Vent=C3=B4se?= an 226 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 12 Mar 2018 23:14:59 +0100
In-Reply-To: <20180312210936.7f89a29c@HIDDEN> (Danny Milosavljevic's
 message of "Mon, 12 Mar 2018 21:09:36 +0100")
Message-ID: <87h8plkkkc.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Howdy!

Danny Milosavljevic <dannym@HIDDEN> skribis:

> On Mon, 12 Mar 2018 13:39:17 +0100
> Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:
>
>> +       (when modprobe
>> +         ;; Tell the kernel to invoke MODPROBE.
>> +         (call-with-output-file "/proc/sys/kernel/modprobe"
>> +           (lambda (port)
>> +             (display modprobe port))))
>> +
>>         (display "loading kernel modules...\n")
>
> There's a race because Linux could just start loading modules
> immediately before boot-system even starts / executed far enough.
>
> That was why earlier I kept /sbin/modprobe as the name (it's the
> default Linux uses) and made sure that the file /sbin/modprobe is already
> in the initrd (as opposed to created by boot-system).
>
> The race didn't happen to me yet (and I doubt that Linux has modules
> fine-grained enough that that's a problem in practise) - but I would pref=
er
> it not to be possible.
>
> WDYT?

You=E2=80=99re right, I wondered what would happen.  I=E2=80=99ve restored =
the
/sbin/modprobe symlink in v11.

>> +          (define aliases
>> +            ;; The list of aliases we are asked to load.
>> +            (filter-map (match-lambda
>> +                          (('argument . alias) alias)
>> +                          (_ #f))
>> +                        options))
>
> Without "-a", it's not supposed to be a list of aliases.  It's supposed t=
o be
> one alias and the remainder are parameters supposed to be passed to that
> kernel module.
>
> (I didn't know that before).
>
> When Linux invokes /sbin/modprobe, it doesn't pass "-a" but it doesn't
> pass any module parameters either - it just passes one module alias.
>
> For clarity and in order that we don't have weird problems later (trying =
to
> load a module named "verbose=3D1" or something :) ), let's just accept on=
e alias
> for now.

Indeed, done in v11.

>>+(define* (modprobe-program linux-module-directory #:key
>>+                           (guile %guile-static-stripped))
> [...]
>> +            (call-with-output-file "/dev/kmsg"
>> +              (lambda (port)
>> +                (format port "modprobe[~a]: aliases ~s; modules ~s; arg=
s ~s~%"
>> +                        (getpid) aliases modules (program-arguments))))
>
> Hmm, logging is nice!

I didn=E2=80=99t mean to leave it, but after all, it=E2=80=99s pretty usefu=
l.  :-)

> But with /dev/kmsg one write(2) syscall needs to pass the entire message.
>
> What do you think about additionally calling setvbuf with 1024 ?  Because:

Sure.

>> +          (write-module-alias-database #$output))))
>
> One of the devnames created statically is the one for btrfs, so not writi=
ng or
> using devnames is not going to end well.

We=E2=80=99re fine because btrfs, 9p, overlay, etc. all have an =E2=80=9Cfs=
-btrfs=E2=80=9D,
=E2=80=9Cfs-9p=E2=80=9D, etc. alias, which shows up in =E2=80=9Cmodules.ali=
as=E2=80=9D.  No need for
=E2=80=9Cmodules.devname=E2=80=9D AFAICS.

> (I'd also copy the modules.builtin (from Linux).
>  Also, what happens if we load a module which has as dependency a builtin?
>  Will we try to load the builtin as a .ko file and fail the entire thing?)

The dependency of a builtin is necessarily a builtin, and the kernel
won=E2=80=99t invoke modprobe for a builtin, will it?  IOW, I think there=
=E2=80=99s no
problem here.  :-)

>> +         ;; We may need to lazy-load modules.  The initrd installs a
>
> Nitpick: "kernel modules" (to clarify).

Fixed.

Thanks for the insightful review!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 21:13:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 17:13:39 2018
Received: from localhost ([127.0.0.1]:57575 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evUlH-0003l7-GY
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 17:13:39 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:54330)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evUlF-0003kz-Qg
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 17:13:38 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 64AD712492;
 Mon, 12 Mar 2018 22:13:37 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id iWL9Bwsjb6OD; Mon, 12 Mar 2018 22:13:36 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 7F0481245C;
 Mon, 12 Mar 2018 22:13:36 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [PATCH v10 1/6] linux-modules: Add "modules.alias" writer.
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312205444.07c05f4c@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 22 =?utf-8?Q?Vent=C3=B4se?= an 226 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 12 Mar 2018 22:13:26 +0100
In-Reply-To: <20180312205444.07c05f4c@HIDDEN> (Danny Milosavljevic's
 message of "Mon, 12 Mar 2018 20:54:44 +0100")
Message-ID: <87muzdknex.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Danny Milosavljevic <dannym@HIDDEN> skribis:

>> +(define %not-dash
>> +  (char-set-complement (char-set #\-)))
>
> Is that used?

Oops, not until patch 6/6.  I=E2=80=99ve moved it there.

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 21:12:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 17:12:34 2018
Received: from localhost ([127.0.0.1]:57571 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evUkE-0003jG-7K
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 17:12:34 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:39716)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evUkD-0003j8-2F
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 17:12:33 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id E1F283360290;
 Mon, 12 Mar 2018 22:12:31 +0100 (CET)
Date: Mon, 12 Mar 2018 22:12:26 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [bug#30604] [PATCH v10 5/6] linux-initrd: Provide our own
 'modprobe' program.
Message-ID: <20180312221226.72eb6cb7@HIDDEN>
In-Reply-To: <20180312210936.7f89a29c@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312123918.22645-5-ludo@HIDDEN>
 <20180312210936.7f89a29c@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/yqyUpe/VHoXpAgll993hj+C"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/yqyUpe/VHoXpAgll993hj+C
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

> That was why earlier I kept /sbin/modprobe as the name (it's the
> default Linux uses) and made sure that the file /sbin/modprobe is already
> in the initrd (as opposed to created by boot-system).

Note: The simplest change would be to keep this patch as-is but add=20

    ;; Make sure that Linux can modprobe even before boot-system started up.
    (when modprobe
      (mkdir-p "sbin")
      (symlink modprobe "sbin/modprobe")
      (compile-to-cache "sbin/modprobe")) ; Note: without this line booting=
 is dead slow. [Maybe in this case that wouldn't be so bad - since boot-sys=
tem switches away immediately anyway :)]

to gnu/build/linux-initrd.scm

--Sig_/yqyUpe/VHoXpAgll993hj+C
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqm7ToACgkQ5xo1VCww
uqXvXgf/SnwfDNtEZL1XSdFOuX/41Dp/eKf3g0roct+Yxfv1fjvliPoGPFfttKv+
Zx+vSHS1R//outrcrcXifpJJaNpsASsol1HxtuoPtzQ7nLXDIZKB4bG9aZYeVW1H
OnWOKL1Si9ozts4KJxfBSyovFyDqIs/J85BrSaYhsCI5qkpH3pmKx03bTuPPOlXH
kI5S5j4977ATl5IXiUdZ0Y2+QOun98k+a5XM4ujlfaID+gu+9PrEp4R9bg6V1nGZ
M3efWovUJeewL+nk4gB1pLx3bo5ISLeoqdq1Bso2HzYkfmZtiI5Ke5+k37zPpOg1
tfBGWBNxzKJLnS40yu6tbFDweZ/1sg==
=5MQy
-----END PGP SIGNATURE-----

--Sig_/yqyUpe/VHoXpAgll993hj+C--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 21:10:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 17:10:53 2018
Received: from localhost ([127.0.0.1]:57567 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evUia-0003gQ-Qg
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 17:10:53 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:54302)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evUiZ-0003gI-2H
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 17:10:51 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 96EFE12492;
 Mon, 12 Mar 2018 22:10:50 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id qlUQ7UOFFKjG; Mon, 12 Mar 2018 22:10:49 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 901B612029;
 Mon, 12 Mar 2018 22:10:49 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v10 3/6] linux-modules: Add
 'load-needed-linux-modules'.
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312123918.22645-3-ludo@HIDDEN>
 <20180312204002.09bfc72f@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 22 =?utf-8?Q?Vent=C3=B4se?= an 226 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 12 Mar 2018 22:10:39 +0100
In-Reply-To: <20180312204002.09bfc72f@HIDDEN> (Danny Milosavljevic's
 message of "Mon, 12 Mar 2018 20:40:02 +0100")
Message-ID: <87r2opknjk.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Danny Milosavljevic <dannym@HIDDEN> skribis:

>> +        (let* ((alias   (string-trim-right
>> +                         (call-with-input-file file get-string-all)))
>
> Hmm... doesn't this trim other things than newline?

Yes, it trims whitespace.

> A quick internet search shows that most people do that.  Huh.

Yeah I=E2=80=99d think that whitespace is non-significant in these files, b=
ut in
practice they=E2=80=99re always generated anyway.

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 20:09:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 16:09:47 2018
Received: from localhost ([127.0.0.1]:57550 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evTlT-00026l-GT
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 16:09:47 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:34672)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evTlS-00026d-4X
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 16:09:46 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id F0A0A3360163;
 Mon, 12 Mar 2018 21:09:44 +0100 (CET)
Date: Mon, 12 Mar 2018 21:09:36 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [bug#30604] [PATCH v10 5/6] linux-initrd: Provide our own
 'modprobe' program.
Message-ID: <20180312210936.7f89a29c@HIDDEN>
In-Reply-To: <20180312123918.22645-5-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312123918.22645-5-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/+QfwEzIV806Sp6Lwi4U+ueu"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/+QfwEzIV806Sp6Lwi4U+ueu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

On Mon, 12 Mar 2018 13:39:17 +0100
Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:

> +       (when modprobe
> +         ;; Tell the kernel to invoke MODPROBE.
> +         (call-with-output-file "/proc/sys/kernel/modprobe"
> +           (lambda (port)
> +             (display modprobe port))))
> +
>         (display "loading kernel modules...\n")

There's a race because Linux could just start loading modules
immediately before boot-system even starts / executed far enough.

That was why earlier I kept /sbin/modprobe as the name (it's the
default Linux uses) and made sure that the file /sbin/modprobe is already
in the initrd (as opposed to created by boot-system).

The race didn't happen to me yet (and I doubt that Linux has modules
fine-grained enough that that's a problem in practise) - but I would prefer
it not to be possible.

WDYT?

> +          (define aliases
> +            ;; The list of aliases we are asked to load.
> +            (filter-map (match-lambda
> +                          (('argument . alias) alias)
> +                          (_ #f))
> +                        options))

Without "-a", it's not supposed to be a list of aliases.  It's supposed to =
be
one alias and the remainder are parameters supposed to be passed to that
kernel module.

(I didn't know that before).

When Linux invokes /sbin/modprobe, it doesn't pass "-a" but it doesn't
pass any module parameters either - it just passes one module alias.

For clarity and in order that we don't have weird problems later (trying to
load a module named "verbose=3D1" or something :) ), let's just accept one =
alias
for now.

>+(define* (modprobe-program linux-module-directory #:key
>+                           (guile %guile-static-stripped))
[...]
> +            (call-with-output-file "/dev/kmsg"
> +              (lambda (port)
> +                (format port "modprobe[~a]: aliases ~s; modules ~s; args=
 ~s~%"
> +                        (getpid) aliases modules (program-arguments))))

Hmm, logging is nice!

But with /dev/kmsg one write(2) syscall needs to pass the entire message.

What do you think about additionally calling setvbuf with 1024 ?  Because:

kernel/printk/printk.c: #define LOG_LINE_MAX         (1024 - PREFIX_MAX)

> +            (when (< (length modules) (length aliases))
> +              (error "alias resolution failed" aliases))

The original modprobe loads as many modules as it can and possibly sets an
(always the same) error flag (and continues loading the other modules).

Then modprobe's exit status is that error flag.

This is moot because we shouldn't accept more than one alias - see above.

> +          (write-module-alias-database #$output))))

One of the devnames created statically is the one for btrfs, so not writing=
 or
using devnames is not going to end well.

If it did work without it I'd be even more on guard :)

(I'd also copy the modules.builtin (from Linux).
 Also, what happens if we load a module which has as dependency a builtin?
 Will we try to load the builtin as a .ko file and fail the entire thing?)

> +         ;; We may need to lazy-load modules.  The initrd installs a

Nitpick: "kernel modules" (to clarify).

--Sig_/+QfwEzIV806Sp6Lwi4U+ueu
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqm3oAACgkQ5xo1VCww
uqVxHQf/SAsE6KJ/6f6BdakZaXlVHzpjRCqHAsBqgjysduzvcrFV8UCjlL+oHwbx
wSTlb3pX/UlqNI6URpKE2lAvroThzv4nrohwxTlIHCUM/Y1eYanCrT0F6v6Qwg6z
fr+AF1KUyJHeLU7I0vgu+Sl2KWEJwRvQkUCPoF4UnpkQnwreJFatjBa5jkJeRPYP
GRQe2vfBmOQUQetL2JjeqvOJ6FSfKV51A//8HoJFHpVgkktBD1mADHR4yiB+CWuD
9BiPndNOCm8FgF5szqQK+htdfm15kMF9yapqCVib12xZzUEji6zXPSN201q3V0uY
O0fbTWR4qYQL/2nlcZU+Tm/RMPfs5g==
=D7DW
-----END PGP SIGNATURE-----

--Sig_/+QfwEzIV806Sp6Lwi4U+ueu--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 19:54:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 15:54:54 2018
Received: from localhost ([127.0.0.1]:57546 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evTX4-0001is-5y
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 15:54:54 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:33470)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evTX3-0001ij-8o
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 15:54:53 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id CC0583360290;
 Mon, 12 Mar 2018 20:54:51 +0100 (CET)
Date: Mon, 12 Mar 2018 20:54:44 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [PATCH v10 1/6] linux-modules: Add "modules.alias" writer.
Message-ID: <20180312205444.07c05f4c@HIDDEN>
In-Reply-To: <20180312123918.22645-1-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN>
	<20180312123918.22645-1-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/168_Ahi6oUnV_8ev6XJ61G8"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/168_Ahi6oUnV_8ev6XJ61G8
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

> +(define %not-dash
> +  (char-set-complement (char-set #\-)))

Is that used?


--Sig_/168_Ahi6oUnV_8ev6XJ61G8
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqm2wQACgkQ5xo1VCww
uqWAEggAoQSbJS4ZokiOPU19tL7sruZCtY+obW6fPybblMPoEGu4lvtpYgGS2LKJ
WM/BqQ47Gl+YsaHN0rtubgE/x6UR1QSgNT4u8YzKgUUndYDCnTE/IZeZxJpInCHm
vX/zZrABiPijn2XScY+CPIZhDSqc2clk0+9SwG0HuZ95YGmsR46fgBk7pxkgtwHi
tF2KGNgAvTY9ras70li10hgd8yhddjYV7hDzlD5V4NPUO0zUHq/bnLMvQUwvL8Vf
DbeqIeZo2LuEmC8/ndD8cOYD9abRswWxwiV5X6W2Mv/sM1ihgP1qFxXZsfXffq7e
IUSeM6PeZH9zXjm7zhULRhbu5jBFlQ==
=5l1S
-----END PGP SIGNATURE-----

--Sig_/168_Ahi6oUnV_8ev6XJ61G8--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 19:40:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 15:40:09 2018
Received: from localhost ([127.0.0.1]:57542 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evTIm-0001Mq-Sc
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 15:40:09 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:60636)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evTIl-0001Mi-4p
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 15:40:07 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id E92F43360290;
 Mon, 12 Mar 2018 20:40:05 +0100 (CET)
Date: Mon, 12 Mar 2018 20:40:02 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [bug#30604] [PATCH v10 3/6] linux-modules: Add
 'load-needed-linux-modules'.
Message-ID: <20180312204002.09bfc72f@HIDDEN>
In-Reply-To: <20180312123918.22645-3-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312123918.22645-3-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

> +        (let* ((alias   (string-trim-right
> +                         (call-with-input-file file get-string-all)))

Hmm... doesn't this trim other things than newline?

A quick internet search shows that most people do that.  Huh.

LGTM!




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 19:27:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 15:27:05 2018
Received: from localhost ([127.0.0.1]:57534 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evT69-00011z-4S
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 15:27:05 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:59714)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evT67-00011r-Qw
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 15:27:04 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 175F03360290;
 Mon, 12 Mar 2018 20:27:02 +0100 (CET)
Date: Mon, 12 Mar 2018 20:26:54 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Ludovic =?ISO-8859-1?Q?Court=E8s?= <ludo@HIDDEN>
Subject: Re: [bug#30604] [PATCH v10 2/6] linux-modules: Add
 'load-linux-modules-from-directory'.
Message-ID: <20180312202654.43eaa5b1@HIDDEN>
In-Reply-To: <20180312123918.22645-2-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN> <20180312123918.22645-1-ludo@HIDDEN>
 <20180312123918.22645-2-ludo@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/8h1YRx+a/y.xMUaBt6U3YWB"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/8h1YRx+a/y.xMUaBt6U3YWB
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

LGTM!

--Sig_/8h1YRx+a/y.xMUaBt6U3YWB
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqm1H4ACgkQ5xo1VCww
uqUaDQgAoQZlq9m3ie+LFkr6iYXYrja7h9oMesSDWz5Prfd8ou8Y59JZnoGHPkMc
PucsWmIvytg4OgT7xqbJk7rmNFdwyM7EFqj/oizhKnwYBo0kObRfUXfA6jbE2GiG
JdLHMuiIbfJAe2S1B01PEMT2Wdkxb+2qTJJMCQaHR1DPQe6NgnSK2vI4567CYD/U
iU3ugZV6pTIWjoju//TvaiNbGFJiW65f1E3I3X79gIiY2UJJQiWeCDJjmBPAC24P
XzIGzhywgHcL/zItbRnp6LlVl8pjpg4soK+IIEu/Rlu/Pgfhx4RmSsHqE91c0V9h
pdzRqIfDXaqB0PbdF20hY3I1ZMfOHQ==
=8AKq
-----END PGP SIGNATURE-----

--Sig_/8h1YRx+a/y.xMUaBt6U3YWB--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 17:52:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 13:52:05 2018
Received: from localhost ([127.0.0.1]:57502 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evRcD-00072k-Hy
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 13:52:05 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:52574)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1evRcC-00072Z-L8
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 13:52:05 -0400
Received: from localhost (178.113.188.221.wireless.dyn.drei.com
 [178.113.188.221])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 6BBC73360290;
 Mon, 12 Mar 2018 18:52:02 +0100 (CET)
Date: Mon, 12 Mar 2018 18:51:55 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v9 3/7] linux-initrd: Provide pure-Guile
 modprobe.
Message-ID: <20180312183840.44e1b6c2@HIDDEN>
In-Reply-To: <878taxnyie.fsf@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
 <20180304010914.1322-4-dannym@HIDDEN>
 <20180311212430.707ef0ea@HIDDEN> <878taxnyie.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/ofkgarPL=IPwfQpjLIc/DDS"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/ofkgarPL=IPwfQpjLIc/DDS
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

On Mon, 12 Mar 2018 15:45:29 +0100
ludo@HIDDEN (Ludovic Court=C3=A8s) wrote:

> > Would make sense to also support "-a" (used when invoking modprobe to l=
oad multiple
> > kernel modules at once). =20
>=20
> I suppose we can do that later because the kernel doesn=E2=80=99t use it =
in
> =E2=80=98call_modprobe=E2=80=99 and this thing is only ever invoked by th=
e kernel.

Sure.

I just wanted to comment because I noticed that kmod's

  modprobe a b c

doesn't load three modules a, b, c.  But my v9's pure-Guile modprobe was
implemented in a way that it did load three modules a, b, c - which it
definitely shouldn't be doing.

--Sig_/ofkgarPL=IPwfQpjLIc/DDS
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqmvjsACgkQ5xo1VCww
uqXeIwf/bWzHASgwuyDjDHnyky9v07N2HOiSCOKw02bU0cL1fq2XiqTMAOJ1aurg
yrijV9mfr6v27OKikXld/AoTPf4kSJR3DLRosyJeu1CoXHm4CdLnBpFm2Zbf4HSm
c+jBjo3x21qMmIj1O5KDtJQo22fbgTp29/2ndokOOrDLpShdKxCRNiihK9e3gRTM
eZdw10jhypvXZWLgfeWrOvLkxrBeLgR437UdWYXkal6SOZ1EY2jP3d1XqhxCi/BA
gGPAcEQYIc2SNVhf30MfaH6ssih+bcDeLxlBkTJ/U9vpXMJDPiKoC9kgpus7ncLN
Ph7AT+i7N1bp9JEbQfnDrNdGwqctKQ==
=bZwL
-----END PGP SIGNATURE-----

--Sig_/ofkgarPL=IPwfQpjLIc/DDS--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 14:45:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 10:45:33 2018
Received: from localhost ([127.0.0.1]:57079 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evOhh-0001ye-0T
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 10:45:33 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:51766)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evOhf-0001yV-5q
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 10:45:31 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 9DD82123DD;
 Mon, 12 Mar 2018 15:45:30 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 8zwWI3TA9VqT; Mon, 12 Mar 2018 15:45:29 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id C2940123CF;
 Mon, 12 Mar 2018 15:45:29 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v9 3/7] linux-initrd: Provide pure-Guile
 modprobe.
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
 <20180304010914.1322-4-dannym@HIDDEN>
 <20180311212430.707ef0ea@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 22 =?utf-8?Q?Vent=C3=B4se?= an 226 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 12 Mar 2018 15:45:29 +0100
In-Reply-To: <20180311212430.707ef0ea@HIDDEN> (Danny Milosavljevic's
 message of "Sun, 11 Mar 2018 21:24:30 +0100")
Message-ID: <878taxnyie.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Danny Milosavljevic <dannym@HIDDEN> skribis:

>> +          (define option-spec
>> +           '((quiet    (single-char #\q) (value #f))))
>
> Would make sense to also support "-a" (used when invoking modprobe to loa=
d multiple
> kernel modules at once).

I suppose we can do that later because the kernel doesn=E2=80=99t use it in
=E2=80=98call_modprobe=E2=80=99 and this thing is only ever invoked by the =
kernel.

WDYT?

Ludo=E2=80=99.





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 12:39:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 08:39:58 2018
Received: from localhost ([127.0.0.1]:56089 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evMkA-0002zb-IU
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:58 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48204)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evMk3-0002yV-Vi
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evMjx-0006HX-4I
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:46 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56602)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evMju-0006Bp-2S; Mon, 12 Mar 2018 08:39:42 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:57474 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evMjt-0003VE-Cx; Mon, 12 Mar 2018 08:39:41 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v10 5/6] linux-initrd: Provide our own 'modprobe' program.
Date: Mon, 12 Mar 2018 13:39:17 +0100
Message-Id: <20180312123918.22645-5-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312123918.22645-1-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN>
 <20180312123918.22645-1-ludo@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

This allows us to load modules on demand when the kernel asks for them.

* gnu/system/linux-initrd.scm (modprobe-program): New variable.
(flat-linux-module-directory): Call 'write-module-alias-database'.
(raw-initrd): Pass #:modprobe to 'boot-system'.
(expression->initrd): Copy "closure" to $out/references.
* gnu/build/linux-boot.scm (boot-system): Add #:modprobe and honor it.
Call 'load-needed-linux-modules'.
* gnu/system/vm.scm (qemu-image): Add #:linux parameter.  Define
'modprobe-wrapper' and pass it to 'activate-modprobe'.  Pass #:linux to
'expression->derivation-in-linux-vm'.

Co-authored-by: Danny Milosavljevic <dannym@HIDDEN>
---
 gnu/build/linux-boot.scm    | 13 +++++--
 gnu/system/linux-initrd.scm | 86 +++++++++++++++++++++++++++++++++++++++++----
 gnu/system/vm.scm           | 21 +++++++++++
 3 files changed, 111 insertions(+), 9 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index df0b2b2d1..eedc4bb9d 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -435,6 +435,7 @@ bailing out.~%root contents: ~s~%" (scandir "/"))
 
 
 (define* (boot-system #:key
+                      modprobe
                       (linux-modules '())
                       linux-module-directory
                       qemu-guest-networking?
@@ -449,6 +450,9 @@ QEMU-GUEST-NETWORKING? is true, calling PRE-MOUNT, mounting the file systems
 specified in MOUNTS, and finally booting into the new root if any.  The initrd
 supports kernel command-line options '--load', '--root', and '--repl'.
 
+MODPROBE must be #f or a program to install as the modprobe program that the
+kernel will invoke when it needs to load modules.
+
 Mount the root file system, specified by the '--root' command-line argument,
 if any.
 
@@ -482,9 +486,14 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
+       (when modprobe
+         ;; Tell the kernel to invoke MODPROBE.
+         (call-with-output-file "/proc/sys/kernel/modprobe"
+           (lambda (port)
+             (display modprobe port))))
+
        (display "loading kernel modules...\n")
-       (load-linux-modules-from-directory linux-modules
-                                          linux-module-directory)
+       (load-needed-linux-modules linux-module-directory)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 1eb5f5130..6b7883c2c 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -63,6 +63,75 @@
 ;;;
 ;;; Code:
 
+(define* (modprobe-program linux-module-directory #:key
+                           (guile %guile-static-stripped))
+  "Return a minimal implementation of 'modprobe' for our initrd that looks up
+modules in LINUX-MODULE-DIRECTORY.  This program will be invoked by the kernel
+when modules need to be loaded."
+  (define program
+    (with-imported-modules (source-module-closure
+                            '((gnu build linux-modules)))
+      #~(begin
+          (use-modules (gnu build linux-modules)
+                       (ice-9 match)
+                       (srfi srfi-1)
+                       (srfi srfi-26)
+                       (srfi srfi-37))
+
+          (define option-spec
+            (list (option '(#\q "quiet") #f #f
+                          (lambda (opt name arg result)
+                            (alist-cons 'quiet? #t result)))))
+
+          (define options
+            ;; Alist of options and non-option arguments.
+            (args-fold (cdr (program-arguments))
+                       option-spec
+                       (lambda (opt name arg result)
+                         (error "unrecognized option" name))
+                       (lambda (arg result)
+                         (alist-cons 'argument arg result))
+                       '()))
+
+          (define aliases
+            ;; The list of aliases we are asked to load.
+            (filter-map (match-lambda
+                          (('argument . alias) alias)
+                          (_ #f))
+                        options))
+
+          (define linux-module-directory
+            ;; The module directory.  Note: We expect a flat directory here.
+            #$linux-module-directory)
+
+          (define %known-aliases
+            ;; The alias database.
+            (known-module-aliases
+             (string-append linux-module-directory "/modules.alias")))
+
+          (define (device-aliases->module-names aliases)
+            ;; Return the list of module names for the subset of ALIASES that
+            ;; appears in %KNOWN-ALIASES.
+            (append-map (cut matching-modules <> %known-aliases)
+                        aliases))
+
+          (when (assq-ref options 'quiet?)
+            (current-error-port (%make-void-port "w"))
+            (current-output-port (%make-void-port "w")))
+
+          (let ((modules (device-aliases->module-names aliases)))
+            (call-with-output-file "/dev/kmsg"
+              (lambda (port)
+                (format port "modprobe[~a]: aliases ~s; modules ~s; args ~s~%"
+                        (getpid) aliases modules (program-arguments))))
+
+            (when (< (length modules) (length aliases))
+              (error "alias resolution failed" aliases))
+
+            (load-linux-modules-from-directory (reverse modules)
+                                               linux-module-directory)))))
+
+  (program-file "modprobe" program #:guile guile))
 
 (define* (expression->initrd exp
                              #:key
@@ -89,16 +158,16 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (mkdir #$output)
 
           ;; The guile used in the initrd must be present in the store, so
-          ;; that module loading works once the root is switched.
+          ;; that module loading works once the root is switched.  Similarly,
+          ;; the 'modprobe' program installed in /proc/sys/kernel/modprobe by
+          ;; the initrd, if any, must be present after switch root.
           ;;
           ;; To ensure that is the case, add an explicit reference to the
           ;; guile package used in the initrd to the output.
           ;;
-          ;; This fixes guix-patches bug #28399, "Fix mysql activation, and
+          ;; This fixes <https://bugs.gnu.org/28399>, "Fix mysql activation, and
           ;; add a basic test".
-          (call-with-output-file (string-append #$ output "/references")
-            (lambda (port)
-              (simple-format port "~A\n" #$guile)))
+          (copy-file "closure" (string-append #$output "/references"))
 
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
@@ -153,7 +222,9 @@ MODULES and taken from LINUX."
                       (copy-file module
                                  (string-append #$output "/"
                                                 (basename module))))
-                    (delete-duplicates modules)))))
+                    (delete-duplicates modules))
+
+          (write-module-alias-database #$output))))
 
   (computed-file "linux-modules" build-exp))
 
@@ -222,7 +293,8 @@ upon error."
              (set-path-environment-variable "PATH" '("bin" "sbin")
                                             '#$helper-packages)))
 
-         (boot-system #:mounts
+         (boot-system #:modprobe #$(modprobe-program kodir)
+                      #:mounts
                       (map spec->file-system
                            '#$(map file-system->spec file-systems))
                       #:pre-mount (lambda ()
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 4360adf15..ecb7ed506 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -249,6 +249,7 @@ INPUTS is a list of inputs (as for packages)."
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
+                     (linux linux-libre)
                      (qemu qemu-minimal)
                      (disk-image-size 'guess)
                      (disk-image-format "qcow2")
@@ -275,18 +276,37 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (define modprobe-wrapper
+    ;; Wrapper for the 'modprobe' command that knows where modules live.
+    (let ((modprobe (file-append kmod "/bin/modprobe")))
+      (program-file "modprobe"
+                    #~(begin
+                        (setenv "LINUX_MODULE_DIRECTORY"
+                                #$(file-append linux "/lib/modules"))
+                        (apply execl #$modprobe
+                               (cons #$modprobe (cdr (command-line))))))))
+
+
   (expression->derivation-in-linux-vm
    name
    (with-imported-modules (source-module-closure '((gnu build bootloader)
                                                    (gnu build vm)
+                                                   (gnu build activation)
                                                    (guix build utils)))
      #~(begin
          (use-modules (gnu build bootloader)
                       (gnu build vm)
+                      ((gnu build activation) #:select (activate-modprobe))
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
+         ;; We may need to lazy-load modules.  The initrd installs a
+         ;; 'modprobe' that can only search through the modules available in
+         ;; the initrd, but here we want to be able to use all the modules of
+         ;; LINUX.  Thus, install a real 'modprobe'.
+         (activate-modprobe #$modprobe-wrapper)
+
          (let ((inputs
                 '#$(append (list qemu parted e2fsprogs dosfstools)
                            (map canonical-package
@@ -361,6 +381,7 @@ the image."
                                    #$(bootloader-installer bootloader))
              (reboot)))))
    #:system system
+   #:linux linux
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 12:39:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 08:39:54 2018
Received: from localhost ([127.0.0.1]:56087 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evMk6-0002zI-3O
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48198)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evMk3-0002yT-21
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evMjx-0006HO-3V
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:46 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56603)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evMjv-0006Dh-2i; Mon, 12 Mar 2018 08:39:43 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:57474 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evMju-0003VE-Iu; Mon, 12 Mar 2018 08:39:42 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v10 6/6] linux-modules: Add "modules.devname" writer.
Date: Mon, 12 Mar 2018 13:39:18 +0100
Message-Id: <20180312123918.22645-6-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312123918.22645-1-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN>
 <20180312123918.22645-1-ludo@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

* gnu/build/linux-modules.scm (aliases->device-tuple)
(write-module-device-database): New procedures.

Co-authored-by: Danny Milosavljevic <dannym@HIDDEN>.
---
 gnu/build/linux-modules.scm | 48 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 9aabe6d37..2ed04e5b4 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -47,6 +47,8 @@
             known-module-aliases
             matching-modules
             write-module-alias-database
+            write-module-device-database
+
             load-needed-linux-modules))
 
 ;;; Commentary:
@@ -418,6 +420,52 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                              aliases)))
                 aliases))))
 
+(define (aliases->device-tuple aliases)
+  "Traverse ALIASES, a list of module aliases, and search for
+\"char-major-M-N\", \"block-major-M-N\", or \"devname:\" aliases.  When they
+are found, return a tuple (DEVNAME TYPE MAJOR MINOR), otherwise return #f."
+  (define (char/block-major? alias)
+    (or (string-prefix? "char-major-" alias)
+        (string-prefix? "block-major-" alias)))
+
+  (define (char/block-major->tuple alias)
+    (match (string-tokenize alias %not-dash)
+      ((type "major" (= string->number major) (= string->number minor))
+       (list (match type
+               ("char" "c")
+               ("block" "b"))
+             major minor))))
+
+  (let* ((devname     (any (lambda (alias)
+                             (and (string-prefix? "devname:" alias)
+                                  (string-drop alias 8)))
+                           aliases))
+         (major/minor (match (find char/block-major? aliases)
+                        (#f #f)
+                        (str (char/block-major->tuple str)))))
+    (and devname major/minor
+         (cons devname major/minor))))
+
+(define (write-module-device-database directory)
+  "Traverse the '.ko' files in DIRECTORY and create the corresponding
+'modules.devname' file.  This file contains information about modules that can
+be loaded on-demand, such as file system modules."
+  (define aliases
+    (filter-map (lambda (file)
+                  (match (aliases->device-tuple (module-aliases file))
+                    (#f #f)
+                    (tuple (cons (file-name->module-name file) tuple))))
+                (find-files directory "\\.ko$")))
+
+  (call-with-output-file (string-append "/tmp" "/modules.devname")
+    (lambda (port)
+      (display "# Device nodes to trigger on-demand module loading.\n" port)
+      (for-each (match-lambda
+                  ((module devname type major minor)
+                   (format port "~a ~a ~a~a:~a~%"
+                           module devname type major minor)))
+                aliases))))
+
 (define (load-needed-linux-modules module-directory)
   "Examine /sys/devices to find out which modules are needed and load those we
 have in MODULE-DIRECTORY.  Return the list of modules loaded, not including
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 12:39:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 08:39:54 2018
Received: from localhost ([127.0.0.1]:56085 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evMk5-0002zG-RK
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48164)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evMk0-0002yC-O3
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evMju-0006D8-Op
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:43 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56600)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evMjs-00069Q-Sj; Mon, 12 Mar 2018 08:39:40 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:57474 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evMjs-0003VE-8p; Mon, 12 Mar 2018 08:39:40 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v10 4/6] vm: Make the virtio-blk uniquely identifiable in /sys.
Date: Mon, 12 Mar 2018 13:39:16 +0100
Message-Id: <20180312123918.22645-4-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312123918.22645-1-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN>
 <20180312123918.22645-1-ludo@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>,
 =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

From: Danny Milosavljevic <dannym@HIDDEN>

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.

Signed-off-by: Ludovic Courtès <ludo@HIDDEN>
---
 gnu/build/vm.scm  | 6 +++++-
 gnu/system/vm.scm | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..773b738ae 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,11 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+
+                       ;; QEMU seems to have a bug that it doesn't assign PCI
+                       ;; IDs properly, so force the address of our virtio-blk
+                       ;; device.
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 91ff32ce9..4360adf15 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -677,7 +677,12 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+
+     ;; QEMU seems to have a bug that it doesn't assign PCI IDs properly, so
+     ;; force the address of our virtio-blk device.
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 12:39:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 08:39:50 2018
Received: from localhost ([127.0.0.1]:56081 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evMk2-0002yv-Ie
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48145)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evMjz-0002yA-Ea
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evMjt-0006As-IG
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:42 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56599)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evMjr-00066x-JY; Mon, 12 Mar 2018 08:39:39 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:57474 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evMjr-0003VE-1M; Mon, 12 Mar 2018 08:39:39 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v10 3/6] linux-modules: Add 'load-needed-linux-modules'.
Date: Mon, 12 Mar 2018 13:39:15 +0100
Message-Id: <20180312123918.22645-3-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312123918.22645-1-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN>
 <20180312123918.22645-1-ludo@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

Based on a patch by Danny Milosavljevic <dannym@HIDDEN>.

* gnu/build/linux-modules.scm (load-needed-linux-modules): New
procedure.
---
 gnu/build/linux-modules.scm | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 1337b5e88..9aabe6d37 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -30,6 +30,7 @@
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 ftw)
   #:export (dot-ko
             ensure-dot-ko
             module-aliases
@@ -45,7 +46,8 @@
             device-module-aliases
             known-module-aliases
             matching-modules
-            write-module-alias-database))
+            write-module-alias-database
+            load-needed-linux-modules))
 
 ;;; Commentary:
 ;;;
@@ -416,4 +418,34 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                              aliases)))
                 aliases))))
 
+(define (load-needed-linux-modules module-directory)
+  "Examine /sys/devices to find out which modules are needed and load those we
+have in MODULE-DIRECTORY.  Return the list of modules loaded, not including
+dependencies.
+
+Note: loading modules leads to the creation of new entries in /sys/devices,
+which is why we need traversal and loading to be interleaved.  If we walked
+/sys/devices and *then* loaded modules, we'd miss the entries added as a
+side-effect and would thus need to traverse /sys/devices again."
+  (define aliases
+    (known-module-aliases
+     (string-append module-directory "/modules.alias")))
+
+  (define (enter? director stat result) result)
+  (define (down directory stat result) result)
+  (define (up directory stat result) result)
+  (define (skip entry stat result) result)
+  (define (error name stat errno result) result)
+  (define (leaf file stat result)
+    (if (string=? (basename file) "modalias")
+        (let* ((alias   (string-trim-right
+                         (call-with-input-file file get-string-all)))
+               (modules (matching-modules alias aliases)))
+          (load-linux-modules-from-directory modules
+                                             module-directory)
+          (append modules result))
+        result))
+
+  (file-system-fold enter? leaf down up skip error #t "/sys/devices"))
+
 ;;; linux-modules.scm ends here
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 12:39:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 08:39:47 2018
Received: from localhost ([127.0.0.1]:56077 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evMjz-0002yb-B5
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48138)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evMjy-0002y8-Qj
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evMjs-00069I-QV
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:41 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56597)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evMjq-00064l-Gi; Mon, 12 Mar 2018 08:39:38 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:57474 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evMjq-0003VE-0n; Mon, 12 Mar 2018 08:39:38 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v10 2/6] linux-modules: Add
 'load-linux-modules-from-directory'.
Date: Mon, 12 Mar 2018 13:39:14 +0100
Message-Id: <20180312123918.22645-2-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20180312123918.22645-1-ludo@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN>
 <20180312123918.22645-1-ludo@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

* gnu/build/linux-modules.scm (load-linux-modules-from-directory): New
procedure.
* gnu/build/linux-boot.scm (boot-system)[lookup-module]: Remove.
Use 'load-linux-modules-from-directory' instead.
---
 gnu/build/linux-boot.scm    |  9 ++-------
 gnu/build/linux-modules.scm | 12 ++++++++++++
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..df0b2b2d1 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -469,10 +469,6 @@ upon error."
              mounts)
         "ext4"))
 
-  (define (lookup-module name)
-    (string-append linux-module-directory "/"
-                   (ensure-dot-ko name)))
-
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
 
@@ -487,9 +483,8 @@ upon error."
          (start-repl))
 
        (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (load-linux-modules-from-directory linux-modules
+                                          linux-module-directory)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 6101b8dc3..1337b5e88 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -38,6 +38,7 @@
             modules-loaded
             module-loaded?
             load-linux-module*
+            load-linux-modules-from-directory
 
             current-module-debugging-port
 
@@ -232,6 +233,17 @@ appears in BLACK-LIST are not loaded."
              (or (and recursive? (= EEXIST (system-error-errno args)))
                  (apply throw args)))))))
 
+(define (load-linux-modules-from-directory modules directory)
+  "Load MODULES and their dependencies from DIRECTORY, a directory containing
+the '.ko' files.  The '.ko' suffix is automatically added to MODULES if
+needed."
+  (define (lookup-module name)
+    (string-append directory "/" (ensure-dot-ko name)))
+
+  (for-each (cut load-linux-module* <>
+                 #:lookup-module lookup-module)
+            (map lookup-module modules)))
+
 
 ;;;
 ;;; Device modules.
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 12:39:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 08:39:45 2018
Received: from localhost ([127.0.0.1]:56074 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evMjx-0002yK-1z
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:45 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48099)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evMjv-0002y3-Nc
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1evMjp-000637-K7
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:39:38 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56596)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1evMjp-00062u-Fk; Mon, 12 Mar 2018 08:39:37 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:57474 helo=gnu.org)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1evMjp-0003VE-0C; Mon, 12 Mar 2018 08:39:37 -0400
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v10 1/6] linux-modules: Add "modules.alias" writer.
Date: Mon, 12 Mar 2018 13:39:13 +0100
Message-Id: <20180312123918.22645-1-ludo@HIDDEN>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <87ina1qxic.fsf@HIDDEN>
References: <87ina1qxic.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

From: Danny Milosavljevic <dannym@HIDDEN>

* gnu/build/linux-modules.scm (write-module-alias-database): New
procedure.
(%not-dash): New variable.

Co-authored-by: Ludovic Courtès <ludo@HIDDEN>
---
 gnu/build/linux-modules.scm | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 4fe673cca..6101b8dc3 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2016, 2018 Ludovic Courtès <ludo@HIDDEN>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@HIDDEN>
+;;; Copyright © 2018 Danny Milosavljevic <dannym@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,6 +22,7 @@
   #:use-module (guix elf)
   #:use-module (guix glob)
   #:use-module (guix build syscalls)
+  #:use-module ((guix build utils) #:select (find-files))
   #:use-module (rnrs io ports)
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
@@ -41,7 +43,8 @@
 
             device-module-aliases
             known-module-aliases
-            matching-modules))
+            matching-modules
+            write-module-alias-database))
 
 ;;; Commentary:
 ;;;
@@ -380,4 +383,25 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                       module)))
               known-aliases))
 
+(define %not-dash
+  (char-set-complement (char-set #\-)))
+
+(define (write-module-alias-database directory)
+  "Traverse the '.ko' files in DIRECTORY and create the corresponding
+'modules.alias' file."
+  (define aliases
+    (map (lambda (file)
+           (cons (file-name->module-name file) (module-aliases file)))
+         (find-files directory "\\.ko$")))
+
+  (call-with-output-file (string-append directory "/modules.alias")
+    (lambda (port)
+      (display "# Aliases extracted from modules themselves.\n" port)
+      (for-each (match-lambda
+                  ((module . aliases)
+                   (for-each (lambda (alias)
+                               (format port "alias ~a ~a\n" alias module))
+                             aliases)))
+                aliases))))
+
 ;;; linux-modules.scm ends here
-- 
2.16.2





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 12:38:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 12 08:38:56 2018
Received: from localhost ([127.0.0.1]:56069 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1evMjA-0002wg-MJ
	for submit <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:38:56 -0400
Received: from hera.aquilenet.fr ([185.233.100.1]:50622)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1evMj8-0002wV-Et
 for 30604 <at> debbugs.gnu.org; Mon, 12 Mar 2018 08:38:55 -0400
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 60BE812382;
 Mon, 12 Mar 2018 13:38:53 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id g2xEDFGgJYeT; Mon, 12 Mar 2018 13:38:51 +0100 (CET)
Received: from ribbon (vpn-0-27.aquilenet.fr [IPv6:2a0c:e300:4:27::])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 8A5E211CC1;
 Mon, 12 Mar 2018 13:38:51 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN> <20180304133444.4edceecd@HIDDEN>
 <87muzgykcl.fsf@HIDDEN> <20180309231320.20a02822@HIDDEN>
Date: Mon, 12 Mar 2018 13:38:51 +0100
In-Reply-To: <20180309231320.20a02822@HIDDEN> (Danny Milosavljevic's
 message of "Fri, 9 Mar 2018 23:13:20 +0100")
Message-ID: <87ina1qxic.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Heya Danny,

Danny Milosavljevic <dannym@HIDDEN> skribis:

> As I said, modprobe mutates /sys - you cannot use find-files.  I haven't =
used
> ftw just to be contrarian.  There's even a warning comment :-)

I did see this comment, and I don=E2=80=99t doubt you=E2=80=99re acting in =
good faith!

> In order to find that out, try to print how /sys looked before modprobe -=
 then
> in the early guile recovery REPL print how /sys looks again - the alias it
> was juuust complaining about will be there just fine.

It wasn=E2=80=99t clear to me what =E2=80=9Cmodprobe mutates /sys=E2=80=9D =
meant, and I guess I
didn=E2=80=99t think it could lead to not seeing relevant =E2=80=9Cmodalias=
=E2=80=9D files.  Now
I=E2=80=99ve experienced first-hand that it does matter.  :-)

> It took about 30 h to work out the correct minimal combination - just say=
ing :-)

Yeah I can imagine (and it would have taken me much longer I guess.)

While reviewing this series I realized I didn=E2=80=99t understand everythi=
ng,
as in the example above, some things seemed unnecessary, and I thought
we could improve the style of a few things.

The patches that follow build upon your work with a few changes:

  =E2=80=A2 The =E2=80=9Cmodules.alias=E2=80=9D writer style is made more i=
diomatic and
    hopefully simpler.

  =E2=80=A2 The =E2=80=9Cmodules.devname=E2=80=9D writer is actually unnece=
ssary.  I changed it
    to a more functional style and with smaller functions.  It=E2=80=99s the
    last patch of this series; it=E2=80=99s completely optional since we do=
n=E2=80=99t
    use it currently, but we might want to keep it around for later.

  =E2=80=A2 The pure-Scheme modprobe uses SRFI-37 instead of (ice-9
    getopt-long), as in the rest of the code base.

  =E2=80=A2 /proc/sys/kernel/modprobe is set in =E2=80=98boot-system=E2=80=
=99 directly, so that
    we don=E2=80=99t have to special-case the =E2=80=9Cmodprobe=E2=80=9D cl=
osure in
    =E2=80=98build-initrd=E2=80=99.

  =E2=80=A2 =E2=80=98module-aliases->module-file-names=E2=80=99 is gone.  I=
nstead there=E2=80=99s
    =E2=80=98load-needed-linux-modules=E2=80=99, similar to the =E2=80=98lo=
ad-kernel-modules=E2=80=99
    you had, but a bit simpler.

  =E2=80=A2 I added comments here and there, especially about the
    virtio-blk-pci, which was far from obvious.  :-)

I didn=E2=80=99t add the =E2=80=98needed-modules=E2=80=99 and =E2=80=98syst=
em-device-aliases=E2=80=99 procedures
I posted earlier because we don=E2=80=99t need them currently.  If you think
they could be useful, we can always add them.

The following command succeeds:

  make check-system TESTS=3D"basic installed-os iso-image-installer"

WDYT?


I realize that makes for a not-so-efficient review process, though I
think the result is worth it.  I=E2=80=99m open to suggestions though.

Overall, these changes are mostly about (1) making self-contained
commits, (2) commenting code, and (3) coding style.  About #3, I think
the guidelines I applied were:

  1. Avoid imperative style.  When we do need side effects, try hard to
     move them separately.

  2. Keep functions short.

  3. Decompose functions in a way that allows them to be combined
     =E2=80=9Cnicely=E2=80=9D.

Some of that is a bit subjective, but overall we should be able to
converge.

Thanks for the great work, and sorry for the back-and-forth and delays!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 11 Mar 2018 20:24:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 11 16:24:42 2018
Received: from localhost ([127.0.0.1]:55716 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ev7WM-0005n0-KT
	for submit <at> debbugs.gnu.org; Sun, 11 Mar 2018 16:24:42 -0400
Received: from dd26836.kasserver.com ([85.13.145.193]:35408)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ev7WL-0005mp-0p
 for 30604 <at> debbugs.gnu.org; Sun, 11 Mar 2018 16:24:41 -0400
Received: from localhost (178.113.255.63.wireless.dyn.drei.com
 [178.113.255.63])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 2F48B3360C78
 for <30604 <at> debbugs.gnu.org>; Sun, 11 Mar 2018 21:24:39 +0100 (CET)
Date: Sun, 11 Mar 2018 21:24:30 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: Re: [PATCH v9 3/7] linux-initrd: Provide pure-Guile modprobe.
Message-ID: <20180311212430.707ef0ea@HIDDEN>
In-Reply-To: <20180304010914.1322-4-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
 <20180304010914.1322-4-dannym@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/Cey6o_VYT6PJ=veW8WEpofZ"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/Cey6o_VYT6PJ=veW8WEpofZ
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

> +          (define option-spec
> +           '((quiet    (single-char #\q) (value #f))))

Would make sense to also support "-a" (used when invoking modprobe to load =
multiple
kernel modules at once).

--Sig_/Cey6o_VYT6PJ=veW8WEpofZ
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqlkH4ACgkQ5xo1VCww
uqWFsggAiePy7PVn0EvxcvzawT0U/UuWoHTaiMJZDwj5nSBhWHpNLnMGfYe2emd4
q10BZdapDN4FI+4iwRdene+8NbH2y4rsUpM1VMKG12Iq+hNE2v/D1hiBMFgozX1b
jPbvb1NIZXZDT+iHwo2no1fvylSySl4SjE+b68RQpeieKyodums5B9Dg1H7aavcU
B/qo0pkotTl11ChmZ0wAgj3HyZfGndP1b6BBTsUvz1fKFvcYTaH0tryh9oK2Ug1h
lpRdSRtugfCb2BQ9ajzC937gXUTzZ8gNMF8nQm76HPe/WeB+DkXUhMPic1pndz8h
JHTXjkmP8NUywJjnGkmi0N0sruquoA==
=hAM5
-----END PGP SIGNATURE-----

--Sig_/Cey6o_VYT6PJ=veW8WEpofZ--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 9 Mar 2018 22:44:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 09 17:44:41 2018
Received: from localhost ([127.0.0.1]:52918 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1euQkj-0005rG-5v
	for submit <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:44:41 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:52212)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1euQkh-0005r8-5N
 for 30604 <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:44:39 -0500
Received: from localhost (178.113.255.63.wireless.dyn.drei.com
 [178.113.255.63])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 1329B3360156;
 Fri,  9 Mar 2018 23:44:37 +0100 (CET)
Date: Fri, 9 Mar 2018 23:44:34 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
Message-ID: <20180309234434.2bf5e3ff@HIDDEN>
In-Reply-To: <20180309231320.20a02822@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN> <20180304133444.4edceecd@HIDDEN>
 <87muzgykcl.fsf@HIDDEN> <20180309231320.20a02822@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/ZpJsqZ5m19SZZ_H8+EhNO.v"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/ZpJsqZ5m19SZZ_H8+EhNO.v
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

sorry for the many e-mails - I'm recollecting all the workarounds :)

>--8<---------------cut here---------------start------------->8---
>loading '/gnu/store/n2zvdxp25kvg7wy5xr1y5n9r4502fw80-linux-vm-loader'...
>environment variable `PATH' set to `/gnu/store/vxl918zb9brnrgaipzsykpy3mzc=
afvcr-qemu-minimal-2.11.1/bin:/gnu/store/lvkaf3xlvy57bvap51xlzb209ilbkgcv-p=
arted-3.2/sbin:/>gnu/store/nm305rpb2mvridkyj4l3636nc9ql4lf9-e2fsprogs-1.43.=
6/bin:/gnu/store/nm305rpb2mvridkyj4l3636nc9ql4lf9-e2fsprogs-1.43.6/sbin:/gn=
u/>store/0sq2nflm42x0znkv44add0gk82khkcb6-dosfstools-4.1/sbin:/gnu/store/0h=
l513mnpkhszm2hjai2w9cxmpxs0vgq-sed-4.4/bin:/gnu/store/1h44pkgdd7n6s3i2vjh54=
awsvfmc219j->grep-3.1/bin:/gnu/store/kgzvfby2ggi1xawsh5vjh4s93qk2dp9k-coreu=
tils-8.28/bin:/gnu/store/k7r2m2wgj8x8jjhccwjsiimp0dlzxb7i-findutils-4.6.0/b=
in:/gnu/store/>ahxc89r6npzf2bbl8yg5vdjicskzzjf3-gawk-4.1.4/bin'
>creating partition table with 2 partitions (20.0 MiB, 40.0 MiB)...
>Warning: The resulting partition is not properly aligned for best performa=
nce.
>creating ext4 partition...
...
[    3.235493] FAT-fs (vda2): IO charset iso8859-1 not found
ERROR: In procedure mount:
In procedure mount: Invalid argument
--8<---------------cut here---------------end--------------->8---

>Here the nls_iso8859-1 module doesn=E2=80=99t get loaded and modprobe isn=
=E2=80=99t even
>invoked, although my understanding is that it should (per =E2=80=98load_nl=
s=E2=80=99 in
>nls_base.c in the kernel, called from vfat/inode.c).

Yeah, that was an evil problem.  There are two different ways linux-boot
can boot:
* Either it loads a full system in which case /run/booted-system will
contain kernel module files which can and will be loaded
* Or it loads a "--load" file only - in which case there's no system
modprobe, but switch-root just switched our pure-Guile modprobe away,
so now we are out of modprobes :)


--Sig_/ZpJsqZ5m19SZZ_H8+EhNO.v
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqjDlIACgkQ5xo1VCww
uqWZ7Qf+N2/hBERWip1Lvyq6ZzPc425T5v1Jrkahu3TEoHiSJd6IxXG4A/OzqR0h
CehvMgm1sIznAECajIe/4X9UFTi42yOWJZB5aauCVn11kkllTbiEJbbtkhNnScQZ
FNCdyFF8Jese+aUXTpWxY0TucI6xvLwgvU6UYrRHOgND5Ug+G5ilWYTca8sFHena
InbXiYP4GNOGKcPltMn/i05TMOHcnHHUg67jta8VnqEROxHFWwukWtujGxrPu548
Rgcr/o5Lu9EjKGn1zFi+WR4W1Jh2sExFh9hvdHHeox3gAfq+tivXd7vZBYnQNJ88
6v6YlrVDX9OZ7H6eCrmZmxaK1yc9Iw==
=sXjo
-----END PGP SIGNATURE-----

--Sig_/ZpJsqZ5m19SZZ_H8+EhNO.v--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 9 Mar 2018 22:36:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 09 17:36:50 2018
Received: from localhost ([127.0.0.1]:52905 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1euQd7-0005dm-O1
	for submit <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:36:49 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:51540)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1euQd6-0005de-FG
 for 30604 <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:36:48 -0500
Received: from localhost (178.113.255.63.wireless.dyn.drei.com
 [178.113.255.63])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 352B933600C4;
 Fri,  9 Mar 2018 23:36:47 +0100 (CET)
Date: Fri, 9 Mar 2018 23:36:44 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
Message-ID: <20180309233644.7dc53f8e@HIDDEN>
In-Reply-To: <87muzgykcl.fsf@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN> <20180304133444.4edceecd@HIDDEN>
 <87muzgykcl.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/Qcuacp5x8cg/Xqbkmau+X1e"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/Qcuacp5x8cg/Xqbkmau+X1e
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

> Similarly, it seems that virtio_blk has to be loaded explicitly: is not
> reported by =E2=80=98needed-modules=E2=80=99 (i.e., not listed in /sys/=
=E2=80=A6/modalias), nor
> do we get a modprobe query for it.

qemu seems to have a bug that it doesn't assign pci ids properly.

Patch v9 6/7 works around it by fixing the virtio-blk-pci address.

Nicer fixes welcome.

--Sig_/Qcuacp5x8cg/Xqbkmau+X1e
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqjDHwACgkQ5xo1VCww
uqXulgf+OpolkwmELThupRx/W0t2WQJeFm+Ho+G6OdSRoHPG7pIg+Tcb24jtRVTD
87fYf2IRRJe2Vx+O0ASGZd1NfDjyVX+fXnhnvfPRFg9SB2zGRkoLSMuACEelx3Ir
v8qpPnm+CmqUlTBldzTwJ/TSNWHVGB1SH3W/tgGGK0yljFvHIfnPYssrgMT84tDo
+G1yVVtSxSU+5Y0DxkCjTeo4ZYkJ5fn/0lsL96iUSb4vJNlUqDJUo3ALJUa2aa5Z
dmw1zzum71yBzSH2QjPyqqEoxgo/apAA/rqZt1J0o0Yayd+ZETBtDjg0PdSxXl0n
d1cB0c6ejWpFsSxhcDRnjOmXC2Q5ig==
=4rsy
-----END PGP SIGNATURE-----

--Sig_/Qcuacp5x8cg/Xqbkmau+X1e--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 9 Mar 2018 22:26:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 09 17:26:57 2018
Received: from localhost ([127.0.0.1]:52901 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1euQTY-0003R0-PE
	for submit <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:26:56 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:50772)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1euQTX-0003Qs-AL
 for 30604 <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:26:55 -0500
Received: from localhost (178.113.255.63.wireless.dyn.drei.com
 [178.113.255.63])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 26D5D33600C4
 for <30604 <at> debbugs.gnu.org>; Fri,  9 Mar 2018 23:26:54 +0100 (CET)
Date: Fri, 9 Mar 2018 23:26:50 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: Re: [PATCH v9 7/7] linux-initrd: Use
 module-aliases->module-file-names, too.
Message-ID: <20180309232650.0f37fb89@HIDDEN>
In-Reply-To: <20180304010914.1322-8-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
 <20180304010914.1322-8-dannym@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/Qg9Kzc.tiVe2MTnqVgF7R4i"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/Qg9Kzc.tiVe2MTnqVgF7R4i
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Sun,  4 Mar 2018 02:09:14 +0100
Danny Milosavljevic <dannym@HIDDEN> wrote:

> --- a/gnu/system/linux-initrd.scm
> +++ b/gnu/system/linux-initrd.scm
> @@ -161,17 +161,17 @@ the derivations referenced by EXP are automatically=
 copied to the initrd."
>                      #:references-graphs `(("init-closure" ,init)
>                                            ("modprobe-closure" ,modprobe)=
)))
> =20
> -(define (flat-linux-module-directory linux modules)
> -  "Return a flat directory containing the Linux kernel modules listed in
> -MODULES and taken from LINUX."
> +(define (flat-linux-module-directory linux aliases)
> +  "Return a flat directory containing the Linux kernel modules resolved =
by
> +ALIASES and taken from LINUX."
...
> +          (define (find-only-entry directory)
> +            (match (scandir directory)
> +             (("." ".." basename)
> +              (string-append directory "/" basename))))

Probably unsafe since the order is not guaranteed.

--Sig_/Qg9Kzc.tiVe2MTnqVgF7R4i
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqjCioACgkQ5xo1VCww
uqXOZQgAkZgLnU86tFzMFoHikvaAZ41DEtYdjK+787F90a0+RSvTIMDMpFXvL40K
LjRBRv3k7Im8o/gw4v0h0Jx9DhfwKmL7zXOOFkaK4urXx80Gfp49kozLeAUJWutP
LRt3kn4hqw8PQzT/nDW46jH9GnNUyCAk2sANoQQWOdk+LpBc1EHs4Z571y6rQDb8
i6x9Ui3CNvDHYXjWsRDRS1+EIZaKTNpeTbD9/iyZOLltD6CXR37/6vgPyKP/kqE9
RHtHdwyrl6MVfPuomee2iiqC5z1HT+EXWjevXXVkIvP1azIGwM2mWxpJLynDO5Ld
0KYbk0UMDZ3/HFCSbcoODoMwvFeNEA==
=PIV0
-----END PGP SIGNATURE-----

--Sig_/Qg9Kzc.tiVe2MTnqVgF7R4i--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 9 Mar 2018 22:19:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 09 17:19:49 2018
Received: from localhost ([127.0.0.1]:52891 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1euQMf-0003Eu-1p
	for submit <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:19:49 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:50178)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1euQMd-0003En-TO
 for 30604 <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:19:48 -0500
Received: from localhost (178.113.255.63.wireless.dyn.drei.com
 [178.113.255.63])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 8735133600C4;
 Fri,  9 Mar 2018 23:19:46 +0100 (CET)
Date: Fri, 9 Mar 2018 23:19:42 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
Message-ID: <20180309231942.023f6655@HIDDEN>
In-Reply-To: <20180309231320.20a02822@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN> <20180304133444.4edceecd@HIDDEN>
 <87muzgykcl.fsf@HIDDEN> <20180309231320.20a02822@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/GgwLbqb0fXVNFjmMJIU7Cyj"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/GgwLbqb0fXVNFjmMJIU7Cyj
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

oops,

On Fri, 9 Mar 2018 23:13:20 +0100
Danny Milosavljevic <dannym@HIDDEN> wrote:

> As I said, modprobe mutates /sys - you cannot use find-files. =20

I guess technically it's the Linux kernel module that mutates it.

>I haven't used
> ftw just to be contrarian.  There's even a warning comment :-)
>=20
> In order to find that out, try to print how /sys looked before modprobe -=
 then
> in the early guile recovery REPL print how /sys looks again - the alias it
> was juuust complaining about will be there just fine.
>=20
> My patch series works fine lazy-loading the IO charset, virtio_blk, virti=
o_net.

(v9)

--Sig_/GgwLbqb0fXVNFjmMJIU7Cyj
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqjCH4ACgkQ5xo1VCww
uqWLvwgAp6KezsUDCUjxB5czeSEyKuSBRy6gciJgiTDnedaerVSA4+yHafKUUKe1
1JY9TK5I6qJbSnkaBXFK1ajrYEcz69jODXPRbv7NS0NtK+PrJBpIeXXqpVfYhsll
KO2CKDWrZ9A7CXLURtSsRrf8vzhkuccoJs8xQnqqoUPYt6FTRYFm9G6XukWY5Wop
5nXX2it0JYFN2M47Eb99uMy3khSanLUY7iC6Ib9vMxBURVURXXFkteb4FRbYC24c
6P2SxkabRhOkc1SrWOXLaUvLl5FKozFO82elcohJCol4s/osEodG9vS8KNTFD0Ej
XkVhv/a5u7/+i/iqoyuXj4KEU9054A==
=ixMQ
-----END PGP SIGNATURE-----

--Sig_/GgwLbqb0fXVNFjmMJIU7Cyj--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 9 Mar 2018 22:13:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 09 17:13:46 2018
Received: from localhost ([127.0.0.1]:52876 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1euQGo-000345-Iu
	for submit <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:13:46 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:49634)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1euQGm-00033w-QN
 for 30604 <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:13:45 -0500
Received: from localhost (178.113.255.63.wireless.dyn.drei.com
 [178.113.255.63])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 2268033600C4;
 Fri,  9 Mar 2018 23:13:43 +0100 (CET)
Date: Fri, 9 Mar 2018 23:13:20 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
Message-ID: <20180309231320.20a02822@HIDDEN>
In-Reply-To: <87muzgykcl.fsf@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN> <20180304133444.4edceecd@HIDDEN>
 <87muzgykcl.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/GnqWfEzZKnoi.SFxFgthD/Z"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/GnqWfEzZKnoi.SFxFgthD/Z
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

On Fri, 09 Mar 2018 23:06:50 +0100
ludo@HIDDEN (Ludovic Court=C3=A8s) wrote:

> When than happens, our modprobe gets called with the =E2=80=9Cnetdev-eth0=
=E2=80=9D
> alias, which it cannot handle, leading to this error.
>=20
> By explicitly loading =E2=80=9Cvirtio_net=E2=80=9D and


> sleeping a bit,=20

Uhhhhh no please don't.

> point, but fail later on:
...
> --8<---------------cut here---------------end--------------->8---
>=20
> Here the nls_iso8859-1 module doesn=E2=80=99t get loaded and modprobe isn=
=E2=80=99t even
> invoked, although my understanding is that it should (per =E2=80=98load_n=
ls=E2=80=99 in
> nls_base.c in the kernel, called from vfat/inode.c).
>=20
> Similarly, it seems that virtio_blk has to be loaded explicitly: is not
> reported by =E2=80=98needed-modules=E2=80=99 (i.e., not listed in /sys/=
=E2=80=A6/modalias), nor
> do we get a modprobe query for it.
>=20
> All in all on-demand loading seems more complicated that it seemed.
>=20
> What are we missing here?

As I said, modprobe mutates /sys - you cannot use find-files.  I haven't us=
ed
ftw just to be contrarian.  There's even a warning comment :-)

In order to find that out, try to print how /sys looked before modprobe - t=
hen
in the early guile recovery REPL print how /sys looks again - the alias it
was juuust complaining about will be there just fine.

My patch series works fine lazy-loading the IO charset, virtio_blk, virtio_=
net.

It took about 30 h to work out the correct minimal combination - just sayin=
g :-)

--Sig_/GnqWfEzZKnoi.SFxFgthD/Z
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqjBwAACgkQ5xo1VCww
uqV8/Qf+J555Zoy+CZAq38ezF4hHwS5YbLy//BfK3/3lu2RwSu4h53vmvUqcFZrl
vk+Y1Q7b7SJUmzUKCj/doQ+VgjJgpWlBia0PM0H0kNdKYrz4qbCH3KMDmyKKxlUS
m0uMD7xiSef1evuBRttunzQIwv6zCUJn8kqyalkFQZ01lDXv7Mex0vpG/QkTTVJZ
aTregruimbDWlMnNfUfN9aq5tKlvZfBrzysXGVpZDZlbZrUBkGkd4R8Skq4WdAwv
OQcLkclyTwJOzEO7+ZCkw1b2uzKilS0K6kdoSAylcaXkc9wqjaV1feE9HrQkUHb3
OTPBJQScuFZ7VApDRwn6xCL/DfTvhg==
=uf4c
-----END PGP SIGNATURE-----

--Sig_/GnqWfEzZKnoi.SFxFgthD/Z--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 9 Mar 2018 22:06:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 09 17:06:58 2018
Received: from localhost ([127.0.0.1]:52871 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1euQAD-0002tc-Nl
	for submit <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:06:57 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:33794)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1euQAA-0002tT-Ed
 for 30604 <at> debbugs.gnu.org; Fri, 09 Mar 2018 17:06:56 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 790CD10FBA;
 Fri,  9 Mar 2018 23:06:53 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id VAI4MblhOCdW; Fri,  9 Mar 2018 23:06:52 +0100 (CET)
Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id ACD49FFCA;
 Fri,  9 Mar 2018 23:06:51 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN> <20180304133444.4edceecd@HIDDEN>
Date: Fri, 09 Mar 2018 23:06:50 +0100
In-Reply-To: <20180304133444.4edceecd@HIDDEN> (Danny Milosavljevic's
 message of "Sun, 4 Mar 2018 13:34:44 +0100")
Message-ID: <87muzgykcl.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Hello!

I=E2=80=99ve reworked this patch series a bit, but now I=E2=80=99m stuck on=
 this:

Danny Milosavljevic <dannym@HIDDEN> skribis:

> ERROR: In procedure network-interface-flags:
> In procedure network-interface-flags: No such device

When than happens, our modprobe gets called with the =E2=80=9Cnetdev-eth0=
=E2=80=9D
alias, which it cannot handle, leading to this error.

By explicitly loading =E2=80=9Cvirtio_net=E2=80=9D and sleeping a bit, we g=
et past that
point, but fail later on:

--8<---------------cut here---------------start------------->8---
loading '/gnu/store/n2zvdxp25kvg7wy5xr1y5n9r4502fw80-linux-vm-loader'...
environment variable `PATH' set to `/gnu/store/vxl918zb9brnrgaipzsykpy3mzca=
fvcr-qemu-minimal-2.11.1/bin:/gnu/store/lvkaf3xlvy57bvap51xlzb209ilbkgcv-pa=
rted-3.2/sbin:/gnu/store/nm305rpb2mvridkyj4l3636nc9ql4lf9-e2fsprogs-1.43.6/=
bin:/gnu/store/nm305rpb2mvridkyj4l3636nc9ql4lf9-e2fsprogs-1.43.6/sbin:/gnu/=
store/0sq2nflm42x0znkv44add0gk82khkcb6-dosfstools-4.1/sbin:/gnu/store/0hl51=
3mnpkhszm2hjai2w9cxmpxs0vgq-sed-4.4/bin:/gnu/store/1h44pkgdd7n6s3i2vjh54aws=
vfmc219j-grep-3.1/bin:/gnu/store/kgzvfby2ggi1xawsh5vjh4s93qk2dp9k-coreutils=
-8.28/bin:/gnu/store/k7r2m2wgj8x8jjhccwjsiimp0dlzxb7i-findutils-4.6.0/bin:/=
gnu/store/ahxc89r6npzf2bbl8yg5vdjicskzzjf3-gawk-4.1.4/bin'
creating partition table with 2 partitions (20.0 MiB, 40.0 MiB)...
Warning: The resulting partition is not properly aligned for best performan=
ce.
creating ext4 partition...
mke2fs 1.43.6 (29-Aug-2017)
ext2fs_check_if_mount: Can't check if filesystem is mounted due to missing =
mtab file while determining whether /dev/vda1 is mounted.
Creating filesystem with 20480 1k blocks and 5136 inodes
Filesystem UUID: 81a538e9-3efe-406b-bf67-fa153fa3c6a6
Superblock backups stored on blocks:=20
	8193

Allocating group tables: done=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20
Writing inode tables: done=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

[    3.190801] EXT4-fs (vda1): mounted filesystem with ordered data mode. O=
pts: (null)
populating...
clearing file timestamps...
creating FAT partition...
mkfs.fat 4.1 (2017-01-24)
[    3.235493] FAT-fs (vda2): IO charset iso8859-1 not found
ERROR: In procedure mount:
In procedure mount: Invalid argument
--8<---------------cut here---------------end--------------->8---

Here the nls_iso8859-1 module doesn=E2=80=99t get loaded and modprobe isn=
=E2=80=99t even
invoked, although my understanding is that it should (per =E2=80=98load_nls=
=E2=80=99 in
nls_base.c in the kernel, called from vfat/inode.c).

Similarly, it seems that virtio_blk has to be loaded explicitly: is not
reported by =E2=80=98needed-modules=E2=80=99 (i.e., not listed in /sys/=E2=
=80=A6/modalias), nor
do we get a modprobe query for it.

All in all on-demand loading seems more complicated that it seemed.

What are we missing here?

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 12:53:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 04 07:53:35 2018
Received: from localhost ([127.0.0.1]:43529 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esT8w-0006FL-RR
	for submit <at> debbugs.gnu.org; Sun, 04 Mar 2018 07:53:35 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:37396)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esT8v-0006FD-52
 for 30604 <at> debbugs.gnu.org; Sun, 04 Mar 2018 07:53:33 -0500
Received: from localhost (77.118.231.171.wireless.dyn.drei.com
 [77.118.231.171])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 8A0403367616;
 Sun,  4 Mar 2018 13:53:31 +0100 (CET)
Date: Sun, 4 Mar 2018 13:53:27 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 2/7] linux-modules: Add install-modules.
Message-ID: <20180304135327.0a103e57@HIDDEN>
In-Reply-To: <87y3j84xtu.fsf@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-3-dannym@HIDDEN>
 <87y3j84xtu.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/s3HhKKL0oZ8Y2bY0RkrWxz1"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/s3HhKKL0oZ8Y2bY0RkrWxz1
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

On Sat, 03 Mar 2018 23:07:57 +0100
ludo@HIDDEN (Ludovic Court=C3=A8s) wrote:

> We could reuse modules.alias and modules.devname from the =E2=80=98linux-=
libre=E2=80=99
> package (right?), but I guess it doesn=E2=80=99t hurt to generate custom =
ones.

Yes, but it would be somewhat dirty.  Here's why:

Linux-libre contains a superset of modules and also their modules.alias
and modules.devname contain a superset of modules compared to the initrd.

That means

(1) modules.alias would contain aliases which map to modules which
don't exist.  Since we don't for-each it, who cares.

(2) modules.devname would contain devnames for modules which don't
exist.  That means the boot code would create files in /dev which,
when someone accesses them, would try to load modules which don't
exist - and then the access would fail.

Technically both are not bad, but (2) is bad "UX" practise nowadays - and
not done in the Linux world any more since udev exists.

I can still remember the days of 8540 entries static /dev filesystem (as in,
really on the hard disk), 7000 of which didn't work (or even valid for this
system type :P).

If something goes wrong, good luck finding the needle in the haystack
(which /dev file you can use to boot).

--Sig_/s3HhKKL0oZ8Y2bY0RkrWxz1
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqb7EcACgkQ5xo1VCww
uqXPwAf+P1CjrHIU4Ewpz6ucWfrmOOxqL3oR5zvmf1xtQGitXspjCtfP7OQhEok4
NS43aa4Rcurf32znHZvciYwiTIvkziXGJS3aMh7RbbJc2M8VG13gYTLYr9+YRs28
GSGLIFlHKAjozMeyOHOv9zzpMVgTH0zVE0B1dlV+0ttGUxSXu00v9QX4aoWTh97p
p7HNT/yHvdhfYFUJDjiEk63eSvSkLyvWMxqChGU2iTOv3EDCRFREzKMYWHGBfjpu
5wQRUW5uivoX116X0iA2ipwJ6mb8C31yqInEVAFxt6GFzP5+AmwIrdVrGfG4N/we
NkQd9yJol2LXAPV4qI8pfU6h7aFkPQ==
=P/RW
-----END PGP SIGNATURE-----

--Sig_/s3HhKKL0oZ8Y2bY0RkrWxz1--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 12:45:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 04 07:45:13 2018
Received: from localhost ([127.0.0.1]:43520 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esT0r-00062x-LN
	for submit <at> debbugs.gnu.org; Sun, 04 Mar 2018 07:45:13 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:36744)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esT0q-00062p-8C
 for 30604 <at> debbugs.gnu.org; Sun, 04 Mar 2018 07:45:12 -0500
Received: from localhost (77.118.231.171.wireless.dyn.drei.com
 [77.118.231.171])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 2D4963367616;
 Sun,  4 Mar 2018 13:45:11 +0100 (CET)
Date: Sun, 4 Mar 2018 13:45:04 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 2/7] linux-modules: Add install-modules.
Message-ID: <20180304134504.0a15b26d@HIDDEN>
In-Reply-To: <87y3j84xtu.fsf@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-3-dannym@HIDDEN>
 <87y3j84xtu.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/4j2QMexvE7dYMZ.hPX8mPXg"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/4j2QMexvE7dYMZ.hPX8mPXg
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

>   (write-module-alias-database modules port)  ;for =E2=80=9Cmodules.alias=
=E2=80=9D
>   (write-module-device-database modules port) ;for =E2=80=9Cmodules.devna=
me=E2=80=9D

I'd prefer "install-" because their interface is somewhat like install-file
(caller provides output directory and callee adds "modules."* automatically=
).

But I used the names "write-module-"* in the patchset v9.

> I=E2=80=99m not sure we need =E2=80=98install-module-files=E2=80=99 itsel=
f.  Perhaps we can
> inline it at the call site?

Sure.  Did so now.

> For the devname code, please avoid =E2=80=98set!=E2=80=99.

I found an even better way to avoid both.

> The indentation of =E2=80=98match=E2=80=99 forms is wrong.  Would it be O=
K for you to
> pass it through ./etc/indent-code.el?  (It=E2=80=99s non interactive, you=
 don=E2=80=99t
> need to actually use Emacs.)

I'm actually trying to switch to emacs but when I press Tab it messes up
the stuff more.  Is there some kind of configuration for guile indentation?

Also, every time I open gnu/build/linux-modules.scm I get

"The local variables list .. may not be safe

* bug-reference-bug-repexp
* eval: (modify-syntax-entry 126 "'")
* eval: (modify-syntax-entry 36 "'")
* eval: (modify-syntax-entry 43 "'")"

???

--Sig_/4j2QMexvE7dYMZ.hPX8mPXg
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqb6lAACgkQ5xo1VCww
uqVseAf/VW2PLCgcY8nImiTi4YlI/BODnYJVCkVIzmA5x/hS3+5OxKXh1LnUjECD
p50Bhz9u8i6v3P6PFKYa7Om3aowsyKOH9E2nochuk8tGKkbBWTPA6ou2TZcJBE2G
SjswuTE7nUBBIjg8vEEzZ9ufF536jDzrzzsyFaVTHlfCHr/eTJ29fg9fR0wMPGgB
PVHZKSI5J0zrZycmSlO8+I1m/NQGzvUMDE2V01DGGIhbLQhcOSy/YL8hCYwbBF+G
lMznbEgw+ZjvoZCeRJfooZeuRU/myeAbJ1mAVUlTeDLLdZzFKOTqTyRR/e7B9jUT
hCsEiOUOX4Pino5+64dzLsfv16jBcg==
=wMFl
-----END PGP SIGNATURE-----

--Sig_/4j2QMexvE7dYMZ.hPX8mPXg--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 12:34:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 04 07:34:57 2018
Received: from localhost ([127.0.0.1]:43516 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esSqv-0005nq-KX
	for submit <at> debbugs.gnu.org; Sun, 04 Mar 2018 07:34:57 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:35974)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esSqs-0005nh-VM
 for 30604 <at> debbugs.gnu.org; Sun, 04 Mar 2018 07:34:55 -0500
Received: from localhost (77.118.231.171.wireless.dyn.drei.com
 [77.118.231.171])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id D0C543367616;
 Sun,  4 Mar 2018 13:34:52 +0100 (CET)
Date: Sun, 4 Mar 2018 13:34:44 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
Message-ID: <20180304133444.4edceecd@HIDDEN>
In-Reply-To: <87sh9g4vy1.fsf@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/war/2NgU7F4a1M/YUNS3K5e"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/war/2NgU7F4a1M/YUNS3K5e
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

I've been thinking about it some more - I think it can be made to work "you=
r" way.

I'm trying to integrate it right now.

But!  The module-aliases->module-file-names way I've been pursuing (which a=
lso
returns the recursive dependencies) has the advantage of using exactly the =
same
procedure for both flat-linux-module-directory (which copies files) and for
our modprobe (which loads them later).

This means that it's very likely these two will match.

But if load-linux-module* recursively loads modules on its own it's easily
possible that these will diverge - what flat-linux-module-directory is doing
could (accidentially) differ in the future.

Maybe that's overly defensive programming.  What do you think?

My flat-linux-module-directory basically just returns a subset of the direc=
tory
tree it gets as parameter (and flattens it for no reason).

Also, I've been trying to use find-files for /sys before, like you do.
It doesn't work correctly - probably because of the mutation that modprobe =
does
(find-files sorts - not sure whether that's the whole story).

Integration tests just finished - even the basic system test fails because =
of it
now.

I tried only this:

   (define (load-kernel-modules)
     "Examine /sys/devices to find out which modules to load and load them."
-    (define enter?
-      (const #t))
-    (define (down! directory stat result)
-     ;; Note: modprobe mutates the tree starting with DIRECTORY.
-     (let ((modalias-name (string-append directory "/modalias")))
-       (if (file-exists? modalias-name)
-           (let ((modalias
-                 (string-trim-right (call-with-input-file modalias-name
-                                                          read-string)
-                                    #\newline)))
-             (system* "/sbin/modprobe" "-q" "--" modalias))))
-       #t)
-    (define up
-      (const #t))
-    (define skip
-      (const #t))
-    (define leaf
-      (const #t))
-    (define (error name stat errno result)
-      (format (current-error-port) "warning: ~a: ~a~%"
-              name (strerror errno))
-      result)
-    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
+    (for-each (lambda (modalias)
+                (system* "/sbin/modprobe" "-q" "--" modalias))
+              (system-device-aliases)))

Doesn't work anymore...

ERROR: In procedure network-interface-flags:
In procedure network-interface-flags: No such device

(I've exported system-device-aliases)

--Sig_/war/2NgU7F4a1M/YUNS3K5e
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqb5+QACgkQ5xo1VCww
uqXJ9wf/UFzvHkvHtXvKpynbANSL48kLwGHYSKetR6r353nTtySJZV0kVrRf6aEk
eLZnfbjOFX1Y7cQYKPgiC4/lg5JbqxWkWNR0R1zNQvUgXByL8hxfkuZYtwWE7z5G
Buw/dZBJNdRcG8ZlaOw6r88bhD3CtnceI+XhcqH6sOGud2Bef3cn8HO2gLeA5vi9
DOmeXM1wlP45eYxZ+FNKRJ7WXQwsnGo3WTwowpttZQdA0p80BKmjy+7Jv2DOW3D9
z8lfZ/yHeOQkW1PE7vi0TsjTKy1ryFSBfI37MMcOfmFgenkMKG4K/+c9rMUPltGi
0rBPw7P1HKqxQAXWYaISS3MpQRrvpQ==
=uxOr
-----END PGP SIGNATURE-----

--Sig_/war/2NgU7F4a1M/YUNS3K5e--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:55:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:55:12 2018
Received: from localhost ([127.0.0.1]:43392 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esIrn-0005bM-Vj
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:55:12 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42018)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esIrj-0005bB-Ov
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:55:08 -0500
Received: from localhost (77.118.252.91.wireless.dyn.drei.com [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 5E7C533602D9;
 Sun,  4 Mar 2018 02:55:06 +0100 (CET)
Date: Sun, 4 Mar 2018 02:54:54 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
Message-ID: <20180304025454.791a2b87@HIDDEN>
In-Reply-To: <87sh9g4vy1.fsf@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/Bu7nXlkPzNj2tBNhO1bISAs"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/Bu7nXlkPzNj2tBNhO1bISAs
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

Ah, your attached patch is fine, just the proposed usage=20

  (for-each (catch-ENOENT load-linux-module*)
                          ^^^^^^^^^^^^^^^^^^
            (needed-modules
             (known-module-aliases (string-append linux-module-directory
                                                  "/modules.alias"))))

is probably not working.

--Sig_/Bu7nXlkPzNj2tBNhO1bISAs
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqbUe8ACgkQ5xo1VCww
uqXHyAf/ZSamYfxnytp+YzqCZ3ZmoZ/6vD+5H176T5CuMtS7ZtfrkFe4d/lvjB3R
QfAd5rBRzuJ5jO0Or75iGgUleXGO191Rqt/r/AoSeOCur+T3VUAOSrv689F9l/bU
bAOdnOJqNarX7oBrrqmySg0MINUdjaCpWW7B+HSCTuG81fSJl2vdJnUZvPjs25Zn
A+wLozvtzps+wOOrbiQNFspCvwTecMccsUbG+s022c/Ssr/hHxwE43SdUzApR1YZ
F3ugEM1G60KgfXgjTFS9DOKIMLVbfvTZy7J+cbbc9GTrbPhoLFEieUQj+MyjTMb6
oCT+/VZANgBc4YzfoMHEi3Pp1uGg6Q==
=54nz
-----END PGP SIGNATURE-----

--Sig_/Bu7nXlkPzNj2tBNhO1bISAs--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:09:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:09:42 2018
Received: from localhost ([127.0.0.1]:43365 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI9m-0002c7-ES
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:42 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38486)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI9k-0002bt-Sr
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:41 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id EDF6D3362AE1;
 Sun,  4 Mar 2018 02:09:39 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v9 7/7] linux-initrd: Use module-aliases->module-file-names,
 too.
Date: Sun,  4 Mar 2018 02:09:14 +0100
Message-Id: <20180304010914.1322-8-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180304010914.1322-1-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (flat-linux-module-directory): Use
module-aliases->module-file-names.
* gnu/build/linux-modules.scm (file-name->module-name): Export.
---
 gnu/build/linux-modules.scm |  1 +
 gnu/system/linux-initrd.scm | 67 ++++++++++++++++++++++++++-------------------
 2 files changed, 40 insertions(+), 28 deletions(-)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index f6bb0512b..81a4b15b1 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -35,6 +35,7 @@
             ensure-dot-ko
             module-aliases
             module-aliases->module-file-names
+            file-name->module-name
             module-dependencies
             recursive-module-dependencies
             modules-loaded
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 339ecf754..0b976afad 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -161,17 +161,17 @@ the derivations referenced by EXP are automatically copied to the initrd."
                     #:references-graphs `(("init-closure" ,init)
                                           ("modprobe-closure" ,modprobe))))
 
-(define (flat-linux-module-directory linux modules)
-  "Return a flat directory containing the Linux kernel modules listed in
-MODULES and taken from LINUX."
+(define (flat-linux-module-directory linux aliases)
+  "Return a flat directory containing the Linux kernel modules resolved by
+ALIASES and taken from LINUX."
   (define build-exp
     (with-imported-modules (source-module-closure
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex)
+          (use-modules (ice-9 match) (ice-9 ftw)
                        (srfi srfi-1)
-                       (guix build utils)
+                       (guix build utils) ; mkdir-p
                        (gnu build linux-modules))
 
           (define (string->regexp str)
@@ -181,31 +181,42 @@ MODULES and taken from LINUX."
           (define module-dir
             (string-append #$linux "/lib/modules"))
 
-          (define (lookup module)
-            (let ((name (ensure-dot-ko module)))
-              (match (find-files module-dir (string->regexp name))
-                ((file)
-                 file)
-                (()
-                 (error "module not found" name module-dir))
-                ((_ ...)
-                 (error "several modules by that name"
-                        name module-dir)))))
+          (define (find-only-entry directory)
+            (match (scandir directory)
+             (("." ".." basename)
+              (string-append directory "/" basename))))
 
-          (define modules
-            (let ((modules (map lookup '#$modules)))
-              (append modules
-                      (recursive-module-dependencies modules
-                                                     #:lookup-module lookup))))
-
-          (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
+          (define linux-release-module-directory
+            (find-only-entry module-dir))
 
+          (define modules
+            (module-aliases->module-file-names #$linux '#$aliases))
+
+          (define version
+            (basename linux-release-module-directory))
+
+          (define (install-module-files module-files output)
+            "Install MODULE-FILES to OUTPUT.
+Precondition: OUTPUT is an empty directory except for \"modules.builtin\"."
+            (let ((aliases
+                   (map (lambda (module-file-name)
+                          (format #t "copying '~a'...~%" module-file-name)
+                          (copy-file module-file-name
+                           (string-append output "/"
+                                          (basename module-file-name)))
+                         `(,(file-name->module-name module-file-name) .
+                            ,(module-aliases module-file-name)))
+                     (sort module-files string<))))
+              (install-file (string-append linux-release-module-directory
+                                           "/modules.builtin")
+                            output)
+              (write-module-alias-database aliases output)
+              (write-module-device-database aliases output)))
+
+          (let ((output (string-append #$output "/lib/modules/" version)))
+            (mkdir-p output)
+            (install-module-files (delete-duplicates modules) output)
+            #t))))
   (computed-file "linux-modules" build-exp))
 
 (define* (raw-initrd file-systems




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:09:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:09:41 2018
Received: from localhost ([127.0.0.1]:43363 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI9l-0002bu-6h
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:41 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38478)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI9j-0002bm-Na
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:40 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id C5218336224E;
 Sun,  4 Mar 2018 02:09:35 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v9 6/7] vm: Make the virtio-blk uniquely identifiable in /sys.
Date: Sun,  4 Mar 2018 02:09:13 +0100
Message-Id: <20180304010914.1322-7-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180304010914.1322-1-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.
---
 gnu/build/vm.scm  | 2 +-
 gnu/system/vm.scm | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..ebf9e9f6e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,7 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index cf1ec651a..78cc8cad1 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -700,7 +700,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:09:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:09:36 2018
Received: from localhost ([127.0.0.1]:43359 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI9f-0002bZ-UJ
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:36 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38464)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI9d-0002bD-Sj
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:34 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 0ACB03362AE1;
 Sun,  4 Mar 2018 02:09:32 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v9 5/7] vm: Allow qemu-image builder to load Linux kernel
 modules.
Date: Sun,  4 Mar 2018 02:09:12 +0100
Message-Id: <20180304010914.1322-6-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180304010914.1322-1-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/vm.scm (%modprobe-wrapper): New variable.
(qemu-image): Modify.
---
 gnu/system/vm.scm | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 91ff32ce9..cf1ec651a 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -246,6 +246,17 @@ INPUTS is a list of inputs (as for packages)."
    #:single-file-output? #t
    #:references-graphs inputs))
 
+(define (%modprobe-wrapper modprobe linux-module-directory)
+  ;; Wrapper for the 'modprobe' command that knows where modules live.
+  ;;
+  ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+  ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+  ;; environment variable is not set---hence the need for this wrapper.
+  (program-file "modprobe"
+    #~(begin
+        (setenv "LINUX_MODULE_DIRECTORY" #$linux-module-directory)
+        (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))
+
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
@@ -275,20 +286,24 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (let ((modprobe-name (file-append os-drv "/profile/bin/modprobe"))
+        (linux-module-directory (file-append (file-append os-drv "/kernel/lib/modules"))))
   (expression->derivation-in-linux-vm
    name
-   (with-imported-modules (source-module-closure '((gnu build bootloader)
+   (with-imported-modules (source-module-closure '((gnu build activation)
+                                                   (gnu build bootloader)
                                                    (gnu build vm)
                                                    (guix build utils)))
      #~(begin
-         (use-modules (gnu build bootloader)
+         (use-modules (gnu build activation)
+                      (gnu build bootloader)
                       (gnu build vm)
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs dosfstools)
+                '#$(append (list qemu parted e2fsprogs dosfstools kmod)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -302,6 +317,14 @@ the image."
                         inputs)))
 
            (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
+           ;; It's possible that we need to load nls modules in order to
+           ;; mount the new partition.
+           (if (file-exists? #$modprobe-name)
+               (activate-modprobe #$(%modprobe-wrapper modprobe-name
+                                     linux-module-directory))
+               (format (current-error-port)
+                "WARNING: No modprobe found in ~s.  \
+Loading kernel modules will be impossible.\n" #$modprobe-name))
 
            (let* ((graphs     '#$(match inputs
                                    (((names . _) ...)
@@ -364,7 +387,7 @@ the image."
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-   #:references-graphs inputs))
+   #:references-graphs inputs)))
 
 
 ;;;




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:09:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:09:34 2018
Received: from localhost ([127.0.0.1]:43357 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI9e-0002bQ-Mk
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:34 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38456)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI9c-0002b6-W9
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:33 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id DACC533636F2;
 Sun,  4 Mar 2018 02:09:31 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v9 4/7] linux-boot: Load kernel modules only when the hardware
 is present.
Date: Sun,  4 Mar 2018 02:09:11 +0100
Message-Id: <20180304010914.1322-5-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180304010914.1322-1-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 42 +++++++++++++++++++++++++++++++++++-------
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..2236d8971 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -469,9 +469,31 @@ upon error."
              mounts)
         "ext4"))
 
-  (define (lookup-module name)
-    (string-append linux-module-directory "/"
-                   (ensure-dot-ko name)))
+  (define (load-kernel-modules)
+    "Examine /sys/devices to find out which modules to load and load them."
+    (define enter?
+      (const #t))
+    (define (down! directory stat result)
+     ;; Note: modprobe mutates the tree starting with DIRECTORY.
+     (let ((modalias-name (string-append directory "/modalias")))
+       (if (file-exists? modalias-name)
+           (let ((modalias
+                 (string-trim-right (call-with-input-file modalias-name
+                                                          read-string)
+                                    #\newline)))
+             (system* "/sbin/modprobe" "-q" "--" modalias))))
+       #t)
+    (define up
+      (const #t))
+    (define skip
+      (const #t))
+    (define leaf
+      (const #t))
+    (define (error name stat errno result)
+      (format (current-error-port) "warning: ~a: ~a~%"
+              name (strerror errno))
+      result)
+    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
 
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
@@ -486,10 +508,16 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (let* ((kernel-release
+               (utsname:release (uname)))
+              (directory
+               (string-append linux-module-directory "/lib/modules/"
+                              kernel-release))
+              (old-umask (umask #o022)))
+         (make-static-device-nodes directory)
+         (umask old-umask))
+
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 6ad6d75f7..339ecf754 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -266,7 +266,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:09:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:09:33 2018
Received: from localhost ([127.0.0.1]:43354 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI9d-0002bC-Bl
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:33 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38446)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI9b-0002ar-NV
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:32 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 5BBDC336224E;
 Sun,  4 Mar 2018 02:09:30 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v9 3/7] linux-initrd: Provide pure-Guile modprobe.
Date: Sun,  4 Mar 2018 02:09:10 +0100
Message-Id: <20180304010914.1322-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180304010914.1322-1-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (%modprobe): New variable.
(expression->initrd): Add modprobe, LINUX-MODULE-DIRECTORY.
(raw-initrd): Pass KODIR as LINUX-MODULE-DIRECTORY.
* gnu/build/linux-initrd.scm (build-initrd): Add modprobe.
---
 gnu/build/linux-initrd.scm  | 13 ++++++++-
 gnu/system/linux-initrd.scm | 65 ++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..d4cb5e2d8 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init modprobe linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,17 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+     ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (when modprobe
+      (mkdir-p "sbin")
+      (symlink modprobe "sbin/modprobe")
+      (compile-to-cache "sbin/modprobe"))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index e0cb59c00..6ad6d75f7 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -46,7 +46,8 @@
             %base-initrd-modules
             raw-initrd
             file-system-packages
-            base-initrd))
+            base-initrd
+            %modprobe))
 
 
 ;;; Commentary:
@@ -56,11 +57,61 @@
 ;;;
 ;;; Code:
 
+(define* (%modprobe linux-module-directory #:key
+                    (guile %guile-static-stripped))
+  "Minimal implementation of modprobe for our initrd.
+LINUX-MODULE-DIRECTORY is the directory that contains \"lib\"."
+  (program-file "modprobe"
+    (with-imported-modules (source-module-closure
+                            '((gnu build linux-modules)))
+      #~(begin
+          (use-modules (gnu build linux-modules) (ice-9 getopt-long)
+                       (ice-9 match) (srfi srfi-1))
+          (define option-spec
+           '((quiet    (single-char #\q) (value #f))))
+          (define options
+            (getopt-long (command-line) option-spec))
+          (when (option-ref options 'quiet #f)
+            (current-error-port (%make-void-port "w"))
+            (current-output-port (%make-void-port "w")))
+          (let ((exit-status 0))
+            (for-each (match-lambda
+                        (('quiet . #t)
+                         #f)
+                        ((() aliases ...)
+                         (catch #t
+                           (lambda ()
+                             (let ((module-file-names
+                                    (module-aliases->module-file-names
+                                     #$linux-module-directory aliases)))
+                               (for-each (lambda (name)
+                                           (catch 'system-error
+                                             (lambda ()
+                                               (when (not (load-linux-module* name
+                                                                              #:recursive?
+                                                                              #f))
+                                                 (set! exit-status 1)))
+                                             (lambda (key . args)
+                                               (when (not (= EEXIST
+                                                             (system-error-errno
+                                                              (cons key args))))
+                                                 (print-exception (current-error-port)
+                                                                  #f key args)
+                                                 (set! exit-status 1)))))
+                                         module-file-names)))
+                           (lambda (key . args)
+                             (print-exception (current-error-port)
+                                              #f key args)
+                             (set! exit-status 1)))))
+                      options)
+            (exit exit-status))))
+  #:guile guile))
 
 (define* (expression->initrd exp
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -73,6 +124,9 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (define init
     (program-file "init" exp #:guile guile))
 
+  (define modprobe
+    (%modprobe linux-module-directory #:guile guile))
+
   (define builder
     (with-imported-modules (source-module-closure
                             '((gnu build linux-initrd)))
@@ -96,12 +150,16 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
+                        #:modprobe #$modprobe
+                        #:linux-module-directory #$linux-module-directory
                         ;; Copy everything INIT refers to into the initrd.
-                        #:references-graphs '("closure")
+                        #:references-graphs '("init-closure"
+                                              "modprobe-closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
 
   (gexp->derivation name builder
-                    #:references-graphs `(("closure" ,init))))
+                    #:references-graphs `(("init-closure" ,init)
+                                          ("modprobe-closure" ,modprobe))))
 
 (define (flat-linux-module-directory linux modules)
   "Return a flat directory containing the Linux kernel modules listed in
@@ -225,6 +283,7 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:09:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:09:32 2018
Received: from localhost ([127.0.0.1]:43350 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI9b-0002at-W1
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:32 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38438)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI9a-0002ad-78
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:30 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 483A83362AE1;
 Sun,  4 Mar 2018 02:09:29 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v9 2/7] linux-modules: Add module-aliases->module-file-names.
Date: Sun,  4 Mar 2018 02:09:09 +0100
Message-Id: <20180304010914.1322-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180304010914.1322-1-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (module-aliases->module-file-names): New
procedure.
---
 gnu/build/linux-modules.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 0aaf2ff6f..f6bb0512b 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -21,6 +21,7 @@
   #:use-module (guix elf)
   #:use-module (guix glob)
   #:use-module (guix build syscalls)
+  #:use-module (guix build utils) ; find-files
   #:use-module (rnrs io ports)
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
@@ -28,9 +29,12 @@
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 regex)
+  #:use-module (ice-9 ftw)
   #:export (dot-ko
             ensure-dot-ko
             module-aliases
+            module-aliases->module-file-names
             module-dependencies
             recursive-module-dependencies
             modules-loaded
@@ -438,4 +442,55 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                           (format port "~a ~a ~a~a:~a\n" module devname
                                        "b" major minor)))))))) aliases))))
 
+(define (module-aliases->module-file-names linux aliases)
+  "Resolve ALIASES to module file names, including their dependencies (which will appear
+first).  Each alias will map to a list of module file names.
+LINUX is the directory containing \"lib\"."
+  (define (string->regexp str)
+    ;; Return a regexp that matches STR exactly.
+    (string-append "^" (regexp-quote str) "$"))
+
+  (define module-dir
+    (string-append linux "/lib/modules"))
+
+  (define (find-only-entry directory)
+    (match (scandir directory)
+     (("." ".." basename)
+      (string-append directory "/" basename))))
+
+  (define linux-release-module-directory
+    (find-only-entry module-dir))
+
+  (define known-module-aliases*
+    (known-module-aliases
+     (string-append linux-release-module-directory
+                    "/modules.alias")))
+  (define (resolve-alias alias)
+    "If possible, resolve ALIAS to a list of module names.
+Otherwise return just ALIAS as possible module names."
+    (match (delete-duplicates (matching-modules alias
+                                                known-module-aliases*))
+           (()
+            (list alias))
+           (items
+            items)))
+
+  (define (lookup module)
+    (let ((name (ensure-dot-ko module)))
+      (match (find-files module-dir (string->regexp name))
+             ((file)
+              file)
+             (()
+              (error "module not found" name module-dir))
+             ((_ ...)
+              (error "several modules by that name"
+                     name module-dir)))))
+  (append-map (lambda (alias)
+                (let ((modules (map lookup (resolve-alias alias))))
+                  (append (recursive-module-dependencies modules
+                                                         #:lookup-module
+                                                         lookup)
+                          modules)))
+              aliases))
+
 ;;; linux-modules.scm ends here




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:09:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:09:30 2018
Received: from localhost ([127.0.0.1]:43348 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI9a-0002ak-Ng
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:30 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38428)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI9Z-0002aS-2c
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:29 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 12781336224E;
 Sun,  4 Mar 2018 02:09:27 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v9 1/7] linux-modules: Add "modules.devname" and
 "modules.alias" writer.
Date: Sun,  4 Mar 2018 02:09:08 +0100
Message-Id: <20180304010914.1322-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180304010914.1322-1-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
 <20180304010914.1322-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (write-module-alias-database): New procedure.
(write-module-device-database): New procedure.
(%not-dash): New variable.
---
 gnu/build/linux-modules.scm | 58 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 4fe673cca..0aaf2ff6f 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -36,6 +36,8 @@
             modules-loaded
             module-loaded?
             load-linux-module*
+            write-module-alias-database
+            write-module-device-database
 
             current-module-debugging-port
 
@@ -380,4 +382,60 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                       module)))
               known-aliases))
 
+(define %not-dash
+  (char-set-complement (char-set #\-)))
+
+(define (write-module-alias-database aliases output)
+  "Install \"modules.alias\" for ALIASES to directory OUTPUT."
+  (call-with-output-file (string-append output "/modules.alias")
+    (lambda (port)
+      (format port
+              "# Aliases extracted from modules themselves.\n")
+      (for-each (match-lambda ((module . aliases)
+                               (for-each (lambda (alias)
+                                           (format port "alias ~a ~a\n" alias
+                                                   module))
+                                         aliases)))
+                aliases))))
+
+(define (write-module-device-database aliases output)
+  "Install \"modules.devname\" for ALIASES to directory OUTPUT."
+  (call-with-output-file (string-append output "/modules.devname")
+    (lambda (port)
+      (format port
+              "# Device nodes to trigger on-demand module loading.\n")
+      (for-each (match-lambda
+                 ((module . aliases)
+                  (let* ((interesting-aliases
+                          ;; Note: there's only one devname and then only one
+                          ;; (char-major|block-major).
+                          (filter-map
+                           (match-lambda
+                            ((? (cut string-prefix? "devname:" <>) alias)
+                             `(devname . ,(string-drop alias (string-length "devname:"))))
+                            ((? (cut string-prefix? "char-major-" <>) alias)
+                             `(char-major . ,(string-drop alias (string-length "char-major-"))))
+                            ((? (cut string-prefix? "block-major-" <>) alias)
+                             `(block-major . ,(string-drop alias (string-length "block-major-"))))
+                            (_ #f))
+                           aliases))
+                         (devname (assq-ref interesting-aliases
+                                            'devname))
+                         (char-major (assq-ref interesting-aliases
+                                               'char-major))
+                         (block-major (assq-ref interesting-aliases
+                                               'block-major)))
+                    (when (and devname char-major)
+                      (let ((parts (string-tokenize char-major %not-dash)))
+                        (match parts
+                         ((major minor)
+                          (format port "~a ~a ~a~a:~a\n" module devname
+                                       "c" major minor)))))
+                    (when (and devname block-major)
+                      (let ((parts (string-tokenize block-major %not-dash)))
+                        (match parts
+                         ((major minor)
+                          (format port "~a ~a ~a~a:~a\n" module devname
+                                       "b" major minor)))))))) aliases))))
+
 ;;; linux-modules.scm ends here




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:09:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:09:28 2018
Received: from localhost ([127.0.0.1]:43344 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI9Y-0002aP-Ft
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:28 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38420)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI9W-0002aH-Iu
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:09:26 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 93D15336224E;
 Sun,  4 Mar 2018 02:09:25 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v9 0/7] Load Linux module only when supported hardware is
 present.
Date: Sun,  4 Mar 2018 02:09:07 +0100
Message-Id: <20180304010914.1322-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180303135533.6112-1-dannym@HIDDEN>
References: <20180303135533.6112-1-dannym@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Danny Milosavljevic (7):
  linux-modules: Add "modules.devname" and "modules.alias" writer.
  linux-modules: Add module-aliases->module-file-names.
  linux-initrd: Provide pure-Guile modprobe.
  linux-boot: Load kernel modules only when the hardware is present.
  vm: Allow qemu-image builder to load Linux kernel modules.
  vm: Make the virtio-blk uniquely identifiable in /sys.
  linux-initrd: Use module-aliases->module-file-names, too.

 gnu/build/linux-boot.scm    |  42 +++++++++++---
 gnu/build/linux-initrd.scm  |  13 ++++-
 gnu/build/linux-modules.scm | 114 +++++++++++++++++++++++++++++++++++++
 gnu/build/vm.scm            |   2 +-
 gnu/system/linux-initrd.scm | 136 +++++++++++++++++++++++++++++++++-----------
 gnu/system/vm.scm           |  34 +++++++++--
 6 files changed, 295 insertions(+), 46 deletions(-)





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 4 Mar 2018 01:07:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 20:07:05 2018
Received: from localhost ([127.0.0.1]:43340 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esI7F-0002XB-1r
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:07:05 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38238)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esI7D-0002Wy-96
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 20:07:03 -0500
Received: from localhost (77.118.252.91.wireless.dyn.drei.com [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 99A22336224E;
 Sun,  4 Mar 2018 02:07:01 +0100 (CET)
Date: Sun, 4 Mar 2018 02:06:43 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: ludo@HIDDEN (Ludovic =?ISO-8859-1?Q?Court=E8s?=)
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
Message-ID: <20180304020643.6773e016@HIDDEN>
In-Reply-To: <87sh9g4vy1.fsf@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
 <87sh9g4vy1.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/2j+BS72XcrZBeirf3UmbMmD"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/2j+BS72XcrZBeirf3UmbMmD
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Ludo,

On Sat, 03 Mar 2018 23:48:38 +0100
ludo@HIDDEN (Ludovic Court=C3=A8s) wrote:

> > +             (system* "/sbin/modprobe" "-q" "--" modalias)))) =20
>=20
> If we change =E2=80=98flat-linux-module-directory=E2=80=99 to produce a =
=E2=80=98modules.alias=E2=80=99
> file, here we could read =E2=80=98modules.aliases=E2=80=99 directly and l=
oad the right
> thing.
>=20
> With the patch below, we get =E2=80=98needed-modules=E2=80=99, and we cou=
ld simply do:
>=20
>   (for-each (catch-ENOENT load-linux-module*)
>             (needed-modules
>              (known-module-aliases (string-append linux-module-directory
>                                                   "/modules.alias"))))
>=20
> and we can do away with kmod=E2=80=99s modprobe.

It's not kmod's modprobe anymore.  It's our pure-Guile implementation.

Linux lazy-invokes modprobe (for example when mounting stuff), so
/sbin/modprobe is never going away - but it can be our implementation.

I doubt it will take the modules from the correct directory with your patch.
(Of course otherwise it looks much nicer - but I think it won't pass the te=
sts)

My newest version (v9) will use the same procedure for both computing the l=
ist
of modules for flat-linux-module-directory and the list of modules that are=
 to
be modprobed - I think it's nice to be able to keep those in sync so we don=
't
get nasty surprises.  Let's see how that goes...

--Sig_/2j+BS72XcrZBeirf3UmbMmD
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqbRqMACgkQ5xo1VCww
uqXDwQgAowI5zaIU+SBYbyZPcBgJoXZC0c5raPEdUouIjGTcIY3A0uIY9hLfuMDX
kX+Sg60ZEvxBtoJmsy9eMNKlvuzVduB8jNEouH1MQcUBLu6wSLvHhkQRHjamAHkN
oRKpLTj429itvdQ0jNewulqshW3xeeneepYDITKFD/sOAHt/ek0DFthYYxIJUEXY
PXLkJ+O2mCyspt4uoc+8L+4dtEO9gv3asmu4mhk8D5+bXZ0DgBVsNqmQrOe3XSkc
S0no3CafpSInmq+HuGAbFwnJcQbp1ISd3AoSMXEBAfaSVoaE/ZzKFKLgavNuvbpD
SQdW8dstK+ZyUiOP6KiaG3g5tn2AHg==
=Qtnk
-----END PGP SIGNATURE-----

--Sig_/2j+BS72XcrZBeirf3UmbMmD--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 22:48:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 17:48:43 2018
Received: from localhost ([127.0.0.1]:43292 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esFxL-0007rb-JY
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 17:48:43 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:55216)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1esFxJ-0007rS-9F
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 17:48:41 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 72AED11DE2;
 Sat,  3 Mar 2018 23:48:40 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Siot1ErsUpmx; Sat,  3 Mar 2018 23:48:39 +0100 (CET)
Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 3465211D90;
 Sat,  3 Mar 2018 23:48:39 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v8 3/7] linux-boot: Load kernel modules only
 when the hardware is present.
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-4-dannym@HIDDEN>
Date: Sat, 03 Mar 2018 23:48:38 +0100
In-Reply-To: <20180303135533.6112-4-dannym@HIDDEN> (Danny
 Milosavljevic's message of "Sat, 3 Mar 2018 14:55:29 +0100")
Message-ID: <87sh9g4vy1.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Danny Milosavljevic <dannym@HIDDEN> skribis:

> * gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
> the hardware is present.
> (lookup-module): Delete procedure.
> * gnu/system/linux-initrd.scm (raw-initrd): Add imports.

[...]

> +  (define (load-kernel-modules)
> +    "Examine /sys/devices to find out which modules to load and load the=
m."
> +    (define enter?
> +      (const #t))
> +    (define (down! directory stat result)
> +     ;; Note: modprobe mutates the tree starting with DIRECTORY.
> +     (let ((modalias-name (string-append directory "/modalias")))
> +       (if (file-exists? modalias-name)
> +           (let ((modalias
> +                 (string-trim-right (call-with-input-file modalias-name
> +                                                          read-string)
> +                                    #\newline)))
> +             (system* "/sbin/modprobe" "-q" "--" modalias))))

If we change =E2=80=98flat-linux-module-directory=E2=80=99 to produce a =E2=
=80=98modules.alias=E2=80=99
file, here we could read =E2=80=98modules.aliases=E2=80=99 directly and loa=
d the right
thing.

With the patch below, we get =E2=80=98needed-modules=E2=80=99, and we could=
 simply do:

  (for-each (catch-ENOENT load-linux-module*)
            (needed-modules
             (known-module-aliases (string-append linux-module-directory
                                                  "/modules.alias"))))

and we can do away with kmod=E2=80=99s modprobe.

Thoughts?

Ludo=E2=80=99.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 4a6d4ff08..251095072 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -20,6 +20,7 @@
 (define-module (gnu build linux-modules)
   #:use-module (guix elf)
   #:use-module (guix glob)
+  #:use-module (guix build utils)
   #:use-module (guix build syscalls)
   #:use-module (rnrs io ports)
   #:use-module (rnrs bytevectors)
@@ -40,7 +41,8 @@
 
             device-module-aliases
             known-module-aliases
-            matching-modules))
+            matching-modules
+            needed-modules))
 
 ;;; Commentary:
 ;;;
@@ -370,4 +372,25 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                       module)))
               known-aliases))
 
+(define (system-device-aliases)
+  "Browse /sys/devices in search of \"modalias\" files and return the list of
+device aliases for the current system."
+  (let ((files (find-files "/sys/devices"
+                           (lambda (file stat)
+                             (and (eq? 'regular (stat:type stat))
+                                  (string=? "modalias" (basename file)))))))
+    (filter-map (lambda (file)
+                  (match (string-trim-right
+                          (call-with-input-file file get-string-all))
+                    ("" #f)
+                    (alias alias)))
+                files)))
+
+(define* (needed-modules #:optional (known-aliases (known-module-aliases)))
+  "Return the list of modules needed by devices on the current system.  This
+is achieved by browsing /sys/devices and returning the maching modules from
+KNOWN-ALIASES."
+  (append-map (cut matching-modules <> known-aliases)
+              (system-device-aliases)))
+
 ;;; linux-modules.scm ends here

--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 22:08:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 17:08:01 2018
Received: from localhost ([127.0.0.1]:43244 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esFJx-0006tn-DJ
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 17:08:01 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:54960)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1esFJv-0006tY-Em
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 17:07:59 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id E8E4011D90;
 Sat,  3 Mar 2018 23:07:58 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id ZNbPZTCOq_gq; Sat,  3 Mar 2018 23:07:58 +0100 (CET)
Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id F3B58111A6;
 Sat,  3 Mar 2018 23:07:57 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v8 2/7] linux-modules: Add install-modules.
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-3-dannym@HIDDEN>
Date: Sat, 03 Mar 2018 23:07:57 +0100
In-Reply-To: <20180303135533.6112-3-dannym@HIDDEN> (Danny
 Milosavljevic's message of "Sat, 3 Mar 2018 14:55:28 +0100")
Message-ID: <87y3j84xtu.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Danny Milosavljevic <dannym@HIDDEN> skribis:

> * gnu/build/linux-modules.scm (install-modules): New procedure.
> (%not-dash): New variable.

We could reuse modules.alias and modules.devname from the =E2=80=98linux-li=
bre=E2=80=99
package (right?), but I guess it doesn=E2=80=99t hurt to generate custom on=
es.

> +(define (install-module-files module-files output)
> +  "Install MODULE-FILES to OUTPUT.
> +Precondition: OUTPUT is an empty directory."
> +  (let ((aliases
> +         (map (lambda (module-file-name)
> +                (format #t "copying '~a'...~%" module-file-name)
> +                (copy-file module-file-name
> +                           (string-append output "/"
> +                                          (basename module-file-name)))
> +                `(,(file-name->module-name module-file-name) .
> +                  ,(module-aliases module-file-name)))
> +              (sort module-files string<))))
> +    (call-with-output-file (string-append output "/modules.alias")
> +      (lambda (port)
> +        (format port
> +                "# Aliases extracted from modules themselves.\n")
> +        (for-each (match-lambda ((module . aliases)
> +                                 (for-each (lambda (alias)
> +                                             (format port "alias ~a ~a\n=
" alias
> +                                                     module))
> +                                           aliases)))
> +                  aliases)))
> +    (call-with-output-file (string-append output "/modules.devname")
> +      (lambda (port)
> +        (format port
> +                "# Device nodes to trigger on-demand module loading.\n")
> +        (let* ((aliases (append-map (match-lambda
> +                                     ((module . aliases) aliases))
> +                                    aliases))
> +               (devname #f))
> +          ;; Note: there's only one devname and then only one (char-majo=
r|block-major).
> +          (for-each
> +           (match-lambda
> +            (((? (cut string-prefix? "devname:" <>) alias) . value)
> +             (set! devname (string-drop value (string-length "devname:")=
)))
> +            (((? (cut string-prefix? "char-major-" <>) alias) . value)
> +             (let ((parts (string-tokenize %not-dash)))
> +               (match parts
> +                      ((a b major minor)
> +                       (format port "~a ~a ~a:~a\n" devname "c" major mi=
nor)))))
> +            (((? (cut string-prefix? "block-major-" <>) alias) . value)
> +             (let ((parts (string-tokenize %not-dash)))
> +               (match parts
> +                      ((a b major minor)
> +                       (format port "~a ~a ~a:~a\n" devname "b" major mi=
nor)))))
> +            (_ #f))
> +           aliases))))))

I think we need different procedures here:

  (write-module-alias-database modules port)  ;for =E2=80=9Cmodules.alias=
=E2=80=9D
  (write-module-device-database modules port) ;for =E2=80=9Cmodules.devname=
=E2=80=9D

with docstrings.

I=E2=80=99m not sure we need =E2=80=98install-module-files=E2=80=99 itself.=
  Perhaps we can
inline it at the call site?

For the devname code, please avoid =E2=80=98set!=E2=80=99.  Instead you can=
 thread the
current devname as the state of a loop:

  (let loop ((devname #f)
             (aliases aliases))
    (match aliases
      (() =E2=80=A6)
      (((? devname-alias? devname) . rest)
       (loop devname rest))
      =E2=80=A6))
=20=20=20=20=20=20=20
The indentation of =E2=80=98match=E2=80=99 forms is wrong.  Would it be OK =
for you to
pass it through ./etc/indent-code.el?  (It=E2=80=99s non interactive, you d=
on=E2=80=99t
need to actually use Emacs.)

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 21:58:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 16:58:40 2018
Received: from localhost ([127.0.0.1]:43230 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esFAu-0006ep-4C
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 16:58:40 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:54924)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1esFAs-0006eh-IA
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 16:58:39 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id EA45611D90;
 Sat,  3 Mar 2018 22:58:37 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id gcfN9Wz-4cDE; Sat,  3 Mar 2018 22:58:37 +0100 (CET)
Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 113E8111A6;
 Sat,  3 Mar 2018 22:58:37 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v8 1/7] linux-modules: Add module-aliases.
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-2-dannym@HIDDEN>
Date: Sat, 03 Mar 2018 22:58:36 +0100
In-Reply-To: <20180303135533.6112-2-dannym@HIDDEN> (Danny
 Milosavljevic's message of "Sat, 3 Mar 2018 14:55:27 +0100")
Message-ID: <87371g6ctv.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Danny Milosavljevic <dannym@HIDDEN> skribis:

> * gnu/build/linux-modules.scm (module-aliases): New variable.

LGTM!

> +(define (module-aliases file)
> +  "Return the list of aliases of module FILE."
> +  (let ((info (modinfo-section-contents file)))
> +    (filter-map (match-lambda
> +                 (('alias . value)
> +                  value)
> +                 (_ #f)) (modinfo-section-contents file))))

Nitpick: align like this:

  (filter-map first
              second)

when the first arg spans several lines.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 18:01:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 13:01:44 2018
Received: from localhost ([127.0.0.1]:42985 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1esBTc-0005ez-9z
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 13:01:44 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:33880)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1esBTZ-0005ep-Tx
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 13:01:42 -0500
Received: from localhost (77.118.252.91.wireless.dyn.drei.com [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 4079833602C9
 for <30604 <at> debbugs.gnu.org>; Sat,  3 Mar 2018 19:01:40 +0100 (CET)
Date: Sat, 3 Mar 2018 19:01:31 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: Re: [PATCH v8 7/7] linux-initrd: Factorize %modprobe and
 flat-linux-module-directory.
Message-ID: <20180303190131.5a400f7d@HIDDEN>
In-Reply-To: <20180303135533.6112-8-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-8-dannym@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/2RZK+1d+ZEai1B.L8BmqBOA"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/2RZK+1d+ZEai1B.L8BmqBOA
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

> +                       (guix build utils) ; TODO: Remove

Required for mkdir-p

--Sig_/2RZK+1d+ZEai1B.L8BmqBOA
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqa4vsACgkQ5xo1VCww
uqXOsgf/YAhsza+9v+prxTjzBWMjmdnk4mmMOMjJMoKQvMJlUDKzpVGXRBmmiAXc
gkDel+oaMwi59dhe9jCmMb6cxDETIrFWk7HTHnjpAW5TwS6giIDu4ka83Qk65hI0
cQYgntsHOLfoOrONKnZ9Aw6TnG19lZAsyga1efmFllvyuU+tXuKAde2YZhrbx9ri
vvKJTIVmeAd5tXRxhw44yniPigWS2MRJkEasgYOJPNbaBtoZ4JkfIaWkBIGxsDtF
uVw+JxlMqp/SlbnPPEdYasDWSijIv9ypqAFjNoU/oZd9NqjO8ORSdctRutKy///R
ANg1nn1m7F3x48yAenSc78etjezWfA==
=ILLM
-----END PGP SIGNATURE-----

--Sig_/2RZK+1d+ZEai1B.L8BmqBOA--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 15:32:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 10:32:28 2018
Received: from localhost ([127.0.0.1]:42955 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es999-0000La-Vr
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 10:32:28 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:51092)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es998-0000LS-Eb
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 10:32:26 -0500
Received: from localhost (77.118.252.91.wireless.dyn.drei.com [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id C19CD336173E
 for <30604 <at> debbugs.gnu.org>; Sat,  3 Mar 2018 16:32:24 +0100 (CET)
Date: Sat, 3 Mar 2018 16:32:12 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: Re: [PATCH v8 2/7] linux-modules: Add install-modules.
Message-ID: <20180303163212.40f17905@HIDDEN>
In-Reply-To: <20180303135533.6112-3-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
 <20180303135533.6112-3-dannym@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 boundary="Sig_/bCYi916gqBvqPpM=6.JlJQN"; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--Sig_/bCYi916gqBvqPpM=6.JlJQN
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

> +          ;; Note: there's only one devname and then only one (char-majo=
r|block-major).
> +          (for-each
> +           (match-lambda
> +            (((? (cut string-prefix? "devname:" <>) alias) . value)
> +             (set! devname (string-drop value (string-length "devname:")=
)))
> +            (((? (cut string-prefix? "char-major-" <>) alias) . value)
> +             (let ((parts (string-tokenize %not-dash)))
> +               (match parts
> +                      ((a b major minor)
> +                       (format port "~a ~a ~a:~a\n" devname "c" major mi=
nor)))))
> +            (((? (cut string-prefix? "block-major-" <>) alias) . value)
> +             (let ((parts (string-tokenize %not-dash)))
> +               (match parts
> +                      ((a b major minor)
> +                       (format port "~a ~a ~a:~a\n" devname "b" major mi=
nor)))))
> +            (_ #f))
> +           aliases))))))

Probably better to be more careful that devname is set early enough.

--Sig_/bCYi916gqBvqPpM=6.JlJQN
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqav/wACgkQ5xo1VCww
uqV50wf/VBhDH1xsp4i365g/suHyV27f38/lFep7ohe11uMGlKxolmCCaGoo8/bC
lhVuRnGme8dWV3DaKW8Ih+DE82FkZr+EulBxK9MmPxuw3FRCZDqw058PPkjM+pAM
a09O8uj3qHTsWhNZzKA+Mf0o442+Pz4MwQE2JnX1eEuFltTzBrVAKjIsgbHgmRfh
OAfPnmmBK3lNRTDB/qLvc6U1iuZOP+JduRr05kr7cjOFDZ2Rr0Q1dgB034GXwlj0
3dCw2izbdKc6xhGP5wjDt6Hradg+ReglrDgLzh0mXY0hq9aUIvXxj9ngA3Q05gu1
5n9B45TPg7OOKL7hsHumczfWFXLBLA==
=EtMr
-----END PGP SIGNATURE-----

--Sig_/bCYi916gqBvqPpM=6.JlJQN--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 13:55:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 08:55:55 2018
Received: from localhost ([127.0.0.1]:41979 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es7di-0006MV-Kv
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:55 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43814)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es7dg-0006Lv-Gh
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:53 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 7EA443362284;
 Sat,  3 Mar 2018 14:55:51 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v8 7/7] linux-initrd: Factorize %modprobe and
 flat-linux-module-directory.
Date: Sat,  3 Mar 2018 14:55:33 +0100
Message-Id: <20180303135533.6112-8-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180303135533.6112-1-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (module-aliases->module-file-names): New
procedure.
* gnu/system/linux-initrd.scm (%modprobe): Use
module-aliases->module-file-names.
(flat-linux-module-directory): Use module-aliases->module-file-names.
---
 gnu/build/linux-modules.scm |  56 +++++++++++++++++++++-
 gnu/system/linux-initrd.scm | 110 ++++++++++++++++++--------------------------
 2 files changed, 100 insertions(+), 66 deletions(-)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index af217c974..44059ad93 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -21,6 +21,7 @@
   #:use-module (guix elf)
   #:use-module (guix glob)
   #:use-module (guix build syscalls)
+  #:use-module (guix build utils) ; find-files
   #:use-module (rnrs io ports)
   #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
@@ -28,9 +29,12 @@
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 regex)
+  #:use-module (ice-9 ftw)
   #:export (dot-ko
             ensure-dot-ko
             module-aliases
+            module-aliases->module-file-names
             module-dependencies
             recursive-module-dependencies
             modules-loaded
@@ -385,7 +389,7 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
 
 (define (install-module-files module-files output)
   "Install MODULE-FILES to OUTPUT.
-Precondition: OUTPUT is an empty directory."
+Precondition: OUTPUT is an empty directory except for \"modules.builtin\"."
   (let ((aliases
          (map (lambda (module-file-name)
                 (format #t "copying '~a'...~%" module-file-name)
@@ -431,4 +435,54 @@ Precondition: OUTPUT is an empty directory."
             (_ #f))
            aliases))))))
 
+(define (module-aliases->module-file-names linux aliases)
+  "Resolve ALIASES to module file names, including their dependencies (which will appear
+first).  Each alias will map to a list of module file names.
+LINUX is the directory containing \"lib\"."
+  (define (string->regexp str)
+    ;; Return a regexp that matches STR exactly.
+    (string-append "^" (regexp-quote str) "$"))
+
+  (define module-dir
+    (string-append linux "/lib/modules"))
+
+  (define (find-only-entry directory)
+    (match (scandir directory)
+     (("." ".." basename)
+      (string-append directory "/" basename))))
+
+  (define linux-release-module-directory
+    (find-only-entry module-dir))
+
+  (define known-module-aliases*
+    (known-module-aliases
+     (string-append linux-release-module-directory
+                    "/modules.alias")))
+  (define (resolve-alias alias)
+    "If possible, resolve ALIAS to a list of module names.
+Otherwise return just ALIAS as possible module names."
+    (match (delete-duplicates (matching-modules alias
+                                                known-module-aliases*))
+           (()
+            (list alias))
+           (items
+            items)))
+
+  (define (lookup module)
+    (let ((name (ensure-dot-ko module)))
+      (match (find-files module-dir (string->regexp name))
+             ((file)
+              file)
+             (()
+              (error "module not found" name module-dir))
+             ((_ ...)
+              (error "several modules by that name"
+                     name module-dir)))))
+  (append-map (lambda (alias)
+                (let ((modules (map lookup (resolve-alias alias))))
+                  (append (recursive-module-dependencies modules
+                                                         #:lookup-module
+                                                         lookup) modules)))
+              aliases))
+
 ;;; linux-modules.scm ends here
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 8050ac47e..dc826c63e 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -58,35 +58,14 @@
 
 (define* (%modprobe linux-module-directory #:key
                     (guile %guile-static-stripped))
+  "Minimal implementation of modprobe for our initrd.
+LINUX-MODULE-DIRECTORY is the directory that contains \"lib\"."
   (program-file "modprobe"
     (with-imported-modules (source-module-closure
                             '((gnu build linux-modules)))
       #~(begin
           (use-modules (gnu build linux-modules) (ice-9 getopt-long)
-                       (ice-9 match) (srfi srfi-1) (ice-9 ftw))
-          (define (find-only-entry directory)
-            (match (scandir directory)
-             (("." ".." basename)
-              (string-append directory "/" basename))))
-          (define (resolve-alias alias)
-            (let* ((linux-release-module-directory
-                    (find-only-entry (string-append "/lib/modules"))))
-              (match (delete-duplicates (matching-modules alias
-                      (known-module-aliases
-                        (string-append linux-release-module-directory
-                                       "/modules.alias"))))
-               (()
-                (error "no alias by that name" alias))
-               (items
-                items))))
-          (define (lookup-module module)
-            (let* ((linux-release-module-directory
-                    (find-only-entry (string-append "/lib/modules")))
-                   (file-name (string-append linux-release-module-directory
-                                             "/" (ensure-dot-ko module))))
-              (if (file-exists? file-name)
-                  file-name
-                  (error "no module file found for module" module))))
+                       (ice-9 match) (srfi srfi-1))
           (define option-spec
            '((quiet    (single-char #\q) (value #f))))
           (define options
@@ -98,22 +77,31 @@
             (for-each (match-lambda
                         (('quiet . #t)
                          #f)
-                        ((() modules ...)
-                         (for-each (lambda (alias)
-                                     (catch #t
-                                       (lambda ()
-                                         (let ((modules (resolve-alias alias)))                                           (for-each (lambda (module)
-                                                       (load-linux-module*
-                                                        (lookup-module module)
-                                                        #:lookup-module
-                                                        lookup-module))
-                                                     modules)))
-                                       (lambda (key . args)
-                                         (display (cons* key args)
-                                                  (current-error-port))
-                                         (newline (current-error-port))
-                                         (set! exit-status 1))))
-                                   modules)))
+                        ((() aliases ...)
+                         (catch #t
+                           (lambda ()
+                             (let ((module-file-names
+                                    (module-aliases->module-file-names
+                                     #$linux-module-directory aliases)))
+                               (for-each (lambda (name)
+                                           (catch 'system-error
+                                             (lambda ()
+                                               (when (not (load-linux-module* name
+                                                                              #:recursive?
+                                                                              #f))
+                                                 (set! exit-status 1)))
+                                             (lambda (key . args)
+                                               (when (not (= EEXIST
+                                                             (system-error-errno
+                                                              (cons key args))))
+                                                 (print-exception (current-error-port)
+                                                                  #f key args)
+                                                 (set! exit-status 1)))))
+                                         module-file-names)))
+                           (lambda (key . args)
+                             (print-exception (current-error-port)
+                                              #f key args)
+                             (set! exit-status 1)))))
                       options)
             (exit exit-status))))
   #:guile guile))
@@ -173,17 +161,17 @@ the derivations referenced by EXP are automatically copied to the initrd."
                     #:references-graphs `(("init-closure" ,init)
                                           ("modprobe-closure" ,modprobe))))
 
-(define (flat-linux-module-directory linux modules)
-  "Return a flat directory containing the Linux kernel modules listed in
-MODULES and taken from LINUX."
+(define (flat-linux-module-directory linux aliases)
+  "Return a flat directory containing the Linux kernel modules resolved by
+ALIASES and taken from LINUX."
   (define build-exp
     (with-imported-modules (source-module-closure
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
+          (use-modules (ice-9 match) (ice-9 ftw)
                        (srfi srfi-1)
-                       (guix build utils)
+                       (guix build utils) ; TODO: Remove
                        (gnu build linux-modules))
 
           (define (string->regexp str)
@@ -193,33 +181,25 @@ MODULES and taken from LINUX."
           (define module-dir
             (string-append #$linux "/lib/modules"))
 
-          (define (lookup module)
-            (let ((name (ensure-dot-ko module)))
-              (match (find-files module-dir (string->regexp name))
-                ((file)
-                 file)
-                (()
-                 (error "module not found" name module-dir))
-                ((_ ...)
-                 (error "several modules by that name"
-                        name module-dir)))))
+          (define (find-only-entry directory)
+            (match (scandir directory)
+             (("." ".." basename)
+              (string-append directory "/" basename))))
+
+          (define linux-release-module-directory
+            (find-only-entry module-dir))
 
           (define modules
-            (let ((modules (map lookup '#$modules)))
-              (append modules
-                      (recursive-module-dependencies modules
-                                                     #:lookup-module lookup))))
+            (module-aliases->module-file-names #$linux '#$aliases))
 
           (define version
-            (match
-             (filter
-              (lambda (name)
-                (not (string-prefix? "." name)))
-              (scandir module-dir))
-             ((item) item)))
+            (basename linux-release-module-directory))
 
           (let ((output (string-append #$output "/lib/modules/" version)))
             (mkdir-p output)
+            (install-file
+             (string-append linux-release-module-directory "/modules.builtin")
+             output)
             (install-module-files (delete-duplicates modules) output))
           #t)))
   (computed-file "linux-modules" build-exp))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 13:55:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 08:55:54 2018
Received: from localhost ([127.0.0.1]:41977 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es7di-0006MO-5h
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:54 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43806)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es7df-0006Lm-K8
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:52 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 79D25336188F;
 Sat,  3 Mar 2018 14:55:50 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v8 6/7] linux-initrd: Provide modprobe to the initrd.
Date: Sat,  3 Mar 2018 14:55:32 +0100
Message-Id: <20180303135533.6112-7-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180303135533.6112-1-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-initrd.scm (build-initrd): Provide modprobe and the
linux modules to the initrd.
* gnu/system/linux-initrd.scm (%modprobe): New procedure.
(expression->initrd): Use it.  Add linux-module-directory.
(raw-initrd): Pass linux-module-directory.
---
 gnu/build/linux-initrd.scm  | 13 +++++-
 gnu/system/linux-initrd.scm | 99 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 99 insertions(+), 13 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..d4cb5e2d8 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init modprobe linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,17 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+     ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (when modprobe
+      (mkdir-p "sbin")
+      (symlink modprobe "sbin/modprobe")
+      (compile-to-cache "sbin/modprobe"))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index b50d3ff80..8050ac47e 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -56,11 +56,73 @@
 ;;;
 ;;; Code:
 
+(define* (%modprobe linux-module-directory #:key
+                    (guile %guile-static-stripped))
+  (program-file "modprobe"
+    (with-imported-modules (source-module-closure
+                            '((gnu build linux-modules)))
+      #~(begin
+          (use-modules (gnu build linux-modules) (ice-9 getopt-long)
+                       (ice-9 match) (srfi srfi-1) (ice-9 ftw))
+          (define (find-only-entry directory)
+            (match (scandir directory)
+             (("." ".." basename)
+              (string-append directory "/" basename))))
+          (define (resolve-alias alias)
+            (let* ((linux-release-module-directory
+                    (find-only-entry (string-append "/lib/modules"))))
+              (match (delete-duplicates (matching-modules alias
+                      (known-module-aliases
+                        (string-append linux-release-module-directory
+                                       "/modules.alias"))))
+               (()
+                (error "no alias by that name" alias))
+               (items
+                items))))
+          (define (lookup-module module)
+            (let* ((linux-release-module-directory
+                    (find-only-entry (string-append "/lib/modules")))
+                   (file-name (string-append linux-release-module-directory
+                                             "/" (ensure-dot-ko module))))
+              (if (file-exists? file-name)
+                  file-name
+                  (error "no module file found for module" module))))
+          (define option-spec
+           '((quiet    (single-char #\q) (value #f))))
+          (define options
+            (getopt-long (command-line) option-spec))
+          (when (option-ref options 'quiet #f)
+            (current-error-port (%make-void-port "w"))
+            (current-output-port (%make-void-port "w")))
+          (let ((exit-status 0))
+            (for-each (match-lambda
+                        (('quiet . #t)
+                         #f)
+                        ((() modules ...)
+                         (for-each (lambda (alias)
+                                     (catch #t
+                                       (lambda ()
+                                         (let ((modules (resolve-alias alias)))                                           (for-each (lambda (module)
+                                                       (load-linux-module*
+                                                        (lookup-module module)
+                                                        #:lookup-module
+                                                        lookup-module))
+                                                     modules)))
+                                       (lambda (key . args)
+                                         (display (cons* key args)
+                                                  (current-error-port))
+                                         (newline (current-error-port))
+                                         (set! exit-status 1))))
+                                   modules)))
+                      options)
+            (exit exit-status))))
+  #:guile guile))
 
 (define* (expression->initrd exp
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -73,6 +135,9 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (define init
     (program-file "init" exp #:guile guile))
 
+  (define modprobe
+    (%modprobe linux-module-directory #:guile guile))
+
   (define builder
     (with-imported-modules (source-module-closure
                             '((gnu build linux-initrd)))
@@ -96,12 +161,17 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
-                        ;; Copy everything INIT refers to into the initrd.
-                        #:references-graphs '("closure")
+                        #:modprobe #$modprobe
+                        #:linux-module-directory #$linux-module-directory
+                        ;; Copy everything INIT and MODPROBE refer to into the
+                        ;; initrd.
+                        #:references-graphs '("init-closure"
+                                              "modprobe-closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
 
   (gexp->derivation name builder
-                    #:references-graphs `(("closure" ,init))))
+                    #:references-graphs `(("init-closure" ,init)
+                                          ("modprobe-closure" ,modprobe))))
 
 (define (flat-linux-module-directory linux modules)
   "Return a flat directory containing the Linux kernel modules listed in
@@ -111,7 +181,7 @@ MODULES and taken from LINUX."
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex)
+          (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
                        (srfi srfi-1)
                        (guix build utils)
                        (gnu build linux-modules))
@@ -140,14 +210,18 @@ MODULES and taken from LINUX."
                       (recursive-module-dependencies modules
                                                      #:lookup-module lookup))))
 
-          (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
-
+          (define version
+            (match
+             (filter
+              (lambda (name)
+                (not (string-prefix? "." name)))
+              (scandir module-dir))
+             ((item) item)))
+
+          (let ((output (string-append #$output "/lib/modules/" version)))
+            (mkdir-p output)
+            (install-module-files (delete-duplicates modules) output))
+          #t)))
   (computed-file "linux-modules" build-exp))
 
 (define* (raw-initrd file-systems
@@ -227,6 +301,7 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 13:55:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 08:55:54 2018
Received: from localhost ([127.0.0.1]:41975 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es7dh-0006MM-VM
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:54 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43798)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es7de-0006Lf-K4
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:50 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 8B90D3362284;
 Sat,  3 Mar 2018 14:55:49 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v8 5/7] vm: Make the virtio-blk uniquely identifiable in /sys.
Date: Sat,  3 Mar 2018 14:55:31 +0100
Message-Id: <20180303135533.6112-6-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180303135533.6112-1-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.
---
 gnu/build/vm.scm  | 2 +-
 gnu/system/vm.scm | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..ebf9e9f6e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,7 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b5a559012..fdff64ed9 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -706,7 +706,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 13:55:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 08:55:53 2018
Received: from localhost ([127.0.0.1]:41972 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es7dg-0006Ly-DD
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:52 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43788)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es7dd-0006LY-L6
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:50 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 9EF85336287E;
 Sat,  3 Mar 2018 14:55:48 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v8 4/7] vm: Allow qemu-image builder to load Linux kernel
 modules.
Date: Sat,  3 Mar 2018 14:55:30 +0100
Message-Id: <20180303135533.6112-5-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180303135533.6112-1-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/vm.scm (%modprobe-wrapper): New variable.
(qemu-image): Modify.
---
 gnu/system/vm.scm | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 345cecedd..b5a559012 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -246,6 +246,17 @@ INPUTS is a list of inputs (as for packages)."
    #:single-file-output? #t
    #:references-graphs inputs))
 
+(define (%modprobe-wrapper modprobe linux-module-directory)
+  ;; Wrapper for the 'modprobe' command that knows where modules live.
+  ;;
+  ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+  ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+  ;; environment variable is not set---hence the need for this wrapper.
+  (program-file "modprobe"
+    #~(begin
+        (setenv "LINUX_MODULE_DIRECTORY" #$linux-module-directory)
+        (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))
+
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
@@ -275,20 +286,24 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (let ((modprobe-name (file-append os-drv "/profile/bin/modprobe"))
+        (linux-module-directory (file-append (file-append os-drv "/kernel/lib/modules"))))
   (expression->derivation-in-linux-vm
    name
-   (with-imported-modules (source-module-closure '((gnu build bootloader)
+   (with-imported-modules (source-module-closure '((gnu build activation)
+                                                   (gnu build bootloader)
                                                    (gnu build vm)
                                                    (guix build utils)))
      #~(begin
-         (use-modules (gnu build bootloader)
+         (use-modules (gnu build activation)
+                      (gnu build bootloader)
                       (gnu build vm)
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs dosfstools)
+                '#$(append (list qemu parted e2fsprogs dosfstools kmod)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -302,6 +317,14 @@ the image."
                         inputs)))
 
            (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
+           ;; It's possible that we need to load nls modules in order to
+           ;; mount the new partition.
+           (if (file-exists? #$modprobe-name)
+               (activate-modprobe #$(%modprobe-wrapper modprobe-name
+                                     linux-module-directory))
+               (format (current-error-port)
+                "WARNING: No modprobe found in ~s.  \
+Loading kernel modules will be impossible.\n" #$modprobe-name))
 
            (let* ((graphs     '#$(match inputs
                                    (((names . _) ...)
@@ -364,7 +387,7 @@ the image."
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-   #:references-graphs inputs))
+   #:references-graphs inputs)))
 
 
 ;;;




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 13:55:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 08:55:52 2018
Received: from localhost ([127.0.0.1]:41970 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es7df-0006Lq-Vk
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:52 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43780)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es7dc-0006LI-Nr
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:49 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id B1D9F3362284;
 Sat,  3 Mar 2018 14:55:47 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v8 3/7] linux-boot: Load kernel modules only when the hardware
 is present.
Date: Sat,  3 Mar 2018 14:55:29 +0100
Message-Id: <20180303135533.6112-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180303135533.6112-1-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
(lookup-module): Delete procedure.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 42 +++++++++++++++++++++++++++++++++++-------
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..1b16f267a 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -469,9 +469,31 @@ upon error."
              mounts)
         "ext4"))
 
-  (define (lookup-module name)
-    (string-append linux-module-directory "/"
-                   (ensure-dot-ko name)))
+  (define (load-kernel-modules)
+    "Examine /sys/devices to find out which modules to load and load them."
+    (define enter?
+      (const #t))
+    (define (down! directory stat result)
+     ;; Note: modprobe mutates the tree starting with DIRECTORY.
+     (let ((modalias-name (string-append directory "/modalias")))
+       (if (file-exists? modalias-name)
+           (let ((modalias
+                 (string-trim-right (call-with-input-file modalias-name
+                                                          read-string)
+                                    #\newline)))
+             (system* "/sbin/modprobe" "-q" "--" modalias))))
+       #t)
+    (define up
+      (const #t))
+    (define skip
+      (const #t))
+    (define leaf
+      (const #t))
+    (define (error name stat errno result)
+      (format (current-error-port) "warning: ~a: ~a~%"
+              name (strerror errno))
+      result)
+    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
 
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
@@ -486,10 +508,16 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (let* ((kernel-release
+               (utsname:release (uname)))
+              (directory
+               (string-append linux-module-directory "/lib/modules/"
+                              kernel-release))
+              (old-umask (umask #o022)))
+         (make-static-device-nodes directory)
+         (umask old-umask))
+
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index e7f97bb88..b50d3ff80 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -208,7 +208,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 13:55:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 08:55:52 2018
Received: from localhost ([127.0.0.1]:41967 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es7df-0006Ln-LI
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:51 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43772)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es7db-0006L5-Mz
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:48 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id A8307336188F;
 Sat,  3 Mar 2018 14:55:46 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v8 2/7] linux-modules: Add install-modules.
Date: Sat,  3 Mar 2018 14:55:28 +0100
Message-Id: <20180303135533.6112-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180303135533.6112-1-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (install-modules): New procedure.
(%not-dash): New variable.
---
 gnu/build/linux-modules.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 364339df9..af217c974 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -36,6 +36,7 @@
             modules-loaded
             module-loaded?
             load-linux-module*
+            install-module-files
 
             current-module-debugging-port
 
@@ -379,4 +380,55 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                       module)))
               known-aliases))
 
+(define %not-dash
+  (char-set-complement (char-set #\-)))
+
+(define (install-module-files module-files output)
+  "Install MODULE-FILES to OUTPUT.
+Precondition: OUTPUT is an empty directory."
+  (let ((aliases
+         (map (lambda (module-file-name)
+                (format #t "copying '~a'...~%" module-file-name)
+                (copy-file module-file-name
+                           (string-append output "/"
+                                          (basename module-file-name)))
+                `(,(file-name->module-name module-file-name) .
+                  ,(module-aliases module-file-name)))
+              (sort module-files string<))))
+    (call-with-output-file (string-append output "/modules.alias")
+      (lambda (port)
+        (format port
+                "# Aliases extracted from modules themselves.\n")
+        (for-each (match-lambda ((module . aliases)
+                                 (for-each (lambda (alias)
+                                             (format port "alias ~a ~a\n" alias
+                                                     module))
+                                           aliases)))
+                  aliases)))
+    (call-with-output-file (string-append output "/modules.devname")
+      (lambda (port)
+        (format port
+                "# Device nodes to trigger on-demand module loading.\n")
+        (let* ((aliases (append-map (match-lambda
+                                     ((module . aliases) aliases))
+                                    aliases))
+               (devname #f))
+          ;; Note: there's only one devname and then only one (char-major|block-major).
+          (for-each
+           (match-lambda
+            (((? (cut string-prefix? "devname:" <>) alias) . value)
+             (set! devname (string-drop value (string-length "devname:"))))
+            (((? (cut string-prefix? "char-major-" <>) alias) . value)
+             (let ((parts (string-tokenize %not-dash)))
+               (match parts
+                      ((a b major minor)
+                       (format port "~a ~a ~a:~a\n" devname "c" major minor)))))
+            (((? (cut string-prefix? "block-major-" <>) alias) . value)
+             (let ((parts (string-tokenize %not-dash)))
+               (match parts
+                      ((a b major minor)
+                       (format port "~a ~a ~a:~a\n" devname "b" major minor)))))
+            (_ #f))
+           aliases))))))
+
 ;;; linux-modules.scm ends here




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 13:55:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 08:55:48 2018
Received: from localhost ([127.0.0.1]:41962 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es7dc-0006LD-Bj
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:48 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43764)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es7da-0006Kt-Kb
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:46 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 819593362284;
 Sat,  3 Mar 2018 14:55:45 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v8 1/7] linux-modules: Add module-aliases.
Date: Sat,  3 Mar 2018 14:55:27 +0100
Message-Id: <20180303135533.6112-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180303135533.6112-1-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
 <20180303135533.6112-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (module-aliases): New variable.
---
 gnu/build/linux-modules.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 4a6d4ff08..364339df9 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -30,6 +30,7 @@
   #:use-module (ice-9 rdelim)
   #:export (dot-ko
             ensure-dot-ko
+            module-aliases
             module-dependencies
             recursive-module-dependencies
             modules-loaded
@@ -95,6 +96,14 @@ contains module names, not actual file names."
       (('depends . what)
        (string-tokenize what %not-comma)))))
 
+(define (module-aliases file)
+  "Return the list of aliases of module FILE."
+  (let ((info (modinfo-section-contents file)))
+    (filter-map (match-lambda
+                 (('alias . value)
+                  value)
+                 (_ #f)) (modinfo-section-contents file))))
+
 (define dot-ko
   (cut string-append <> ".ko"))
 




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 3 Mar 2018 13:55:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 03 08:55:48 2018
Received: from localhost ([127.0.0.1]:41960 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1es7dc-0006L6-12
	for submit <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:48 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43760)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1es7da-0006Kq-18
 for 30604 <at> debbugs.gnu.org; Sat, 03 Mar 2018 08:55:46 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id C58B4336188F;
 Sat,  3 Mar 2018 14:55:43 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v8 0/7] Load Linux module only when supported hardware is
 present.
Date: Sat,  3 Mar 2018 14:55:26 +0100
Message-Id: <20180303135533.6112-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302153408.14091-1-dannym@HIDDEN>
References: <20180302153408.14091-1-dannym@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Danny Milosavljevic (7):
  linux-modules: Add module-aliases.
  linux-modules: Add install-modules.
  linux-boot: Load kernel modules only when the hardware is present.
  vm: Allow qemu-image builder to load Linux kernel modules.
  vm: Make the virtio-blk uniquely identifiable in /sys.
  linux-initrd: Provide modprobe to the initrd.
  linux-initrd: Factorize %modprobe and flat-linux-module-directory.

 gnu/build/linux-boot.scm    |  42 ++++++++++++---
 gnu/build/linux-initrd.scm  |  13 ++++-
 gnu/build/linux-modules.scm | 115 +++++++++++++++++++++++++++++++++++++++++
 gnu/build/vm.scm            |   2 +-
 gnu/system/linux-initrd.scm | 121 ++++++++++++++++++++++++++++++++------------
 gnu/system/vm.scm           |  34 +++++++++++--
 6 files changed, 281 insertions(+), 46 deletions(-)





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 16:47:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 11:47:58 2018
Received: from localhost ([127.0.0.1]:41476 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ernqg-0005LY-Bp
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 11:47:58 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38338)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ernqe-0005LQ-G2
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 11:47:56 -0500
Received: from localhost (77.118.252.91.wireless.dyn.drei.com [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 893513360099
 for <30604 <at> debbugs.gnu.org>; Fri,  2 Mar 2018 17:47:55 +0100 (CET)
Date: Fri, 2 Mar 2018 17:47:51 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: Re: [PATCH v7 1/6] linux-modules: Add module-aliases.
Message-ID: <20180302174751.741d5dd3@HIDDEN>
In-Reply-To: <20180302153408.14091-2-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302153408.14091-1-dannym@HIDDEN>
 <20180302153408.14091-2-dannym@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

> +  "Return the list of aliases for FILE."
                                 ^^^ replace by "in"




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 16:47:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 11:47:21 2018
Received: from localhost ([127.0.0.1]:41473 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ernq5-0005Kk-38
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 11:47:21 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:38282)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ernq3-0005Kc-CO
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 11:47:20 -0500
Received: from localhost (77.118.252.91.wireless.dyn.drei.com [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id D5B2533602EB
 for <30604 <at> debbugs.gnu.org>; Fri,  2 Mar 2018 17:47:17 +0100 (CET)
Date: Fri, 2 Mar 2018 17:47:11 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: Re: [PATCH v7 3/6] linux-boot: Load kernel modules only when the
 hardware is present.
Message-ID: <20180302174711.4018dc49@HIDDEN>
In-Reply-To: <20180302153408.14091-4-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302153408.14091-1-dannym@HIDDEN>
 <20180302153408.14091-4-dannym@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

> +  (define (load-kernel-modules)
> +    "Examine /sys/devices to find out which modules to load and load them."
> +    (define enter?
> +      (const #t))
> +    (define (down! path stat result)
> +     ;; Note: modprobe mutates the tree starting with path.
> +     (let ((modalias-name (string-append path "/modalias")))

I should rename "path" to "directory".





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 15:34:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 10:34:26 2018
Received: from localhost ([127.0.0.1]:41422 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ermhW-0003cp-H4
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:26 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:32932)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ermhT-0003cL-UY
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:24 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id C8A0233601D1;
 Fri,  2 Mar 2018 16:34:22 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v7 6/6] linux-initrd: Provide modprobe to the initrd.
Date: Fri,  2 Mar 2018 16:34:08 +0100
Message-Id: <20180302153408.14091-7-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302153408.14091-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302153408.14091-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-initrd.scm (build-initrd): Provide modprobe and the
linux modules to the initrd.
* gnu/system/linux-initrd.scm (%modprobe): New procedure.
(expression->initrd): Use it.  Add linux-module-directory.
(raw-initrd): Pass linux-module-directory.
---
 gnu/build/linux-initrd.scm  | 13 +++++-
 gnu/system/linux-initrd.scm | 99 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 99 insertions(+), 13 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..d4cb5e2d8 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init modprobe linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,17 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+     ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (when modprobe
+      (mkdir-p "sbin")
+      (symlink modprobe "sbin/modprobe")
+      (compile-to-cache "sbin/modprobe"))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index b50d3ff80..8050ac47e 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -56,11 +56,73 @@
 ;;;
 ;;; Code:
 
+(define* (%modprobe linux-module-directory #:key
+                    (guile %guile-static-stripped))
+  (program-file "modprobe"
+    (with-imported-modules (source-module-closure
+                            '((gnu build linux-modules)))
+      #~(begin
+          (use-modules (gnu build linux-modules) (ice-9 getopt-long)
+                       (ice-9 match) (srfi srfi-1) (ice-9 ftw))
+          (define (find-only-entry directory)
+            (match (scandir directory)
+             (("." ".." basename)
+              (string-append directory "/" basename))))
+          (define (resolve-alias alias)
+            (let* ((linux-release-module-directory
+                    (find-only-entry (string-append "/lib/modules"))))
+              (match (delete-duplicates (matching-modules alias
+                      (known-module-aliases
+                        (string-append linux-release-module-directory
+                                       "/modules.alias"))))
+               (()
+                (error "no alias by that name" alias))
+               (items
+                items))))
+          (define (lookup-module module)
+            (let* ((linux-release-module-directory
+                    (find-only-entry (string-append "/lib/modules")))
+                   (file-name (string-append linux-release-module-directory
+                                             "/" (ensure-dot-ko module))))
+              (if (file-exists? file-name)
+                  file-name
+                  (error "no module file found for module" module))))
+          (define option-spec
+           '((quiet    (single-char #\q) (value #f))))
+          (define options
+            (getopt-long (command-line) option-spec))
+          (when (option-ref options 'quiet #f)
+            (current-error-port (%make-void-port "w"))
+            (current-output-port (%make-void-port "w")))
+          (let ((exit-status 0))
+            (for-each (match-lambda
+                        (('quiet . #t)
+                         #f)
+                        ((() modules ...)
+                         (for-each (lambda (alias)
+                                     (catch #t
+                                       (lambda ()
+                                         (let ((modules (resolve-alias alias)))                                           (for-each (lambda (module)
+                                                       (load-linux-module*
+                                                        (lookup-module module)
+                                                        #:lookup-module
+                                                        lookup-module))
+                                                     modules)))
+                                       (lambda (key . args)
+                                         (display (cons* key args)
+                                                  (current-error-port))
+                                         (newline (current-error-port))
+                                         (set! exit-status 1))))
+                                   modules)))
+                      options)
+            (exit exit-status))))
+  #:guile guile))
 
 (define* (expression->initrd exp
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -73,6 +135,9 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (define init
     (program-file "init" exp #:guile guile))
 
+  (define modprobe
+    (%modprobe linux-module-directory #:guile guile))
+
   (define builder
     (with-imported-modules (source-module-closure
                             '((gnu build linux-initrd)))
@@ -96,12 +161,17 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
-                        ;; Copy everything INIT refers to into the initrd.
-                        #:references-graphs '("closure")
+                        #:modprobe #$modprobe
+                        #:linux-module-directory #$linux-module-directory
+                        ;; Copy everything INIT and MODPROBE refer to into the
+                        ;; initrd.
+                        #:references-graphs '("init-closure"
+                                              "modprobe-closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
 
   (gexp->derivation name builder
-                    #:references-graphs `(("closure" ,init))))
+                    #:references-graphs `(("init-closure" ,init)
+                                          ("modprobe-closure" ,modprobe))))
 
 (define (flat-linux-module-directory linux modules)
   "Return a flat directory containing the Linux kernel modules listed in
@@ -111,7 +181,7 @@ MODULES and taken from LINUX."
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex)
+          (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
                        (srfi srfi-1)
                        (guix build utils)
                        (gnu build linux-modules))
@@ -140,14 +210,18 @@ MODULES and taken from LINUX."
                       (recursive-module-dependencies modules
                                                      #:lookup-module lookup))))
 
-          (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
-
+          (define version
+            (match
+             (filter
+              (lambda (name)
+                (not (string-prefix? "." name)))
+              (scandir module-dir))
+             ((item) item)))
+
+          (let ((output (string-append #$output "/lib/modules/" version)))
+            (mkdir-p output)
+            (install-module-files (delete-duplicates modules) output))
+          #t)))
   (computed-file "linux-modules" build-exp))
 
 (define* (raw-initrd file-systems
@@ -227,6 +301,7 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 15:34:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 10:34:25 2018
Received: from localhost ([127.0.0.1]:41420 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ermhV-0003ch-AW
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:25 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:32924)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ermhS-0003cE-RQ
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:23 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id D764F33602EB;
 Fri,  2 Mar 2018 16:34:21 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v7 5/6] vm: Make the virtio-blk uniquely identifiable in /sys.
Date: Fri,  2 Mar 2018 16:34:07 +0100
Message-Id: <20180302153408.14091-6-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302153408.14091-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302153408.14091-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.
---
 gnu/build/vm.scm  | 2 +-
 gnu/system/vm.scm | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..ebf9e9f6e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,7 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b5a559012..fdff64ed9 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -706,7 +706,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 15:34:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 10:34:24 2018
Received: from localhost ([127.0.0.1]:41417 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ermhU-0003cO-1Q
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:24 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:32916)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ermhR-0003c1-SW
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:22 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id E139933601D1;
 Fri,  2 Mar 2018 16:34:20 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v7 4/6] vm: Allow qemu-image builder to load Linux kernel
 modules.
Date: Fri,  2 Mar 2018 16:34:06 +0100
Message-Id: <20180302153408.14091-5-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302153408.14091-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302153408.14091-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/vm.scm (%modprobe-wrapper): New variable.
(qemu-image): Modify.
---
 gnu/system/vm.scm | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 345cecedd..b5a559012 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -246,6 +246,17 @@ INPUTS is a list of inputs (as for packages)."
    #:single-file-output? #t
    #:references-graphs inputs))
 
+(define (%modprobe-wrapper modprobe linux-module-directory)
+  ;; Wrapper for the 'modprobe' command that knows where modules live.
+  ;;
+  ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+  ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+  ;; environment variable is not set---hence the need for this wrapper.
+  (program-file "modprobe"
+    #~(begin
+        (setenv "LINUX_MODULE_DIRECTORY" #$linux-module-directory)
+        (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))
+
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
@@ -275,20 +286,24 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (let ((modprobe-name (file-append os-drv "/profile/bin/modprobe"))
+        (linux-module-directory (file-append (file-append os-drv "/kernel/lib/modules"))))
   (expression->derivation-in-linux-vm
    name
-   (with-imported-modules (source-module-closure '((gnu build bootloader)
+   (with-imported-modules (source-module-closure '((gnu build activation)
+                                                   (gnu build bootloader)
                                                    (gnu build vm)
                                                    (guix build utils)))
      #~(begin
-         (use-modules (gnu build bootloader)
+         (use-modules (gnu build activation)
+                      (gnu build bootloader)
                       (gnu build vm)
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs dosfstools)
+                '#$(append (list qemu parted e2fsprogs dosfstools kmod)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -302,6 +317,14 @@ the image."
                         inputs)))
 
            (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
+           ;; It's possible that we need to load nls modules in order to
+           ;; mount the new partition.
+           (if (file-exists? #$modprobe-name)
+               (activate-modprobe #$(%modprobe-wrapper modprobe-name
+                                     linux-module-directory))
+               (format (current-error-port)
+                "WARNING: No modprobe found in ~s.  \
+Loading kernel modules will be impossible.\n" #$modprobe-name))
 
            (let* ((graphs     '#$(match inputs
                                    (((names . _) ...)
@@ -364,7 +387,7 @@ the image."
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-   #:references-graphs inputs))
+   #:references-graphs inputs)))
 
 
 ;;;




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 15:34:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 10:34:24 2018
Received: from localhost ([127.0.0.1]:41415 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ermhT-0003cM-Pq
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:23 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:32906)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ermhQ-0003br-SR
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:21 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id E11E133602EB;
 Fri,  2 Mar 2018 16:34:19 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v7 3/6] linux-boot: Load kernel modules only when the hardware
 is present.
Date: Fri,  2 Mar 2018 16:34:05 +0100
Message-Id: <20180302153408.14091-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302153408.14091-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302153408.14091-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
(lookup-module): Delete procedure.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 42 +++++++++++++++++++++++++++++++++++-------
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..1b16f267a 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -469,9 +469,31 @@ upon error."
              mounts)
         "ext4"))
 
-  (define (lookup-module name)
-    (string-append linux-module-directory "/"
-                   (ensure-dot-ko name)))
+  (define (load-kernel-modules)
+    "Examine /sys/devices to find out which modules to load and load them."
+    (define enter?
+      (const #t))
+    (define (down! path stat result)
+     ;; Note: modprobe mutates the tree starting with path.
+     (let ((modalias-name (string-append path "/modalias")))
+       (if (file-exists? modalias-name)
+           (let ((modalias
+                 (string-trim-right (call-with-input-file modalias-name
+                                                          read-string)
+                                    #\newline)))
+             (system* "/sbin/modprobe" "-q" "--" modalias))))
+       #t)
+    (define up
+      (const #t))
+    (define skip
+      (const #t))
+    (define leaf
+      (const #t))
+    (define (error name stat errno result)
+      (format (current-error-port) "warning: ~a: ~a~%"
+              name (strerror errno))
+      result)
+    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
 
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
@@ -486,10 +508,16 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (let* ((kernel-release
+               (utsname:release (uname)))
+              (directory
+               (string-append linux-module-directory "/lib/modules/"
+                              kernel-release))
+              (old-umask (umask #o022)))
+         (make-static-device-nodes directory)
+         (umask old-umask))
+
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index e7f97bb88..b50d3ff80 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -208,7 +208,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 15:34:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 10:34:21 2018
Received: from localhost ([127.0.0.1]:41411 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ermhR-0003c0-GJ
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:21 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:32898)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ermhP-0003bd-Qp
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:20 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 5AE1333601D1;
 Fri,  2 Mar 2018 16:34:18 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v7 2/6] linux-modules: Add install-modules.
Date: Fri,  2 Mar 2018 16:34:04 +0100
Message-Id: <20180302153408.14091-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302153408.14091-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302153408.14091-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (install-modules): New procedure.
(%not-dash): New variable.
---
 gnu/build/linux-modules.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 364339df9..af217c974 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -36,6 +36,7 @@
             modules-loaded
             module-loaded?
             load-linux-module*
+            install-module-files
 
             current-module-debugging-port
 
@@ -379,4 +380,55 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                       module)))
               known-aliases))
 
+(define %not-dash
+  (char-set-complement (char-set #\-)))
+
+(define (install-module-files module-files output)
+  "Install MODULE-FILES to OUTPUT.
+Precondition: OUTPUT is an empty directory."
+  (let ((aliases
+         (map (lambda (module-file-name)
+                (format #t "copying '~a'...~%" module-file-name)
+                (copy-file module-file-name
+                           (string-append output "/"
+                                          (basename module-file-name)))
+                `(,(file-name->module-name module-file-name) .
+                  ,(module-aliases module-file-name)))
+              (sort module-files string<))))
+    (call-with-output-file (string-append output "/modules.alias")
+      (lambda (port)
+        (format port
+                "# Aliases extracted from modules themselves.\n")
+        (for-each (match-lambda ((module . aliases)
+                                 (for-each (lambda (alias)
+                                             (format port "alias ~a ~a\n" alias
+                                                     module))
+                                           aliases)))
+                  aliases)))
+    (call-with-output-file (string-append output "/modules.devname")
+      (lambda (port)
+        (format port
+                "# Device nodes to trigger on-demand module loading.\n")
+        (let* ((aliases (append-map (match-lambda
+                                     ((module . aliases) aliases))
+                                    aliases))
+               (devname #f))
+          ;; Note: there's only one devname and then only one (char-major|block-major).
+          (for-each
+           (match-lambda
+            (((? (cut string-prefix? "devname:" <>) alias) . value)
+             (set! devname (string-drop value (string-length "devname:"))))
+            (((? (cut string-prefix? "char-major-" <>) alias) . value)
+             (let ((parts (string-tokenize %not-dash)))
+               (match parts
+                      ((a b major minor)
+                       (format port "~a ~a ~a:~a\n" devname "c" major minor)))))
+            (((? (cut string-prefix? "block-major-" <>) alias) . value)
+             (let ((parts (string-tokenize %not-dash)))
+               (match parts
+                      ((a b major minor)
+                       (format port "~a ~a ~a:~a\n" devname "b" major minor)))))
+            (_ #f))
+           aliases))))))
+
 ;;; linux-modules.scm ends here




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 15:34:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 10:34:20 2018
Received: from localhost ([127.0.0.1]:41408 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ermhQ-0003bk-9y
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:20 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:32890)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ermhO-0003bJ-72
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:18 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 362D733602EB;
 Fri,  2 Mar 2018 16:34:17 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v7 1/6] linux-modules: Add module-aliases.
Date: Fri,  2 Mar 2018 16:34:03 +0100
Message-Id: <20180302153408.14091-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302153408.14091-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302153408.14091-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (module-aliases): New variable.
---
 gnu/build/linux-modules.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 4a6d4ff08..364339df9 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -30,6 +30,7 @@
   #:use-module (ice-9 rdelim)
   #:export (dot-ko
             ensure-dot-ko
+            module-aliases
             module-dependencies
             recursive-module-dependencies
             modules-loaded
@@ -95,6 +96,14 @@ contains module names, not actual file names."
       (('depends . what)
        (string-tokenize what %not-comma)))))
 
+(define (module-aliases file)
+  "Return the list of aliases for FILE."
+  (let ((info (modinfo-section-contents file)))
+    (filter-map (match-lambda
+                 (('alias . value)
+                  value)
+                 (_ #f)) (modinfo-section-contents file))))
+
 (define dot-ko
   (cut string-append <> ".ko"))
 




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 15:34:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 10:34:19 2018
Received: from localhost ([127.0.0.1]:41405 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ermhP-0003bW-2u
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:19 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:32886)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1ermhN-0003bI-Hf
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 10:34:18 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 9E65733601D1;
 Fri,  2 Mar 2018 16:34:15 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v7 0/6] Load Linux module only when supported hardware is
 present.
Date: Fri,  2 Mar 2018 16:34:02 +0100
Message-Id: <20180302153408.14091-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302141606.10669-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Danny Milosavljevic (6):
  linux-modules: Add module-aliases.
  linux-modules: Add install-modules.
  linux-boot: Load kernel modules only when the hardware is present.
  vm: Allow qemu-image builder to load Linux kernel modules.
  vm: Make the virtio-blk uniquely identifiable in /sys.
  linux-initrd: Provide modprobe to the initrd.

 gnu/build/linux-boot.scm    |  42 +++++++++++++++---
 gnu/build/linux-initrd.scm  |  13 +++++-
 gnu/build/linux-modules.scm |  61 ++++++++++++++++++++++++++
 gnu/build/vm.scm            |   2 +-
 gnu/system/linux-initrd.scm | 103 ++++++++++++++++++++++++++++++++++++++------
 gnu/system/vm.scm           |  34 ++++++++++++---
 6 files changed, 228 insertions(+), 27 deletions(-)





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 14:17:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 09:17:40 2018
Received: from localhost ([127.0.0.1]:40338 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1erlVC-0001Yr-C2
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:40 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:55104)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1erlVA-0001Yc-Jc
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:37 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 6E7BB33601D1;
 Fri,  2 Mar 2018 15:17:35 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v6 6/6] linux-initrd: Provide modprobe to the initrd.
Date: Fri,  2 Mar 2018 15:17:20 +0100
Message-Id: <20180302141720.10720-6-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302141720.10720-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302141720.10720-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-initrd.scm (build-initrd): Provide modprobe and the
linux modules to the initrd.
* gnu/system/linux-initrd.scm (%modprobe): New procedure.
(expression->initrd): Use it.  Add linux-module-directory.
(raw-initrd): Pass linux-module-directory.
---
 gnu/build/linux-initrd.scm  | 13 ++++++-
 gnu/system/linux-initrd.scm | 84 ++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 87 insertions(+), 10 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..d4cb5e2d8 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init modprobe linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,17 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+     ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (when modprobe
+      (mkdir-p "sbin")
+      (symlink modprobe "sbin/modprobe")
+      (compile-to-cache "sbin/modprobe"))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index b50d3ff80..a69497ff8 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -56,11 +56,73 @@
 ;;;
 ;;; Code:
 
+(define* (%modprobe linux-module-directory #:key
+                    (guile %guile-static-stripped))
+  (program-file "modprobe"
+    (with-imported-modules (source-module-closure
+                            '((gnu build linux-modules)))
+      #~(begin
+          (use-modules (gnu build linux-modules) (ice-9 getopt-long)
+                       (ice-9 match) (srfi srfi-1) (ice-9 ftw))
+          (define (find-only-entry directory)
+            (match (scandir directory)
+             (("." ".." basename)
+              (string-append directory "/" basename))))
+          (define (resolve-alias alias)
+            (let* ((linux-release-module-directory
+                    (find-only-entry (string-append "/lib/modules"))))
+              (match (delete-duplicates (matching-modules alias
+                      (known-module-aliases
+                        (string-append linux-release-module-directory
+                                       "/modules.alias"))))
+               (()
+                (error "no alias by that name" alias))
+               (items
+                items))))
+          (define (lookup-module module)
+            (let* ((linux-release-module-directory
+                    (find-only-entry (string-append "/lib/modules")))
+                   (file-name (string-append linux-release-module-directory
+                                             "/" (ensure-dot-ko module))))
+              (if (file-exists? file-name)
+                  file-name
+                  (error "no module file found for module" module))))
+          (define option-spec
+           '((quiet    (single-char #\q) (value #f))))
+          (define options
+            (getopt-long (command-line) option-spec))
+          (when (option-ref options 'quiet #f)
+            (current-error-port (%make-void-port "w"))
+            (current-output-port (%make-void-port "w")))
+          (let ((exit-status 0))
+            (for-each (match-lambda
+                        (('quiet . #t)
+                         #f)
+                        ((() modules ...)
+                         (for-each (lambda (alias)
+                                     (catch #t
+                                       (lambda ()
+                                         (let ((modules (resolve-alias alias)))                                           (for-each (lambda (module)
+                                                       (load-linux-module*
+                                                        (lookup-module module)
+                                                        #:lookup-module
+                                                        lookup-module))
+                                                     modules)))
+                                       (lambda (key . args)
+                                         (display (cons* key args)
+                                                  (current-error-port))
+                                         (newline (current-error-port))
+                                         (set! exit-status 1))))
+                                   modules)))
+                      options)
+            (exit exit-status))))
+  #:guile guile))
 
 (define* (expression->initrd exp
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -73,6 +135,9 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (define init
     (program-file "init" exp #:guile guile))
 
+  (define modprobe
+    (%modprobe linux-module-directory #:guile guile))
+
   (define builder
     (with-imported-modules (source-module-closure
                             '((gnu build linux-initrd)))
@@ -96,12 +161,17 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
-                        ;; Copy everything INIT refers to into the initrd.
-                        #:references-graphs '("closure")
+                        #:modprobe #$modprobe
+                        #:linux-module-directory #$linux-module-directory
+                        ;; Copy everything INIT and MODPROBE refer to into the
+                        ;; initrd.
+                        #:references-graphs '("init-closure"
+                                              "modprobe-closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
 
   (gexp->derivation name builder
-                    #:references-graphs `(("closure" ,init))))
+                    #:references-graphs `(("init-closure" ,init)
+                                          ("modprobe-closure" ,modprobe))))
 
 (define (flat-linux-module-directory linux modules)
   "Return a flat directory containing the Linux kernel modules listed in
@@ -141,12 +211,7 @@ MODULES and taken from LINUX."
                                                      #:lookup-module lookup))))
 
           (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
+          (install-module-files (delete-duplicates modules) #$output))))
 
   (computed-file "linux-modules" build-exp))
 
@@ -227,6 +292,7 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 14:17:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 09:17:37 2018
Received: from localhost ([127.0.0.1]:40335 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1erlVA-0001Yd-OI
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:36 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:55096)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1erlV9-0001YN-4g
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:35 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 7CE5533602EB;
 Fri,  2 Mar 2018 15:17:33 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v6 5/6] vm: Make the virtio-blk uniquely identifiable in /sys.
Date: Fri,  2 Mar 2018 15:17:19 +0100
Message-Id: <20180302141720.10720-5-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302141720.10720-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302141720.10720-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.
---
 gnu/build/vm.scm  | 2 +-
 gnu/system/vm.scm | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..ebf9e9f6e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,7 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b5a559012..fdff64ed9 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -706,7 +706,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 14:17:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 09:17:35 2018
Received: from localhost ([127.0.0.1]:40333 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1erlV9-0001YP-C8
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:35 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:55092)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1erlV7-0001Y9-7T
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:33 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id CFE7F33601D1;
 Fri,  2 Mar 2018 15:17:31 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v6 4/6] vm: Allow qemu-image builder to load Linux kernel
 modules.
Date: Fri,  2 Mar 2018 15:17:18 +0100
Message-Id: <20180302141720.10720-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302141720.10720-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302141720.10720-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/vm.scm (%modprobe-wrapper): New variable.
(qemu-image): Modify.
---
 gnu/system/vm.scm | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 345cecedd..b5a559012 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -246,6 +246,17 @@ INPUTS is a list of inputs (as for packages)."
    #:single-file-output? #t
    #:references-graphs inputs))
 
+(define (%modprobe-wrapper modprobe linux-module-directory)
+  ;; Wrapper for the 'modprobe' command that knows where modules live.
+  ;;
+  ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+  ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+  ;; environment variable is not set---hence the need for this wrapper.
+  (program-file "modprobe"
+    #~(begin
+        (setenv "LINUX_MODULE_DIRECTORY" #$linux-module-directory)
+        (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))
+
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
@@ -275,20 +286,24 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (let ((modprobe-name (file-append os-drv "/profile/bin/modprobe"))
+        (linux-module-directory (file-append (file-append os-drv "/kernel/lib/modules"))))
   (expression->derivation-in-linux-vm
    name
-   (with-imported-modules (source-module-closure '((gnu build bootloader)
+   (with-imported-modules (source-module-closure '((gnu build activation)
+                                                   (gnu build bootloader)
                                                    (gnu build vm)
                                                    (guix build utils)))
      #~(begin
-         (use-modules (gnu build bootloader)
+         (use-modules (gnu build activation)
+                      (gnu build bootloader)
                       (gnu build vm)
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs dosfstools)
+                '#$(append (list qemu parted e2fsprogs dosfstools kmod)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -302,6 +317,14 @@ the image."
                         inputs)))
 
            (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
+           ;; It's possible that we need to load nls modules in order to
+           ;; mount the new partition.
+           (if (file-exists? #$modprobe-name)
+               (activate-modprobe #$(%modprobe-wrapper modprobe-name
+                                     linux-module-directory))
+               (format (current-error-port)
+                "WARNING: No modprobe found in ~s.  \
+Loading kernel modules will be impossible.\n" #$modprobe-name))
 
            (let* ((graphs     '#$(match inputs
                                    (((names . _) ...)
@@ -364,7 +387,7 @@ the image."
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-   #:references-graphs inputs))
+   #:references-graphs inputs)))
 
 
 ;;;




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 14:17:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 09:17:33 2018
Received: from localhost ([127.0.0.1]:40329 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1erlV7-0001YA-3k
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:33 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:55084)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1erlV5-0001Xv-E6
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:31 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id E351233602EB;
 Fri,  2 Mar 2018 15:17:29 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v6 3/6] linux-boot: Load kernel modules only when the hardware
 is present.
Date: Fri,  2 Mar 2018 15:17:17 +0100
Message-Id: <20180302141720.10720-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302141720.10720-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302141720.10720-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
(lookup-module): Delete procedure.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 42 +++++++++++++++++++++++++++++++++++-------
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..1b16f267a 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -469,9 +469,31 @@ upon error."
              mounts)
         "ext4"))
 
-  (define (lookup-module name)
-    (string-append linux-module-directory "/"
-                   (ensure-dot-ko name)))
+  (define (load-kernel-modules)
+    "Examine /sys/devices to find out which modules to load and load them."
+    (define enter?
+      (const #t))
+    (define (down! path stat result)
+     ;; Note: modprobe mutates the tree starting with path.
+     (let ((modalias-name (string-append path "/modalias")))
+       (if (file-exists? modalias-name)
+           (let ((modalias
+                 (string-trim-right (call-with-input-file modalias-name
+                                                          read-string)
+                                    #\newline)))
+             (system* "/sbin/modprobe" "-q" "--" modalias))))
+       #t)
+    (define up
+      (const #t))
+    (define skip
+      (const #t))
+    (define leaf
+      (const #t))
+    (define (error name stat errno result)
+      (format (current-error-port) "warning: ~a: ~a~%"
+              name (strerror errno))
+      result)
+    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
 
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
@@ -486,10 +508,16 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (let* ((kernel-release
+               (utsname:release (uname)))
+              (directory
+               (string-append linux-module-directory "/lib/modules/"
+                              kernel-release))
+              (old-umask (umask #o022)))
+         (make-static-device-nodes directory)
+         (umask old-umask))
+
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index e7f97bb88..b50d3ff80 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -208,7 +208,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 14:17:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 09:17:31 2018
Received: from localhost ([127.0.0.1]:40326 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1erlV4-0001Xu-Rg
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:31 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:55068)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1erlV3-0001Xe-Jl
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:29 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 2743F33601D1;
 Fri,  2 Mar 2018 15:17:27 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v6 2/6] linux-modules: Add install-modules.
Date: Fri,  2 Mar 2018 15:17:16 +0100
Message-Id: <20180302141720.10720-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302141720.10720-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
 <20180302141720.10720-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (install-modules): New procedure.
(%not-dash): New variable.
---
 gnu/build/linux-modules.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 364339df9..af217c974 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -36,6 +36,7 @@
             modules-loaded
             module-loaded?
             load-linux-module*
+            install-module-files
 
             current-module-debugging-port
 
@@ -379,4 +380,55 @@ ALIAS is a string like \"scsi:t-0x00\" as returned by
                       module)))
               known-aliases))
 
+(define %not-dash
+  (char-set-complement (char-set #\-)))
+
+(define (install-module-files module-files output)
+  "Install MODULE-FILES to OUTPUT.
+Precondition: OUTPUT is an empty directory."
+  (let ((aliases
+         (map (lambda (module-file-name)
+                (format #t "copying '~a'...~%" module-file-name)
+                (copy-file module-file-name
+                           (string-append output "/"
+                                          (basename module-file-name)))
+                `(,(file-name->module-name module-file-name) .
+                  ,(module-aliases module-file-name)))
+              (sort module-files string<))))
+    (call-with-output-file (string-append output "/modules.alias")
+      (lambda (port)
+        (format port
+                "# Aliases extracted from modules themselves.\n")
+        (for-each (match-lambda ((module . aliases)
+                                 (for-each (lambda (alias)
+                                             (format port "alias ~a ~a\n" alias
+                                                     module))
+                                           aliases)))
+                  aliases)))
+    (call-with-output-file (string-append output "/modules.devname")
+      (lambda (port)
+        (format port
+                "# Device nodes to trigger on-demand module loading.\n")
+        (let* ((aliases (append-map (match-lambda
+                                     ((module . aliases) aliases))
+                                    aliases))
+               (devname #f))
+          ;; Note: there's only one devname and then only one (char-major|block-major).
+          (for-each
+           (match-lambda
+            (((? (cut string-prefix? "devname:" <>) alias) . value)
+             (set! devname (string-drop value (string-length "devname:"))))
+            (((? (cut string-prefix? "char-major-" <>) alias) . value)
+             (let ((parts (string-tokenize %not-dash)))
+               (match parts
+                      ((a b major minor)
+                       (format port "~a ~a ~a:~a\n" devname "c" major minor)))))
+            (((? (cut string-prefix? "block-major-" <>) alias) . value)
+             (let ((parts (string-tokenize %not-dash)))
+               (match parts
+                      ((a b major minor)
+                       (format port "~a ~a ~a:~a\n" devname "b" major minor)))))
+            (_ #f))
+           aliases))))))
+
 ;;; linux-modules.scm ends here




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 14:17:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 09:17:29 2018
Received: from localhost ([127.0.0.1]:40323 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1erlV3-0001Xh-JG
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:29 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:55060)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1erlV1-0001XX-Mp
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:17:27 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 13F6733601D1;
 Fri,  2 Mar 2018 15:17:25 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v6 1/6] linux-modules: Add module-aliases.
Date: Fri,  2 Mar 2018 15:17:15 +0100
Message-Id: <20180302141720.10720-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180302141606.10669-1-dannym@HIDDEN>
References: <20180302141606.10669-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-modules.scm (module-aliases): New variable.
---
 gnu/build/linux-modules.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm
index 4a6d4ff08..364339df9 100644
--- a/gnu/build/linux-modules.scm
+++ b/gnu/build/linux-modules.scm
@@ -30,6 +30,7 @@
   #:use-module (ice-9 rdelim)
   #:export (dot-ko
             ensure-dot-ko
+            module-aliases
             module-dependencies
             recursive-module-dependencies
             modules-loaded
@@ -95,6 +96,14 @@ contains module names, not actual file names."
       (('depends . what)
        (string-tokenize what %not-comma)))))
 
+(define (module-aliases file)
+  "Return the list of aliases for FILE."
+  (let ((info (modinfo-section-contents file)))
+    (filter-map (match-lambda
+                 (('alias . value)
+                  value)
+                 (_ #f)) (modinfo-section-contents file))))
+
 (define dot-ko
   (cut string-append <> ".ko"))
 




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 2 Mar 2018 14:16:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 02 09:16:15 2018
Received: from localhost ([127.0.0.1]:40319 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1erlTr-0001Vk-9b
	for submit <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:16:15 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:54846)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1erlTq-0001Vc-0o
 for 30604 <at> debbugs.gnu.org; Fri, 02 Mar 2018 09:16:14 -0500
Received: from dayas.3.home (77.118.252.91.wireless.dyn.drei.com
 [77.118.252.91])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 0FC8E33601D1;
 Fri,  2 Mar 2018 15:16:10 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v6 0/6] Load Linux module only when supported hardware is
 present.
Date: Fri,  2 Mar 2018 15:16:06 +0100
Message-Id: <20180302141606.10669-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227155051.1141-1-dannym@HIDDEN>
References: <20180227155051.1141-1-dannym@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Danny Milosavljevic (6):
  linux-modules: Add module-aliases.
  linux-modules: Add install-modules.
  linux-boot: Load kernel modules only when the hardware is present.
  vm: Allow qemu-image builder to load Linux kernel modules.
  vm: Make the virtio-blk uniquely identifiable in /sys.
  linux-initrd: Provide modprobe to the initrd.

 gnu/build/linux-boot.scm    | 42 ++++++++++++++++++----
 gnu/build/linux-initrd.scm  | 13 ++++++-
 gnu/build/linux-modules.scm | 61 +++++++++++++++++++++++++++++++
 gnu/build/vm.scm            |  2 +-
 gnu/system/linux-initrd.scm | 88 +++++++++++++++++++++++++++++++++++++++------
 gnu/system/vm.scm           | 34 +++++++++++++++---
 6 files changed, 216 insertions(+), 24 deletions(-)





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:51:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:51:07 2018
Received: from localhost ([127.0.0.1]:34631 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgax-00049Z-4B
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:51:07 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:36062)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqgat-00048n-Bl
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:51:03 -0500
Received: from dayas.3.home (77.118.157.234.wireless.dyn.drei.com
 [77.118.157.234])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id BC7A533601CF;
 Tue, 27 Feb 2018 15:51:01 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v5 7/7] linux-boot: Call make-static-device-nodes much earlier.
Date: Tue, 27 Feb 2018 16:50:51 +0100
Message-Id: <20180227155051.1141-8-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227155051.1141-1-dannym@HIDDEN>
References: <20180227112619.5071-1-dannym@HIDDEN>
 <20180227155051.1141-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (expression->initrd): Store data files for
make-static-device-nodes.
* gnu/build/linux-boot.scm (boot-system): Call make-static-device-nodes.
Delete lookup-module.
---
 gnu/build/linux-boot.scm    | 13 +++++++++----
 gnu/system/linux-initrd.scm |  3 ++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 6d00ea9be..1b16f267a 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -469,10 +469,6 @@ upon error."
              mounts)
         "ext4"))
 
-  (define (lookup-module name)
-    (string-append linux-module-directory "/"
-                   (ensure-dot-ko name)))
-
   (define (load-kernel-modules)
     "Examine /sys/devices to find out which modules to load and load them."
     (define enter?
@@ -512,6 +508,15 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
+       (let* ((kernel-release
+               (utsname:release (uname)))
+              (directory
+               (string-append linux-module-directory "/lib/modules/"
+                              kernel-release))
+              (old-umask (umask #o022)))
+         (make-static-device-nodes directory)
+         (umask old-umask))
+
        (load-kernel-modules)
 
        (when qemu-guest-networking?




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:51:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:51:07 2018
Received: from localhost ([127.0.0.1]:34629 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgaw-00049R-Sq
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:51:07 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:36048)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqgaq-00048E-UK
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:51:01 -0500
Received: from dayas.3.home (77.118.157.234.wireless.dyn.drei.com
 [77.118.157.234])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 951C03360129;
 Tue, 27 Feb 2018 15:50:59 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v5 6/7] vm: Make the virtio-blk is uniquely identifyable in
 /sys.
Date: Tue, 27 Feb 2018 16:50:50 +0100
Message-Id: <20180227155051.1141-7-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227155051.1141-1-dannym@HIDDEN>
References: <20180227112619.5071-1-dannym@HIDDEN>
 <20180227155051.1141-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.
---
 gnu/build/vm.scm  | 2 +-
 gnu/system/vm.scm | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..ebf9e9f6e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,7 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b5a559012..fdff64ed9 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -706,7 +706,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:51:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:51:06 2018
Received: from localhost ([127.0.0.1]:34627 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgaw-00049P-KF
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:51:06 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:36040)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqgao-00047e-Oj
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:59 -0500
Received: from dayas.3.home (77.118.157.234.wireless.dyn.drei.com
 [77.118.157.234])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id B4E8E3360129;
 Tue, 27 Feb 2018 15:50:57 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v5 5/7] vm: Allow qemu-image builder to load Linux kernel
 modules.
Date: Tue, 27 Feb 2018 16:50:49 +0100
Message-Id: <20180227155051.1141-6-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227155051.1141-1-dannym@HIDDEN>
References: <20180227112619.5071-1-dannym@HIDDEN>
 <20180227155051.1141-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/vm.scm (%modprobe-wrapper): New variable.
(qemu-image): Modify.
---
 gnu/system/vm.scm | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 345cecedd..b5a559012 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -246,6 +246,17 @@ INPUTS is a list of inputs (as for packages)."
    #:single-file-output? #t
    #:references-graphs inputs))
 
+(define (%modprobe-wrapper modprobe linux-module-directory)
+  ;; Wrapper for the 'modprobe' command that knows where modules live.
+  ;;
+  ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+  ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+  ;; environment variable is not set---hence the need for this wrapper.
+  (program-file "modprobe"
+    #~(begin
+        (setenv "LINUX_MODULE_DIRECTORY" #$linux-module-directory)
+        (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))
+
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
@@ -275,20 +286,24 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (let ((modprobe-name (file-append os-drv "/profile/bin/modprobe"))
+        (linux-module-directory (file-append (file-append os-drv "/kernel/lib/modules"))))
   (expression->derivation-in-linux-vm
    name
-   (with-imported-modules (source-module-closure '((gnu build bootloader)
+   (with-imported-modules (source-module-closure '((gnu build activation)
+                                                   (gnu build bootloader)
                                                    (gnu build vm)
                                                    (guix build utils)))
      #~(begin
-         (use-modules (gnu build bootloader)
+         (use-modules (gnu build activation)
+                      (gnu build bootloader)
                       (gnu build vm)
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs dosfstools)
+                '#$(append (list qemu parted e2fsprogs dosfstools kmod)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -302,6 +317,14 @@ the image."
                         inputs)))
 
            (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
+           ;; It's possible that we need to load nls modules in order to
+           ;; mount the new partition.
+           (if (file-exists? #$modprobe-name)
+               (activate-modprobe #$(%modprobe-wrapper modprobe-name
+                                     linux-module-directory))
+               (format (current-error-port)
+                "WARNING: No modprobe found in ~s.  \
+Loading kernel modules will be impossible.\n" #$modprobe-name))
 
            (let* ((graphs     '#$(match inputs
                                    (((names . _) ...)
@@ -364,7 +387,7 @@ the image."
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-   #:references-graphs inputs))
+   #:references-graphs inputs)))
 
 
 ;;;




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:50:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:50:59 2018
Received: from localhost ([127.0.0.1]:34618 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgap-000481-AZ
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:59 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:36030)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqgan-00047X-JD
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:57 -0500
Received: from dayas.3.home (77.118.157.234.wireless.dyn.drei.com
 [77.118.157.234])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 86D683361202;
 Tue, 27 Feb 2018 15:50:56 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v5 4/7] linux-boot: Load kernel modules only when the hardware
 is present.
Date: Tue, 27 Feb 2018 16:50:48 +0100
Message-Id: <20180227155051.1141-5-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227155051.1141-1-dannym@HIDDEN>
References: <20180227112619.5071-1-dannym@HIDDEN>
 <20180227155051.1141-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 31 +++++++++++++++++++++++++++----
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..6d00ea9be 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -473,6 +473,32 @@ upon error."
     (string-append linux-module-directory "/"
                    (ensure-dot-ko name)))
 
+  (define (load-kernel-modules)
+    "Examine /sys/devices to find out which modules to load and load them."
+    (define enter?
+      (const #t))
+    (define (down! path stat result)
+     ;; Note: modprobe mutates the tree starting with path.
+     (let ((modalias-name (string-append path "/modalias")))
+       (if (file-exists? modalias-name)
+           (let ((modalias
+                 (string-trim-right (call-with-input-file modalias-name
+                                                          read-string)
+                                    #\newline)))
+             (system* "/sbin/modprobe" "-q" "--" modalias))))
+       #t)
+    (define up
+      (const #t))
+    (define skip
+      (const #t))
+    (define leaf
+      (const #t))
+    (define (error name stat errno result)
+      (format (current-error-port) "warning: ~a: ~a~%"
+              name (strerror errno))
+      result)
+    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
+
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
 
@@ -486,10 +512,7 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 46ef055f0..c8a9e4950 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -225,7 +225,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:50:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:50:59 2018
Received: from localhost ([127.0.0.1]:34615 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgao-00047o-VY
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:59 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:36020)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqgam-00047P-F0
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:56 -0500
Received: from dayas.3.home (77.118.157.234.wireless.dyn.drei.com
 [77.118.157.234])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id ED3CC33601CF;
 Tue, 27 Feb 2018 15:50:54 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v5 3/7] linux-initrd: Add kmod.
Date: Tue, 27 Feb 2018 16:50:47 +0100
Message-Id: <20180227155051.1141-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227155051.1141-1-dannym@HIDDEN>
References: <20180227112619.5071-1-dannym@HIDDEN>
 <20180227155051.1141-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (raw-initrd): Add kmod.
(base-initrd): Add kmod.
(expression->initrd): Add kmod, linux-module-directory.
(flat-linux-module-directory): Add kmod; invoke depmod.
* gnu/build/linux-initrd.scm (build-initrd): Add kmod, linux-module-directory.
---
 gnu/build/linux-initrd.scm  | 12 +++++++++++-
 gnu/system/linux-initrd.scm | 45 ++++++++++++++++++++++++++++++++++-----------
 2 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..6356007df 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init kmod linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,16 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+    ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (when kmod
+      (mkdir-p "sbin")
+      (symlink (string-append kmod "/bin/modprobe") "sbin/modprobe"))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 7170d1c0e..46ef055f0 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -59,6 +59,8 @@
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             kmod
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -94,6 +96,8 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
+                        #:kmod #$kmod
+                        #:linux-module-directory #$linux-module-directory
                         ;; Copy everything INIT refers to into the initrd.
                         #:references-graphs '("closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
@@ -101,7 +105,7 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (gexp->derivation name builder
                     #:references-graphs `(("closure" ,init))))
 
-(define (flat-linux-module-directory linux modules)
+(define (flat-linux-module-directory linux modules kmod)
   "Return a flat directory containing the Linux kernel modules listed in
 MODULES and taken from LINUX."
   (define build-exp
@@ -109,7 +113,7 @@ MODULES and taken from LINUX."
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex)
+          (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
                        (srfi srfi-1)
                        (guix build utils)
                        (gnu build linux-modules))
@@ -138,13 +142,27 @@ MODULES and taken from LINUX."
                       (recursive-module-dependencies modules
                                                      #:lookup-module lookup))))
 
-          (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
+          (define version
+            (match
+             (filter
+              (lambda (name)
+                (not (string-prefix? "." name)))
+              (scandir module-dir))
+             ((item) item)))
+
+          (let ((output (string-append #$output "/lib/modules/" version)))
+            (mkdir-p output)
+            (for-each (lambda (module)
+                        (format #t "copying '~a'...~%" module)
+                        (copy-file module
+                                   (string-append output "/"
+                                                  (basename module))))
+                      (delete-duplicates modules)))
+          (invoke (string-append #$kmod "/bin/depmod") "-a" "-b" #$output
+                  "-e"
+                  "-F" (string-append #$linux "/System.map")
+                  version)
+          #t)))
 
   (computed-file "linux-modules" build-exp))
 
@@ -152,6 +170,7 @@ MODULES and taken from LINUX."
                       #:key
                       (linux linux-libre)
                       (linux-modules '())
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       (helper-packages '())
                       qemu-networking?
@@ -185,7 +204,7 @@ upon error."
          mapped-devices))
 
   (define kodir
-    (flat-linux-module-directory linux linux-modules))
+    (flat-linux-module-directory linux linux-modules kmod))
 
   (expression->initrd
    (with-imported-modules (source-module-closure
@@ -223,6 +242,8 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:kmod kmod
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))
@@ -245,6 +266,7 @@ FILE-SYSTEMS."
 (define* (base-initrd file-systems
                       #:key
                       (linux linux-libre)
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       qemu-networking?
                       volatile-root?
@@ -322,8 +344,9 @@ loaded at boot time in the order in which they appear."
   (raw-initrd file-systems
               #:linux linux
               #:linux-modules linux-modules
+              #:kmod kmod
               #:mapped-devices mapped-devices
-              #:helper-packages helper-packages
+              #:helper-packages (cons kmod helper-packages)
               #:qemu-networking? qemu-networking?
               #:volatile-root? volatile-root?
               #:on-error on-error))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:50:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:50:59 2018
Received: from localhost ([127.0.0.1]:34613 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgao-00047h-Mm
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:58 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:36008)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqgak-000476-Oq
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:55 -0500
Received: from dayas.3.home (77.118.157.234.wireless.dyn.drei.com
 [77.118.157.234])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id D24623361202;
 Tue, 27 Feb 2018 15:50:52 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v5 2/7] gnu: Add kmod-minimal-static.
Date: Tue, 27 Feb 2018 16:50:46 +0100
Message-Id: <20180227155051.1141-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227155051.1141-1-dannym@HIDDEN>
References: <20180227112619.5071-1-dannym@HIDDEN>
 <20180227155051.1141-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal/static): New variable.
* gnu/packages/patches/kmod-13-module-directory.patch: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/linux.scm                             | 44 ++++++++++++++++++++++
 .../patches/kmod-13-module-directory.patch         | 33 ++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 gnu/packages/patches/kmod-13-module-directory.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 21195f8c1..b1e3c878d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -795,6 +795,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/kiki-makefile.patch			\
   %D%/packages/patches/kiki-missing-includes.patch		\
   %D%/packages/patches/kiki-portability-64bit.patch		\
+  %D%/packages/patches/kmod-13-module-directory.patch		\
   %D%/packages/patches/kmod-module-directory.patch		\
   %D%/packages/patches/kobodeluxe-paths.patch			\
   %D%/packages/patches/kobodeluxe-enemies-pipe-decl.patch	\
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 1f8bf3050..b2e47f79a 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1994,6 +1994,50 @@ from the module-init-tools project.")
                      #t))
                  %standard-phases)))))
 
+(define-public kmod-minimal/static
+  (static-package
+   (package (inherit kmod-minimal)
+    (name "kmod-minimal-static")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (arguments
+     (substitute-keyword-arguments
+       (package-arguments (static-package kmod-minimal))
+       ((#:configure-flags flags ''())
+        `(cons* "--disable-manpages" "--disable-static" "--disable-shared" ,flags))
+       ((#:make-flags flags ''())
+        `(cons* "LDFLAGS=-all-static" ,flags))
+       ((#:phases phases '%standard-phases)
+        `(modify-phases ,phases
+          (delete 'install-license-files)
+          (add-after 'unpack 'patch-kmod
+           (lambda _
+             ;; Reduce size by 200 kiB.
+             (substitute* "tools/kmod.c"
+              (("[&]kmod_cmd_compat_lsmod,") "")
+              (("[&]kmod_cmd_compat_rmmod,") "")
+              (("[&]kmod_cmd_compat_insmod,") "")
+              (("[&]kmod_cmd_compat_modinfo,") ""))
+             #t))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "tools/kmod" bin)
+                (for-each
+                 (lambda (tool)
+                   (symlink "kmod" (string-append bin "/" tool)))
+                 '("modprobe" "depmod"))
+                #t))))))))))
+
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.
   (package
diff --git a/gnu/packages/patches/kmod-13-module-directory.patch b/gnu/packages/patches/kmod-13-module-directory.patch
new file mode 100644
index 000000000..5ff2f8a60
--- /dev/null
+++ b/gnu/packages/patches/kmod-13-module-directory.patch
@@ -0,0 +1,33 @@
+This patch changes libkmod so it honors the 'LINUX_MODULE_DIRECTORY'
+environment variable, rather than looking for modules exclusively in
+/lib/modules.
+
+Patch by Shea Levy and Eelco Dolstra, from Nixpkgs; adjusted to
+use 'LINUX_MODULE_DIRECTORY' rather than 'MODULE_DIR' as the variable
+name.
+
+
+--- kmod-7/libkmod/libkmod.c	2012-03-15 08:19:16.750010226 -0400
++++ kmod-7/libkmod/libkmod.c	2012-04-04 15:21:29.532074313 -0400
+@@ -200,7 +200,7 @@
+ static char *get_kernel_release(const char *dirname)
+ {
+ 	struct utsname u;
+-	char *p;
++	char *p, *dirname_prefix;
+ 
+ 	if (dirname != NULL)
+ 		return path_make_absolute_cwd(dirname);
+@@ -208,7 +208,10 @@
+ 	if (uname(&u) < 0)
+ 		return NULL;
+ 
+-	if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
++	if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
++		dirname_prefix = dirname_default_prefix;
++
++	if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
+ 		return NULL;
+ 
+ 	return p;
+




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:50:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:50:58 2018
Received: from localhost ([127.0.0.1]:34611 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgao-00047f-G7
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:58 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:35994)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqgah-00046r-8w
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:55 -0500
Received: from dayas.3.home (77.118.157.234.wireless.dyn.drei.com
 [77.118.157.234])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 5F1073360129;
 Tue, 27 Feb 2018 15:50:49 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v5 0/7] Load Linux module only when supported hardware is
 present.
Date: Tue, 27 Feb 2018 16:50:44 +0100
Message-Id: <20180227155051.1141-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227112619.5071-1-dannym@HIDDEN>
References: <20180227112619.5071-1-dannym@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Danny Milosavljevic (7):
  gnu: kmod: Split off kmod-minimal.
  gnu: Add kmod-minimal-static.
  linux-initrd: Add kmod.
  linux-boot: Load kernel modules only when the hardware is present.
  vm: Allow qemu-image builder to load Linux kernel modules.
  vm: Make the virtio-blk is uniquely identifyable in /sys.
  linux-boot: Call make-static-device-nodes much earlier.

 gnu/build/linux-boot.scm                           | 42 ++++++++--
 gnu/build/linux-initrd.scm                         | 12 ++-
 gnu/build/vm.scm                                   |  2 +-
 gnu/local.mk                                       |  1 +
 gnu/packages/linux.scm                             | 91 ++++++++++++++++++----
 .../patches/kmod-13-module-directory.patch         | 33 ++++++++
 gnu/system/linux-initrd.scm                        | 50 +++++++++---
 gnu/system/vm.scm                                  | 34 ++++++--
 8 files changed, 224 insertions(+), 41 deletions(-)
 create mode 100644 gnu/packages/patches/kmod-13-module-directory.patch





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:50:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:50:54 2018
Received: from localhost ([127.0.0.1]:34606 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgak-000475-7U
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:54 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:35998)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqgai-00046u-Ii
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:50:53 -0500
Received: from dayas.3.home (77.118.157.234.wireless.dyn.drei.com
 [77.118.157.234])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 4278533601CF;
 Tue, 27 Feb 2018 15:50:51 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v5 1/7] gnu: kmod: Split off kmod-minimal.
Date: Tue, 27 Feb 2018 16:50:45 +0100
Message-Id: <20180227155051.1141-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227155051.1141-1-dannym@HIDDEN>
References: <20180227112619.5071-1-dannym@HIDDEN>
 <20180227155051.1141-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal): New variable.
(kmod): Modify.
---
 gnu/packages/linux.scm | 49 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 238398e84..1f8bf3050 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1933,8 +1933,35 @@ for systems using the Linux kernel.  This includes commands such as
 to use Linux' inotify mechanism, which allows file accesses to be monitored.")
     (license license:gpl2+)))
 
-(define-public kmod
+(define kmod-minimal
   (package
+    (name "kmod-minimal")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f)) ; FIXME: Investigate test failures
+    (home-page "https://www.kernel.org/")
+    (synopsis "Kernel module tools")
+    (description "Kmod is a set of tools to handle common tasks with Linux
+kernel modules like insert, remove, list, check properties, resolve
+dependencies and aliases.
+
+These tools are designed on top of libkmod, a library that is shipped with
+kmod.  The aim is to be compatible with tools, configurations and indices
+from the module-init-tools project.")
+    (license license:gpl2+))) ; library under lgpl2.1+
+
+(define-public kmod
+  (package (inherit kmod-minimal)
     (name "kmod")
     (version "24")
     (source (origin
@@ -1946,15 +1973,14 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                (base32
                 "15xkkkzvca9flvkm48gkh8y8f13vlm3sl7nz9ydc7b3jy4fqs2v1"))
               (patches (search-patches "kmod-module-directory.patch"))))
-    (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)))
     (inputs
      `(("xz" ,xz)
        ("zlib" ,zlib)))
     (arguments
-     `(#:tests? #f ; FIXME: Investigate test failures
-       #:configure-flags '("--with-xz" "--with-zlib")
+     `(#:configure-flags '("--with-xz" "--with-zlib")
+       #:tests? #f ; FIXME: Investigate test failures
        #:phases (alist-cons-after
                  'install 'install-modprobe&co
                  (lambda* (#:key outputs #:allow-other-keys)
@@ -1964,18 +1990,9 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                                  (symlink "kmod"
                                           (string-append bin "/" tool)))
                                '("insmod" "rmmod" "lsmod" "modprobe"
-                                 "modinfo" "depmod"))))
-                 %standard-phases)))
-    (home-page "https://www.kernel.org/")
-    (synopsis "Kernel module tools")
-    (description "Kmod is a set of tools to handle common tasks with Linux
-kernel modules like insert, remove, list, check properties, resolve
-dependencies and aliases.
-
-These tools are designed on top of libkmod, a library that is shipped with
-kmod.  The aim is to be compatible with tools, configurations and indices
-from the module-init-tools project.")
-    (license license:gpl2+))) ; library under lgpl2.1+
+                                 "modinfo" "depmod"))
+                     #t))
+                 %standard-phases)))))
 
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 14:26:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 09:26:10 2018
Received: from localhost ([127.0.0.1]:34594 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqgCn-0003T9-Vw
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:26:10 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:52424)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1eqgCm-0003Sz-Bb
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 09:26:08 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id D2C2D11FDE;
 Tue, 27 Feb 2018 15:26:07 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id c7om1nzrY475; Tue, 27 Feb 2018 15:26:06 +0100 (CET)
Received: from ribbon (unknown [193.50.110.216])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 6E96B11CC3;
 Tue, 27 Feb 2018 15:26:06 +0100 (CET)
From: ludo@HIDDEN (Ludovic =?utf-8?Q?Court=C3=A8s?=)
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH v3 4/6] linux-boot: Load kernel modules only
 when the hardware is present.
References: <20180226035025.1698-1-dannym@HIDDEN>
 <20180226040609.3066-1-dannym@HIDDEN>
 <20180226040609.3066-5-dannym@HIDDEN>
Date: Tue, 27 Feb 2018 15:26:06 +0100
In-Reply-To: <20180226040609.3066-5-dannym@HIDDEN> (Danny
 Milosavljevic's message of "Mon, 26 Feb 2018 05:06:07 +0100")
Message-ID: <87muzu33wh.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

Hello,

Nice patch series!

Danny Milosavljevic <dannym@HIDDEN> skribis:

> * gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
> the hardware is present.
> * gnu/system/linux-initrd.scm (raw-initrd): Add imports.

[...]

> +  (define (load-kernel-modules)
> +    "Examine /sys/devices to find out which modules to load and load the=
m."
> +    (define enter?
> +      (const #t))
> +    (define (down! path stat result)
> +     ;; Note: modprobe mutates the tree starting with path.
> +     (let ((modalias-name (string-append path "/modalias")))
> +       (if (file-exists? modalias-name)
> +           (let ((modalias
> +                 (string-trim-right (call-with-input-file modalias-name
> +                                                          read-string)
> +                                    #\newline)))
> +             (system* "/sbin/modprobe" "-q" "--" modalias))))

Can we build upon (gnu build linux-modules) to achieve this?

Hopefully the tools at
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D30629#14> can help a bit.

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 10:26:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 05:26:32 2018
Received: from localhost ([127.0.0.1]:34383 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqcSt-0003tz-SH
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:32 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42494)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqcSs-0003tR-6v
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:30 -0500
Received: from dayas.3.home (77.118.239.24.wireless.dyn.drei.com
 [77.118.239.24])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 3B36533615C9;
 Tue, 27 Feb 2018 11:26:29 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v4 7/7] linux-boot: Call make-static-device-nodes much earlier.
Date: Tue, 27 Feb 2018 12:26:19 +0100
Message-Id: <20180227112619.5071-8-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227112619.5071-1-dannym@HIDDEN>
References: <20180226040609.3066-1-dannym@HIDDEN>
 <20180227112619.5071-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (expression->initrd): Store data files for
make-static-device-nodes.
* gnu/build/linux-boot.scm (make-static-device-nodes): Unexport.
(boot-system): Call make-static-device-nodes.  Delete lookup-module.
* gnu/services/base.scm (udev-shepherd-service): Delete
make-static-device-nodes call.
---
 gnu/build/linux-boot.scm    | 14 +++++++++-----
 gnu/services/base.scm       | 11 -----------
 gnu/system/linux-initrd.scm |  3 ++-
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 6d00ea9be..f0ac755f8 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -39,7 +39,6 @@
             find-long-option
             find-long-options
             make-essential-device-nodes
-            make-static-device-nodes
             configure-qemu-networking
 
             device-number
@@ -469,10 +468,6 @@ upon error."
              mounts)
         "ext4"))
 
-  (define (lookup-module name)
-    (string-append linux-module-directory "/"
-                   (ensure-dot-ko name)))
-
   (define (load-kernel-modules)
     "Examine /sys/devices to find out which modules to load and load them."
     (define enter?
@@ -512,6 +507,15 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
+       (let* ((kernel-release
+               (utsname:release (uname)))
+              (directory
+               (string-append linux-module-directory "/lib/modules/"
+                              kernel-release))
+              (old-umask (umask #o022)))
+         (make-static-device-nodes directory)
+         (umask old-umask))
+
        (load-kernel-modules)
 
        (when qemu-guest-networking?
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 69e211ffa..0cba1c66f 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -1857,17 +1857,6 @@ item of @var{packages}."
                     (setenv "EUDEV_RULES_DIRECTORY"
                             #$(file-append rules "/lib/udev/rules.d"))
 
-                    (let* ((kernel-release
-                            (utsname:release (uname)))
-                           (linux-module-directory
-                            (getenv "LINUX_MODULE_DIRECTORY"))
-                           (directory
-                            (string-append linux-module-directory "/"
-                                           kernel-release))
-                           (old-umask (umask #o022)))
-                      (make-static-device-nodes directory)
-                      (umask old-umask))
-
                     (let ((pid (primitive-fork)))
                       (case pid
                         ((0)




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 10:26:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 05:26:31 2018
Received: from localhost ([127.0.0.1]:34381 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqcSt-0003tq-If
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:31 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42486)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqcSr-0003tK-1Y
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:29 -0500
Received: from dayas.3.home (77.118.239.24.wireless.dyn.drei.com
 [77.118.239.24])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 287F7336287E;
 Tue, 27 Feb 2018 11:26:28 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v4 6/7] vm: Make the virtio-blk uniquely identifyable in /sys.
Date: Tue, 27 Feb 2018 12:26:18 +0100
Message-Id: <20180227112619.5071-7-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227112619.5071-1-dannym@HIDDEN>
References: <20180226040609.3066-1-dannym@HIDDEN>
 <20180227112619.5071-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.
---
 gnu/build/vm.scm  | 2 +-
 gnu/system/vm.scm | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..ebf9e9f6e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,7 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b5a559012..fdff64ed9 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -706,7 +706,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 10:26:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 05:26:31 2018
Received: from localhost ([127.0.0.1]:34379 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqcSt-0003ti-A0
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:31 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42476)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqcSq-0003tD-37
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:28 -0500
Received: from dayas.3.home (77.118.239.24.wireless.dyn.drei.com
 [77.118.239.24])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 38CEC33615C9;
 Tue, 27 Feb 2018 11:26:27 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v4 5/7] vm: Allow qemu-image builder to load Linux kernel
 modules.
Date: Tue, 27 Feb 2018 12:26:17 +0100
Message-Id: <20180227112619.5071-6-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227112619.5071-1-dannym@HIDDEN>
References: <20180226040609.3066-1-dannym@HIDDEN>
 <20180227112619.5071-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/vm.scm (%modprobe-wrapper): New variable.
(qemu-image): Modify.
---
 gnu/system/vm.scm | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 345cecedd..b5a559012 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -246,6 +246,17 @@ INPUTS is a list of inputs (as for packages)."
    #:single-file-output? #t
    #:references-graphs inputs))
 
+(define (%modprobe-wrapper modprobe linux-module-directory)
+  ;; Wrapper for the 'modprobe' command that knows where modules live.
+  ;;
+  ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+  ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+  ;; environment variable is not set---hence the need for this wrapper.
+  (program-file "modprobe"
+    #~(begin
+        (setenv "LINUX_MODULE_DIRECTORY" #$linux-module-directory)
+        (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))
+
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
@@ -275,20 +286,24 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (let ((modprobe-name (file-append os-drv "/profile/bin/modprobe"))
+        (linux-module-directory (file-append (file-append os-drv "/kernel/lib/modules"))))
   (expression->derivation-in-linux-vm
    name
-   (with-imported-modules (source-module-closure '((gnu build bootloader)
+   (with-imported-modules (source-module-closure '((gnu build activation)
+                                                   (gnu build bootloader)
                                                    (gnu build vm)
                                                    (guix build utils)))
      #~(begin
-         (use-modules (gnu build bootloader)
+         (use-modules (gnu build activation)
+                      (gnu build bootloader)
                       (gnu build vm)
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs dosfstools)
+                '#$(append (list qemu parted e2fsprogs dosfstools kmod)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -302,6 +317,14 @@ the image."
                         inputs)))
 
            (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
+           ;; It's possible that we need to load nls modules in order to
+           ;; mount the new partition.
+           (if (file-exists? #$modprobe-name)
+               (activate-modprobe #$(%modprobe-wrapper modprobe-name
+                                     linux-module-directory))
+               (format (current-error-port)
+                "WARNING: No modprobe found in ~s.  \
+Loading kernel modules will be impossible.\n" #$modprobe-name))
 
            (let* ((graphs     '#$(match inputs
                                    (((names . _) ...)
@@ -364,7 +387,7 @@ the image."
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-   #:references-graphs inputs))
+   #:references-graphs inputs)))
 
 
 ;;;




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 10:26:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 05:26:31 2018
Received: from localhost ([127.0.0.1]:34377 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqcSt-0003ta-0V
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:31 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42452)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqcSo-0003sT-NX
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:27 -0500
Received: from dayas.3.home (77.118.239.24.wireless.dyn.drei.com
 [77.118.239.24])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 3860E3362AB9;
 Tue, 27 Feb 2018 11:26:26 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v4 4/7] linux-boot: Load kernel modules only when the hardware
 is present.
Date: Tue, 27 Feb 2018 12:26:16 +0100
Message-Id: <20180227112619.5071-5-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227112619.5071-1-dannym@HIDDEN>
References: <20180226040609.3066-1-dannym@HIDDEN>
 <20180227112619.5071-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 31 +++++++++++++++++++++++++++----
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..6d00ea9be 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -473,6 +473,32 @@ upon error."
     (string-append linux-module-directory "/"
                    (ensure-dot-ko name)))
 
+  (define (load-kernel-modules)
+    "Examine /sys/devices to find out which modules to load and load them."
+    (define enter?
+      (const #t))
+    (define (down! path stat result)
+     ;; Note: modprobe mutates the tree starting with path.
+     (let ((modalias-name (string-append path "/modalias")))
+       (if (file-exists? modalias-name)
+           (let ((modalias
+                 (string-trim-right (call-with-input-file modalias-name
+                                                          read-string)
+                                    #\newline)))
+             (system* "/sbin/modprobe" "-q" "--" modalias))))
+       #t)
+    (define up
+      (const #t))
+    (define skip
+      (const #t))
+    (define leaf
+      (const #t))
+    (define (error name stat errno result)
+      (format (current-error-port) "warning: ~a: ~a~%"
+              name (strerror errno))
+      result)
+    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
+
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
 
@@ -486,10 +512,7 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 46ef055f0..c8a9e4950 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -225,7 +225,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 10:26:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 05:26:31 2018
Received: from localhost ([127.0.0.1]:34375 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqcSs-0003tY-MT
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:30 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42462)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqcSo-0003sY-4j
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:26 -0500
Received: from dayas.3.home (77.118.239.24.wireless.dyn.drei.com
 [77.118.239.24])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id D778333615C9;
 Tue, 27 Feb 2018 11:26:24 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v4 3/7] linux-initrd: Add kmod.
Date: Tue, 27 Feb 2018 12:26:15 +0100
Message-Id: <20180227112619.5071-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227112619.5071-1-dannym@HIDDEN>
References: <20180226040609.3066-1-dannym@HIDDEN>
 <20180227112619.5071-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (raw-initrd): Add kmod.
(base-initrd): Add kmod.
(expression->initrd): Add kmod, linux-module-directory.
(flat-linux-module-directory): Add kmod; invoke depmod.
* gnu/build/linux-initrd.scm (build-initrd): Add kmod, linux-module-directory.
---
 gnu/build/linux-initrd.scm  | 12 +++++++++++-
 gnu/system/linux-initrd.scm | 45 ++++++++++++++++++++++++++++++++++-----------
 2 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..6356007df 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init kmod linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,16 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+    ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (when kmod
+      (mkdir-p "sbin")
+      (symlink (string-append kmod "/bin/modprobe") "sbin/modprobe"))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 7170d1c0e..46ef055f0 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -59,6 +59,8 @@
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             kmod
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -94,6 +96,8 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
+                        #:kmod #$kmod
+                        #:linux-module-directory #$linux-module-directory
                         ;; Copy everything INIT refers to into the initrd.
                         #:references-graphs '("closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
@@ -101,7 +105,7 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (gexp->derivation name builder
                     #:references-graphs `(("closure" ,init))))
 
-(define (flat-linux-module-directory linux modules)
+(define (flat-linux-module-directory linux modules kmod)
   "Return a flat directory containing the Linux kernel modules listed in
 MODULES and taken from LINUX."
   (define build-exp
@@ -109,7 +113,7 @@ MODULES and taken from LINUX."
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex)
+          (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
                        (srfi srfi-1)
                        (guix build utils)
                        (gnu build linux-modules))
@@ -138,13 +142,27 @@ MODULES and taken from LINUX."
                       (recursive-module-dependencies modules
                                                      #:lookup-module lookup))))
 
-          (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
+          (define version
+            (match
+             (filter
+              (lambda (name)
+                (not (string-prefix? "." name)))
+              (scandir module-dir))
+             ((item) item)))
+
+          (let ((output (string-append #$output "/lib/modules/" version)))
+            (mkdir-p output)
+            (for-each (lambda (module)
+                        (format #t "copying '~a'...~%" module)
+                        (copy-file module
+                                   (string-append output "/"
+                                                  (basename module))))
+                      (delete-duplicates modules)))
+          (invoke (string-append #$kmod "/bin/depmod") "-a" "-b" #$output
+                  "-e"
+                  "-F" (string-append #$linux "/System.map")
+                  version)
+          #t)))
 
   (computed-file "linux-modules" build-exp))
 
@@ -152,6 +170,7 @@ MODULES and taken from LINUX."
                       #:key
                       (linux linux-libre)
                       (linux-modules '())
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       (helper-packages '())
                       qemu-networking?
@@ -185,7 +204,7 @@ upon error."
          mapped-devices))
 
   (define kodir
-    (flat-linux-module-directory linux linux-modules))
+    (flat-linux-module-directory linux linux-modules kmod))
 
   (expression->initrd
    (with-imported-modules (source-module-closure
@@ -223,6 +242,8 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:kmod kmod
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))
@@ -245,6 +266,7 @@ FILE-SYSTEMS."
 (define* (base-initrd file-systems
                       #:key
                       (linux linux-libre)
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       qemu-networking?
                       volatile-root?
@@ -322,8 +344,9 @@ loaded at boot time in the order in which they appear."
   (raw-initrd file-systems
               #:linux linux
               #:linux-modules linux-modules
+              #:kmod kmod
               #:mapped-devices mapped-devices
-              #:helper-packages helper-packages
+              #:helper-packages (cons kmod helper-packages)
               #:qemu-networking? qemu-networking?
               #:volatile-root? volatile-root?
               #:on-error on-error))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 10:26:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 05:26:27 2018
Received: from localhost ([127.0.0.1]:34370 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqcSp-0003t1-Dk
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:27 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42440)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqcSk-0003sJ-8p
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:25 -0500
Received: from dayas.3.home (77.118.239.24.wireless.dyn.drei.com
 [77.118.239.24])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 4FB8F336287E;
 Tue, 27 Feb 2018 11:26:20 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v4 0/7] Load Linux module only when supported hardware is
 present.
Date: Tue, 27 Feb 2018 12:26:12 +0100
Message-Id: <20180227112619.5071-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226040609.3066-1-dannym@HIDDEN>
References: <20180226040609.3066-1-dannym@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Danny Milosavljevic (7):
  gnu: kmod: Split off kmod-minimal.
  gnu: Add kmod-minimal-static.
  linux-initrd: Add kmod.
  linux-boot: Load kernel modules only when the hardware is present.
  vm: Allow qemu-image builder to load Linux kernel modules.
  vm: Make the virtio-blk uniquely identifyable in /sys.
  linux-boot: Call make-static-device-nodes much earlier.

 gnu/build/linux-boot.scm                           | 43 ++++++++--
 gnu/build/linux-initrd.scm                         | 12 ++-
 gnu/build/vm.scm                                   |  2 +-
 gnu/local.mk                                       |  1 +
 gnu/packages/linux.scm                             | 91 ++++++++++++++++++----
 .../patches/kmod-13-module-directory.patch         | 33 ++++++++
 gnu/services/base.scm                              | 11 ---
 gnu/system/linux-initrd.scm                        | 50 +++++++++---
 gnu/system/vm.scm                                  | 34 ++++++--
 9 files changed, 224 insertions(+), 53 deletions(-)
 create mode 100644 gnu/packages/patches/kmod-13-module-directory.patch





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 10:26:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 05:26:27 2018
Received: from localhost ([127.0.0.1]:34368 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqcSp-0003sz-3v
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:27 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42452)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqcSm-0003sT-Pp
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:25 -0500
Received: from dayas.3.home (77.118.239.24.wireless.dyn.drei.com
 [77.118.239.24])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id C6A0B3362DFC;
 Tue, 27 Feb 2018 11:26:23 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v4 2/7] gnu: Add kmod-minimal-static.
Date: Tue, 27 Feb 2018 12:26:14 +0100
Message-Id: <20180227112619.5071-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227112619.5071-1-dannym@HIDDEN>
References: <20180226040609.3066-1-dannym@HIDDEN>
 <20180227112619.5071-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal/static): New variable.
* gnu/packages/patches/kmod-13-module-directory.patch: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/linux.scm                             | 44 ++++++++++++++++++++++
 .../patches/kmod-13-module-directory.patch         | 33 ++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 gnu/packages/patches/kmod-13-module-directory.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 21195f8c1..b1e3c878d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -795,6 +795,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/kiki-makefile.patch			\
   %D%/packages/patches/kiki-missing-includes.patch		\
   %D%/packages/patches/kiki-portability-64bit.patch		\
+  %D%/packages/patches/kmod-13-module-directory.patch		\
   %D%/packages/patches/kmod-module-directory.patch		\
   %D%/packages/patches/kobodeluxe-paths.patch			\
   %D%/packages/patches/kobodeluxe-enemies-pipe-decl.patch	\
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 1f8bf3050..b2e47f79a 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1994,6 +1994,50 @@ from the module-init-tools project.")
                      #t))
                  %standard-phases)))))
 
+(define-public kmod-minimal/static
+  (static-package
+   (package (inherit kmod-minimal)
+    (name "kmod-minimal-static")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (arguments
+     (substitute-keyword-arguments
+       (package-arguments (static-package kmod-minimal))
+       ((#:configure-flags flags ''())
+        `(cons* "--disable-manpages" "--disable-static" "--disable-shared" ,flags))
+       ((#:make-flags flags ''())
+        `(cons* "LDFLAGS=-all-static" ,flags))
+       ((#:phases phases '%standard-phases)
+        `(modify-phases ,phases
+          (delete 'install-license-files)
+          (add-after 'unpack 'patch-kmod
+           (lambda _
+             ;; Reduce size by 200 kiB.
+             (substitute* "tools/kmod.c"
+              (("[&]kmod_cmd_compat_lsmod,") "")
+              (("[&]kmod_cmd_compat_rmmod,") "")
+              (("[&]kmod_cmd_compat_insmod,") "")
+              (("[&]kmod_cmd_compat_modinfo,") ""))
+             #t))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "tools/kmod" bin)
+                (for-each
+                 (lambda (tool)
+                   (symlink "kmod" (string-append bin "/" tool)))
+                 '("modprobe" "depmod"))
+                #t))))))))))
+
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.
   (package
diff --git a/gnu/packages/patches/kmod-13-module-directory.patch b/gnu/packages/patches/kmod-13-module-directory.patch
new file mode 100644
index 000000000..5ff2f8a60
--- /dev/null
+++ b/gnu/packages/patches/kmod-13-module-directory.patch
@@ -0,0 +1,33 @@
+This patch changes libkmod so it honors the 'LINUX_MODULE_DIRECTORY'
+environment variable, rather than looking for modules exclusively in
+/lib/modules.
+
+Patch by Shea Levy and Eelco Dolstra, from Nixpkgs; adjusted to
+use 'LINUX_MODULE_DIRECTORY' rather than 'MODULE_DIR' as the variable
+name.
+
+
+--- kmod-7/libkmod/libkmod.c	2012-03-15 08:19:16.750010226 -0400
++++ kmod-7/libkmod/libkmod.c	2012-04-04 15:21:29.532074313 -0400
+@@ -200,7 +200,7 @@
+ static char *get_kernel_release(const char *dirname)
+ {
+ 	struct utsname u;
+-	char *p;
++	char *p, *dirname_prefix;
+ 
+ 	if (dirname != NULL)
+ 		return path_make_absolute_cwd(dirname);
+@@ -208,7 +208,10 @@
+ 	if (uname(&u) < 0)
+ 		return NULL;
+ 
+-	if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
++	if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
++		dirname_prefix = dirname_default_prefix;
++
++	if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
+ 		return NULL;
+ 
+ 	return p;
+




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 27 Feb 2018 10:26:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 27 05:26:26 2018
Received: from localhost ([127.0.0.1]:34364 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqcSn-0003sU-32
	for submit <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:26 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:42444)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqcSl-0003sM-LI
 for 30604 <at> debbugs.gnu.org; Tue, 27 Feb 2018 05:26:24 -0500
Received: from dayas.3.home (77.118.239.24.wireless.dyn.drei.com
 [77.118.239.24])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 982AA33615C9;
 Tue, 27 Feb 2018 11:26:22 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v4 1/7] gnu: kmod: Split off kmod-minimal.
Date: Tue, 27 Feb 2018 12:26:13 +0100
Message-Id: <20180227112619.5071-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180227112619.5071-1-dannym@HIDDEN>
References: <20180226040609.3066-1-dannym@HIDDEN>
 <20180227112619.5071-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal): New variable.
(kmod): Modify.
---
 gnu/packages/linux.scm | 49 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 238398e84..1f8bf3050 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1933,8 +1933,35 @@ for systems using the Linux kernel.  This includes commands such as
 to use Linux' inotify mechanism, which allows file accesses to be monitored.")
     (license license:gpl2+)))
 
-(define-public kmod
+(define kmod-minimal
   (package
+    (name "kmod-minimal")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f)) ; FIXME: Investigate test failures
+    (home-page "https://www.kernel.org/")
+    (synopsis "Kernel module tools")
+    (description "Kmod is a set of tools to handle common tasks with Linux
+kernel modules like insert, remove, list, check properties, resolve
+dependencies and aliases.
+
+These tools are designed on top of libkmod, a library that is shipped with
+kmod.  The aim is to be compatible with tools, configurations and indices
+from the module-init-tools project.")
+    (license license:gpl2+))) ; library under lgpl2.1+
+
+(define-public kmod
+  (package (inherit kmod-minimal)
     (name "kmod")
     (version "24")
     (source (origin
@@ -1946,15 +1973,14 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                (base32
                 "15xkkkzvca9flvkm48gkh8y8f13vlm3sl7nz9ydc7b3jy4fqs2v1"))
               (patches (search-patches "kmod-module-directory.patch"))))
-    (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)))
     (inputs
      `(("xz" ,xz)
        ("zlib" ,zlib)))
     (arguments
-     `(#:tests? #f ; FIXME: Investigate test failures
-       #:configure-flags '("--with-xz" "--with-zlib")
+     `(#:configure-flags '("--with-xz" "--with-zlib")
+       #:tests? #f ; FIXME: Investigate test failures
        #:phases (alist-cons-after
                  'install 'install-modprobe&co
                  (lambda* (#:key outputs #:allow-other-keys)
@@ -1964,18 +1990,9 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                                  (symlink "kmod"
                                           (string-append bin "/" tool)))
                                '("insmod" "rmmod" "lsmod" "modprobe"
-                                 "modinfo" "depmod"))))
-                 %standard-phases)))
-    (home-page "https://www.kernel.org/")
-    (synopsis "Kernel module tools")
-    (description "Kmod is a set of tools to handle common tasks with Linux
-kernel modules like insert, remove, list, check properties, resolve
-dependencies and aliases.
-
-These tools are designed on top of libkmod, a library that is shipped with
-kmod.  The aim is to be compatible with tools, configurations and indices
-from the module-init-tools project.")
-    (license license:gpl2+))) ; library under lgpl2.1+
+                                 "modinfo" "depmod"))
+                     #t))
+                 %standard-phases)))))
 
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 11:52:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 26 06:52:01 2018
Received: from localhost ([127.0.0.1]:32826 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqHK5-00075N-ES
	for submit <at> debbugs.gnu.org; Mon, 26 Feb 2018 06:52:01 -0500
Received: from mail-wm0-f45.google.com ([74.125.82.45]:37279)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <m.othacehe@HIDDEN>) id 1eqHK3-00075A-F7
 for 30604 <at> debbugs.gnu.org; Mon, 26 Feb 2018 06:51:59 -0500
Received: by mail-wm0-f45.google.com with SMTP id 139so3519697wmn.2
 for <30604 <at> debbugs.gnu.org>; Mon, 26 Feb 2018 03:51:59 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=references:user-agent:from:to:cc:subject:in-reply-to:date
 :message-id:mime-version;
 bh=5i6T3rxqP8CWJWRxiWNh6xDnQ5Hvl15DMRbhDNWQMdI=;
 b=Wse6k8247do6aHihrvX3dKSu+y/PWmohVtP8kSh9pVkHJ7oU6kSMiWoqZCfjhwd2FB
 9XL9HKEvheHn4BPrP7Ubqw3zEmltu1Fts3gDRKX6toHc3IqCcuYxAE4gi98Jtn23pXtn
 duh82szm94cqaarjfTkRKUEJmz+XsDsrWBnFBX1JANNKVps+vQCdBU1ThpCRx+sRrUVM
 862dzqlGNVvdsinV/txl1+Iljv/857iyWYJQPs9qY2gYsf/oUcyoBLHYXmiVMvDyCoTf
 WCpUq+6G5/wH3ymmhpeHSIrONq7tJoWIzY4BF4ZQK55WQzPgajiSe7Ckce6N5XbR5Y12
 Bb9g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:references:user-agent:from:to:cc:subject
 :in-reply-to:date:message-id:mime-version;
 bh=5i6T3rxqP8CWJWRxiWNh6xDnQ5Hvl15DMRbhDNWQMdI=;
 b=LKi8ltl1CByVwAog/ENeeNHHGqTGbecP2OjgojHkjsq5cVY/uRnVGfjHErm8XmbkpG
 UV7akTall3Hl/56sASqU6I2lTQSGrq0BsMBT+ONnyYC6iRCsCZvkPl6J7ApDfu3p7Mes
 PSYHCKHUD9JjowIBCQplhqQTtz0uRStAMjTu/VPE/T/g9G8/Cp+sJaUAoTY74iDVzFIn
 rGHU3tXf30cvsH6EPyXWDuu7lDJy1INSj1ONtsQm9kvcdvMJt5G5iqcqLtyfDkAz/woy
 uHirvhq52wLddIu1ystJxgJWWwfK/9q213mIVvYLgYvWwUnLpEWXPTpUct9BZnOI3uXl
 SgOA==
X-Gm-Message-State: APf1xPD9yeL0GxO7UgL29XYX5f0Urst2Y5yVo58jcHcAr4mfBWWFH3Am
 5IDXVoCuFFcgCOjq4n3wpOQ92w==
X-Google-Smtp-Source: AG47ELugXm3kREm1j/NY1qEAXEvwcJDzkGcHEr4LKGGF0FAVmDWCLHjAr4rwmDZ/K0WcsVJTaltBWg==
X-Received: by 10.28.133.129 with SMTP id h123mr8763571wmd.146.1519645913390; 
 Mon, 26 Feb 2018 03:51:53 -0800 (PST)
Received: from denali ([46.218.109.88])
 by smtp.gmail.com with ESMTPSA id x78sm19032749wmd.2.2018.02.26.03.51.52
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Mon, 26 Feb 2018 03:51:52 -0800 (PST)
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180225114816.869-1-dannym@HIDDEN>
 <20180225114816.869-3-dannym@HIDDEN> <87vaelf9ln.fsf@HIDDEN>
 <20180225160750.46bf5b50@HIDDEN>
User-agent: mu4e 0.9.18; emacs 25.3.1
From: Mathieu Othacehe <m.othacehe@HIDDEN>
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH 3/4] linux-initrd: Add kmod.
In-reply-to: <20180225160750.46bf5b50@HIDDEN>
Date: Mon, 26 Feb 2018 12:51:51 +0100
Message-ID: <87h8q4j7e0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)


Hey Danny,

> Because it's an option for specifying the location of "Module.symvers" - and
> I don't know whether guix uses it (probably not).  If one doesn't specify an
> option, depmod will default to the running kernel - which is not what we want.
>
> I should elaborate in the comment that, if we start using Module.symvers, we
> MUST pass "-E" there.  Maybe better to even just check for the file existence
> and add it right now, otherwise we might forget later.  What do you think?

Reading 'depmod' manpage, I understand that -E and -F are mutually
exclusive. Both options seem to have an interest only if -e is supplied
to "reports any symbols which a module needs which are not supplied by
other modules or the kernel".

So maybe something like "-F (string-append #$linux "/System.map") -e"
would make more sense ?

Mathieu




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 04:06:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 23:06:25 2018
Received: from localhost ([127.0.0.1]:60938 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqA3V-0004fc-Hk
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:25 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:45184)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqA3S-0004f7-2K
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:22 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 409C433628BE;
 Mon, 26 Feb 2018 05:06:21 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v3 6/6] vm: Make the virtio-blk is uniquely identifyable in
 /sys.
Date: Mon, 26 Feb 2018 05:06:09 +0100
Message-Id: <20180226040609.3066-7-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226040609.3066-1-dannym@HIDDEN>
References: <20180226035025.1698-1-dannym@HIDDEN>
 <20180226040609.3066-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.
---
 gnu/build/vm.scm  | 2 +-
 gnu/system/vm.scm | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..ebf9e9f6e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,7 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b5a559012..fdff64ed9 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -706,7 +706,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 04:06:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 23:06:25 2018
Received: from localhost ([127.0.0.1]:60936 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqA3V-0004fU-AH
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:25 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:45176)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqA3R-0004er-5R
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:21 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 546F33361FF7;
 Mon, 26 Feb 2018 05:06:20 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v3 5/6] vm: Allow qemu-image builder to load Linux kernel
 modules.
Date: Mon, 26 Feb 2018 05:06:08 +0100
Message-Id: <20180226040609.3066-6-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226040609.3066-1-dannym@HIDDEN>
References: <20180226035025.1698-1-dannym@HIDDEN>
 <20180226040609.3066-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/vm.scm (%modprobe-wrapper): New variable.
(qemu-image): Modify.
---
 gnu/system/vm.scm | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 345cecedd..b5a559012 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -246,6 +246,17 @@ INPUTS is a list of inputs (as for packages)."
    #:single-file-output? #t
    #:references-graphs inputs))
 
+(define (%modprobe-wrapper modprobe linux-module-directory)
+  ;; Wrapper for the 'modprobe' command that knows where modules live.
+  ;;
+  ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+  ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+  ;; environment variable is not set---hence the need for this wrapper.
+  (program-file "modprobe"
+    #~(begin
+        (setenv "LINUX_MODULE_DIRECTORY" #$linux-module-directory)
+        (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))
+
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
@@ -275,20 +286,24 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (let ((modprobe-name (file-append os-drv "/profile/bin/modprobe"))
+        (linux-module-directory (file-append (file-append os-drv "/kernel/lib/modules"))))
   (expression->derivation-in-linux-vm
    name
-   (with-imported-modules (source-module-closure '((gnu build bootloader)
+   (with-imported-modules (source-module-closure '((gnu build activation)
+                                                   (gnu build bootloader)
                                                    (gnu build vm)
                                                    (guix build utils)))
      #~(begin
-         (use-modules (gnu build bootloader)
+         (use-modules (gnu build activation)
+                      (gnu build bootloader)
                       (gnu build vm)
                       (guix build utils)
                       (srfi srfi-26)
                       (ice-9 binary-ports))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs dosfstools)
+                '#$(append (list qemu parted e2fsprogs dosfstools kmod)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -302,6 +317,14 @@ the image."
                         inputs)))
 
            (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
+           ;; It's possible that we need to load nls modules in order to
+           ;; mount the new partition.
+           (if (file-exists? #$modprobe-name)
+               (activate-modprobe #$(%modprobe-wrapper modprobe-name
+                                     linux-module-directory))
+               (format (current-error-port)
+                "WARNING: No modprobe found in ~s.  \
+Loading kernel modules will be impossible.\n" #$modprobe-name))
 
            (let* ((graphs     '#$(match inputs
                                    (((names . _) ...)
@@ -364,7 +387,7 @@ the image."
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-   #:references-graphs inputs))
+   #:references-graphs inputs)))
 
 
 ;;;




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 04:06:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 23:06:25 2018
Received: from localhost ([127.0.0.1]:60934 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqA3V-0004fS-37
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:25 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:45168)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqA3Q-0004el-7r
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:20 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 67A5E33628BE;
 Mon, 26 Feb 2018 05:06:19 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v3 4/6] linux-boot: Load kernel modules only when the hardware
 is present.
Date: Mon, 26 Feb 2018 05:06:07 +0100
Message-Id: <20180226040609.3066-5-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226040609.3066-1-dannym@HIDDEN>
References: <20180226035025.1698-1-dannym@HIDDEN>
 <20180226040609.3066-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 31 +++++++++++++++++++++++++++----
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..6d00ea9be 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -473,6 +473,32 @@ upon error."
     (string-append linux-module-directory "/"
                    (ensure-dot-ko name)))
 
+  (define (load-kernel-modules)
+    "Examine /sys/devices to find out which modules to load and load them."
+    (define enter?
+      (const #t))
+    (define (down! path stat result)
+     ;; Note: modprobe mutates the tree starting with path.
+     (let ((modalias-name (string-append path "/modalias")))
+       (if (file-exists? modalias-name)
+           (let ((modalias
+                 (string-trim-right (call-with-input-file modalias-name
+                                                          read-string)
+                                    #\newline)))
+             (system* "/sbin/modprobe" "-q" "--" modalias))))
+       #t)
+    (define up
+      (const #t))
+    (define skip
+      (const #t))
+    (define leaf
+      (const #t))
+    (define (error name stat errno result)
+      (format (current-error-port) "warning: ~a: ~a~%"
+              name (strerror errno))
+      result)
+    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
+
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
 
@@ -486,10 +512,7 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 46ef055f0..c8a9e4950 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -225,7 +225,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 04:06:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 23:06:22 2018
Received: from localhost ([127.0.0.1]:60931 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqA3R-0004f2-LI
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:22 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:45160)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqA3P-0004eX-AV
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:19 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 2D84E3361FF7;
 Mon, 26 Feb 2018 05:06:18 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v3 3/6] linux-initrd: Add kmod.
Date: Mon, 26 Feb 2018 05:06:06 +0100
Message-Id: <20180226040609.3066-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226040609.3066-1-dannym@HIDDEN>
References: <20180226035025.1698-1-dannym@HIDDEN>
 <20180226040609.3066-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (raw-initrd): Add kmod.
(base-initrd): Add kmod.
(expression->initrd): Add kmod, linux-module-directory.
(flat-linux-module-directory): Add kmod; invoke depmod.
* gnu/build/linux-initrd.scm (build-initrd): Add kmod, linux-module-directory.
---
 gnu/build/linux-initrd.scm  | 12 +++++++++++-
 gnu/system/linux-initrd.scm | 45 ++++++++++++++++++++++++++++++++++-----------
 2 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..6356007df 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init kmod linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,16 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+    ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (when kmod
+      (mkdir-p "sbin")
+      (symlink (string-append kmod "/bin/modprobe") "sbin/modprobe"))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 7170d1c0e..46ef055f0 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -59,6 +59,8 @@
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             kmod
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -94,6 +96,8 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
+                        #:kmod #$kmod
+                        #:linux-module-directory #$linux-module-directory
                         ;; Copy everything INIT refers to into the initrd.
                         #:references-graphs '("closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
@@ -101,7 +105,7 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (gexp->derivation name builder
                     #:references-graphs `(("closure" ,init))))
 
-(define (flat-linux-module-directory linux modules)
+(define (flat-linux-module-directory linux modules kmod)
   "Return a flat directory containing the Linux kernel modules listed in
 MODULES and taken from LINUX."
   (define build-exp
@@ -109,7 +113,7 @@ MODULES and taken from LINUX."
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex)
+          (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
                        (srfi srfi-1)
                        (guix build utils)
                        (gnu build linux-modules))
@@ -138,13 +142,27 @@ MODULES and taken from LINUX."
                       (recursive-module-dependencies modules
                                                      #:lookup-module lookup))))
 
-          (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
+          (define version
+            (match
+             (filter
+              (lambda (name)
+                (not (string-prefix? "." name)))
+              (scandir module-dir))
+             ((item) item)))
+
+          (let ((output (string-append #$output "/lib/modules/" version)))
+            (mkdir-p output)
+            (for-each (lambda (module)
+                        (format #t "copying '~a'...~%" module)
+                        (copy-file module
+                                   (string-append output "/"
+                                                  (basename module))))
+                      (delete-duplicates modules)))
+          (invoke (string-append #$kmod "/bin/depmod") "-a" "-b" #$output
+                  ; -E
+                  "-F" (string-append #$linux "/System.map")
+                  version)
+          #t)))
 
   (computed-file "linux-modules" build-exp))
 
@@ -152,6 +170,7 @@ MODULES and taken from LINUX."
                       #:key
                       (linux linux-libre)
                       (linux-modules '())
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       (helper-packages '())
                       qemu-networking?
@@ -185,7 +204,7 @@ upon error."
          mapped-devices))
 
   (define kodir
-    (flat-linux-module-directory linux linux-modules))
+    (flat-linux-module-directory linux linux-modules kmod))
 
   (expression->initrd
    (with-imported-modules (source-module-closure
@@ -223,6 +242,8 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:kmod kmod
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))
@@ -245,6 +266,7 @@ FILE-SYSTEMS."
 (define* (base-initrd file-systems
                       #:key
                       (linux linux-libre)
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       qemu-networking?
                       volatile-root?
@@ -322,8 +344,9 @@ loaded at boot time in the order in which they appear."
   (raw-initrd file-systems
               #:linux linux
               #:linux-modules linux-modules
+              #:kmod kmod
               #:mapped-devices mapped-devices
-              #:helper-packages helper-packages
+              #:helper-packages (cons kmod helper-packages)
               #:qemu-networking? qemu-networking?
               #:volatile-root? volatile-root?
               #:on-error on-error))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 04:06:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 23:06:21 2018
Received: from localhost ([127.0.0.1]:60928 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqA3R-0004ev-9k
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:21 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:45150)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqA3O-0004eK-26
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:18 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 23D6833628BE;
 Mon, 26 Feb 2018 05:06:17 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v3 2/6] gnu: Add kmod-minimal-static.
Date: Mon, 26 Feb 2018 05:06:05 +0100
Message-Id: <20180226040609.3066-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226040609.3066-1-dannym@HIDDEN>
References: <20180226035025.1698-1-dannym@HIDDEN>
 <20180226040609.3066-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal/static): New variable.
* gnu/packages/patches/kmod-13-module-directory.patch: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/linux.scm                             | 44 ++++++++++++++++++++++
 .../patches/kmod-13-module-directory.patch         | 33 ++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 gnu/packages/patches/kmod-13-module-directory.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 21195f8c1..b1e3c878d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -795,6 +795,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/kiki-makefile.patch			\
   %D%/packages/patches/kiki-missing-includes.patch		\
   %D%/packages/patches/kiki-portability-64bit.patch		\
+  %D%/packages/patches/kmod-13-module-directory.patch		\
   %D%/packages/patches/kmod-module-directory.patch		\
   %D%/packages/patches/kobodeluxe-paths.patch			\
   %D%/packages/patches/kobodeluxe-enemies-pipe-decl.patch	\
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 1f8bf3050..b2e47f79a 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1994,6 +1994,50 @@ from the module-init-tools project.")
                      #t))
                  %standard-phases)))))
 
+(define-public kmod-minimal/static
+  (static-package
+   (package (inherit kmod-minimal)
+    (name "kmod-minimal-static")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (arguments
+     (substitute-keyword-arguments
+       (package-arguments (static-package kmod-minimal))
+       ((#:configure-flags flags ''())
+        `(cons* "--disable-manpages" "--disable-static" "--disable-shared" ,flags))
+       ((#:make-flags flags ''())
+        `(cons* "LDFLAGS=-all-static" ,flags))
+       ((#:phases phases '%standard-phases)
+        `(modify-phases ,phases
+          (delete 'install-license-files)
+          (add-after 'unpack 'patch-kmod
+           (lambda _
+             ;; Reduce size by 200 kiB.
+             (substitute* "tools/kmod.c"
+              (("[&]kmod_cmd_compat_lsmod,") "")
+              (("[&]kmod_cmd_compat_rmmod,") "")
+              (("[&]kmod_cmd_compat_insmod,") "")
+              (("[&]kmod_cmd_compat_modinfo,") ""))
+             #t))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "tools/kmod" bin)
+                (for-each
+                 (lambda (tool)
+                   (symlink "kmod" (string-append bin "/" tool)))
+                 '("modprobe" "depmod"))
+                #t))))))))))
+
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.
   (package
diff --git a/gnu/packages/patches/kmod-13-module-directory.patch b/gnu/packages/patches/kmod-13-module-directory.patch
new file mode 100644
index 000000000..5ff2f8a60
--- /dev/null
+++ b/gnu/packages/patches/kmod-13-module-directory.patch
@@ -0,0 +1,33 @@
+This patch changes libkmod so it honors the 'LINUX_MODULE_DIRECTORY'
+environment variable, rather than looking for modules exclusively in
+/lib/modules.
+
+Patch by Shea Levy and Eelco Dolstra, from Nixpkgs; adjusted to
+use 'LINUX_MODULE_DIRECTORY' rather than 'MODULE_DIR' as the variable
+name.
+
+
+--- kmod-7/libkmod/libkmod.c	2012-03-15 08:19:16.750010226 -0400
++++ kmod-7/libkmod/libkmod.c	2012-04-04 15:21:29.532074313 -0400
+@@ -200,7 +200,7 @@
+ static char *get_kernel_release(const char *dirname)
+ {
+ 	struct utsname u;
+-	char *p;
++	char *p, *dirname_prefix;
+ 
+ 	if (dirname != NULL)
+ 		return path_make_absolute_cwd(dirname);
+@@ -208,7 +208,10 @@
+ 	if (uname(&u) < 0)
+ 		return NULL;
+ 
+-	if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
++	if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
++		dirname_prefix = dirname_default_prefix;
++
++	if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
+ 		return NULL;
+ 
+ 	return p;
+




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 04:06:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 23:06:21 2018
Received: from localhost ([127.0.0.1]:60926 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqA3R-0004et-2K
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:21 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:45138)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqA3L-0004eA-MF
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:18 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 8377B3361672;
 Mon, 26 Feb 2018 05:06:14 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v3 0/6] Load Linux module only when supported hardware is
 present.
Date: Mon, 26 Feb 2018 05:06:03 +0100
Message-Id: <20180226040609.3066-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226035025.1698-1-dannym@HIDDEN>
References: <20180226035025.1698-1-dannym@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Danny Milosavljevic (6):
  gnu: kmod: Split off kmod-minimal.
  gnu: Add kmod-minimal-static.
  linux-initrd: Add kmod.
  linux-boot: Load kernel modules only when the hardware is present.
  vm: Allow qemu-image builder to load Linux kernel modules.
  vm: Make the virtio-blk is uniquely identifyable in /sys.

 gnu/build/linux-boot.scm                           | 31 +++++++-
 gnu/build/linux-initrd.scm                         | 12 ++-
 gnu/build/vm.scm                                   |  2 +-
 gnu/local.mk                                       |  1 +
 gnu/packages/linux.scm                             | 91 ++++++++++++++++++----
 .../patches/kmod-13-module-directory.patch         | 33 ++++++++
 gnu/system/linux-initrd.scm                        | 49 +++++++++---
 gnu/system/vm.scm                                  | 34 ++++++--
 8 files changed, 215 insertions(+), 38 deletions(-)
 create mode 100644 gnu/packages/patches/kmod-13-module-directory.patch





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 04:06:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 23:06:19 2018
Received: from localhost ([127.0.0.1]:60922 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eqA3O-0004eW-QR
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:19 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:45142)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eqA3M-0004eC-Kq
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 23:06:17 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id A05E63361FF7;
 Mon, 26 Feb 2018 05:06:15 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v3 1/6] gnu: kmod: Split off kmod-minimal.
Date: Mon, 26 Feb 2018 05:06:04 +0100
Message-Id: <20180226040609.3066-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226040609.3066-1-dannym@HIDDEN>
References: <20180226035025.1698-1-dannym@HIDDEN>
 <20180226040609.3066-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal): New variable.
(kmod): Modify.
---
 gnu/packages/linux.scm | 49 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 238398e84..1f8bf3050 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1933,8 +1933,35 @@ for systems using the Linux kernel.  This includes commands such as
 to use Linux' inotify mechanism, which allows file accesses to be monitored.")
     (license license:gpl2+)))
 
-(define-public kmod
+(define kmod-minimal
   (package
+    (name "kmod-minimal")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f)) ; FIXME: Investigate test failures
+    (home-page "https://www.kernel.org/")
+    (synopsis "Kernel module tools")
+    (description "Kmod is a set of tools to handle common tasks with Linux
+kernel modules like insert, remove, list, check properties, resolve
+dependencies and aliases.
+
+These tools are designed on top of libkmod, a library that is shipped with
+kmod.  The aim is to be compatible with tools, configurations and indices
+from the module-init-tools project.")
+    (license license:gpl2+))) ; library under lgpl2.1+
+
+(define-public kmod
+  (package (inherit kmod-minimal)
     (name "kmod")
     (version "24")
     (source (origin
@@ -1946,15 +1973,14 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                (base32
                 "15xkkkzvca9flvkm48gkh8y8f13vlm3sl7nz9ydc7b3jy4fqs2v1"))
               (patches (search-patches "kmod-module-directory.patch"))))
-    (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)))
     (inputs
      `(("xz" ,xz)
        ("zlib" ,zlib)))
     (arguments
-     `(#:tests? #f ; FIXME: Investigate test failures
-       #:configure-flags '("--with-xz" "--with-zlib")
+     `(#:configure-flags '("--with-xz" "--with-zlib")
+       #:tests? #f ; FIXME: Investigate test failures
        #:phases (alist-cons-after
                  'install 'install-modprobe&co
                  (lambda* (#:key outputs #:allow-other-keys)
@@ -1964,18 +1990,9 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                                  (symlink "kmod"
                                           (string-append bin "/" tool)))
                                '("insmod" "rmmod" "lsmod" "modprobe"
-                                 "modinfo" "depmod"))))
-                 %standard-phases)))
-    (home-page "https://www.kernel.org/")
-    (synopsis "Kernel module tools")
-    (description "Kmod is a set of tools to handle common tasks with Linux
-kernel modules like insert, remove, list, check properties, resolve
-dependencies and aliases.
-
-These tools are designed on top of libkmod, a library that is shipped with
-kmod.  The aim is to be compatible with tools, configurations and indices
-from the module-init-tools project.")
-    (license license:gpl2+))) ; library under lgpl2.1+
+                                 "modinfo" "depmod"))
+                     #t))
+                 %standard-phases)))))
 
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 03:50:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 22:50:41 2018
Received: from localhost ([127.0.0.1]:60900 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eq9oH-0004Hm-72
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:41 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43594)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eq9oF-0004HP-Jh
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:39 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id A90643361672;
 Mon, 26 Feb 2018 04:50:38 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v2 6/6] vm: Make the virtio-blk is uniquely identifyable in
 /sys.
Date: Mon, 26 Feb 2018 04:50:25 +0100
Message-Id: <20180226035025.1698-7-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226035025.1698-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180226035025.1698-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/vm.scm (load-in-linux-vm): Set virtio-blk pci addr to 0x10.
* gnu/system/vm.scm (common-qemu-options): Set virtio-blk pci addr to 0x10.
---
 gnu/build/vm.scm  | 2 +-
 gnu/system/vm.scm | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index fe003ea45..ebf9e9f6e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -154,7 +154,7 @@ the #:references-graphs parameter of 'derivation'."
                                            builder)
                   (append
                    (if make-disk-image?
-                       `("-device" "virtio-blk,drive=myhd"
+                       `("-device" "virtio-blk-pci,addr=0x10,drive=myhd"
                          "-drive" ,(string-append "if=none,file=" output
                                                   ",format=" disk-image-format
                                                   ",id=myhd"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index c64c9678f..ad48999ee 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -704,7 +704,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
 
      #$@(map virtfs-option shared-fs)
      "-vga std"
-     (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly"
+     "-device" "virtio-blk-pci,addr=0x10,drive=myhd"
+     (format #f "-drive id=myhd,file=~a,if=none,cache=writeback,werror=report,readonly"
              #$image)))
 
 (define* (system-qemu-image/shared-store-script os




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 03:50:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 22:50:41 2018
Received: from localhost ([127.0.0.1]:60898 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eq9oG-0004Hf-Ux
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:41 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43584)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eq9oE-0004HH-K5
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:38 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id AD8A13361FF7;
 Mon, 26 Feb 2018 04:50:37 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v2 5/6] vm: Allow qemu-image builder to load Linux kernel
 modules.
Date: Mon, 26 Feb 2018 04:50:24 +0100
Message-Id: <20180226035025.1698-6-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226035025.1698-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180226035025.1698-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/vm.scm (%modprobe-wrapper): New variable.
(qemu-image): Modify.
---
 gnu/system/vm.scm | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 345cecedd..c64c9678f 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -246,6 +246,17 @@ INPUTS is a list of inputs (as for packages)."
    #:single-file-output? #t
    #:references-graphs inputs))
 
+(define (%modprobe-wrapper modprobe linux-module-directory)
+  ;; Wrapper for the 'modprobe' command that knows where modules live.
+  ;;
+  ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+  ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+  ;; environment variable is not set---hence the need for this wrapper.
+  (program-file "modprobe"
+    #~(begin
+        (setenv "LINUX_MODULE_DIRECTORY" #$linux-module-directory)
+        (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))
+
 (define* (qemu-image #:key
                      (name "qemu-image")
                      (system (%current-system))
@@ -275,6 +286,8 @@ INPUTS is a list of inputs (as for packages).  When COPY-INPUTS? is true, copy
 all of INPUTS into the image being built.  When REGISTER-CLOSURES? is true,
 register INPUTS in the store database of the image so that Guix can be used in
 the image."
+  (let ((modprobe-name (file-append os-drv "/profile/bin/modprobe"))
+        (linux-module-directory (file-append (file-append os-drv "/kernel/lib/modules"))))
   (expression->derivation-in-linux-vm
    name
    (with-imported-modules (source-module-closure '((gnu build bootloader)
@@ -288,7 +301,7 @@ the image."
                       (ice-9 binary-ports))
 
          (let ((inputs
-                '#$(append (list qemu parted e2fsprogs dosfstools)
+                '#$(append (list qemu parted e2fsprogs dosfstools kmod)
                            (map canonical-package
                                 (list sed grep coreutils findutils gawk))
                            (if register-closures? (list guix) '())))
@@ -302,6 +315,14 @@ the image."
                         inputs)))
 
            (set-path-environment-variable "PATH" '("bin" "sbin") inputs)
+           ;; It's possible that we need to load nls modules in order to
+           ;; mount the new partition.
+           (if (file-exists? #$modprobe-name)
+               (activate-modprobe #$(%modprobe-wrapper modprobe-name
+                                     linux-module-directory))
+               (format (current-error-port)
+                "WARNING: No modprobe found in ~s.  \
+Loading kernel modules will be impossible.\n" #$modprobe-name))
 
            (let* ((graphs     '#$(match inputs
                                    (((names . _) ...)
@@ -364,7 +385,7 @@ the image."
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:disk-image-format disk-image-format
-   #:references-graphs inputs))
+   #:references-graphs inputs)))
 
 
 ;;;




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 03:50:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 22:50:40 2018
Received: from localhost ([127.0.0.1]:60896 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eq9oG-0004HY-Nn
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:40 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43576)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eq9oD-0004Gz-IK
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:37 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 9F2FC3361672;
 Mon, 26 Feb 2018 04:50:36 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v2 4/6] linux-boot: Load kernel modules only when the hardware
 is present.
Date: Mon, 26 Feb 2018 04:50:23 +0100
Message-Id: <20180226035025.1698-5-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226035025.1698-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180226035025.1698-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 31 +++++++++++++++++++++++++++----
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..6d00ea9be 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -473,6 +473,32 @@ upon error."
     (string-append linux-module-directory "/"
                    (ensure-dot-ko name)))
 
+  (define (load-kernel-modules)
+    "Examine /sys/devices to find out which modules to load and load them."
+    (define enter?
+      (const #t))
+    (define (down! path stat result)
+     ;; Note: modprobe mutates the tree starting with path.
+     (let ((modalias-name (string-append path "/modalias")))
+       (if (file-exists? modalias-name)
+           (let ((modalias
+                 (string-trim-right (call-with-input-file modalias-name
+                                                          read-string)
+                                    #\newline)))
+             (system* "/sbin/modprobe" "-q" "--" modalias))))
+       #t)
+    (define up
+      (const #t))
+    (define skip
+      (const #t))
+    (define leaf
+      (const #t))
+    (define (error name stat errno result)
+      (format (current-error-port) "warning: ~a: ~a~%"
+              name (strerror errno))
+      result)
+    (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
+
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
 
@@ -486,10 +512,7 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 91e498787..6d130ccac 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -224,7 +224,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 03:50:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 22:50:40 2018
Received: from localhost ([127.0.0.1]:60894 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eq9oG-0004HW-Dw
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:40 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43568)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eq9oC-0004Gp-M2
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:37 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 753EF33628BE;
 Mon, 26 Feb 2018 04:50:35 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v2 3/6] linux-initrd: Add kmod.
Date: Mon, 26 Feb 2018 04:50:22 +0100
Message-Id: <20180226035025.1698-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226035025.1698-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180226035025.1698-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (raw-initrd): Add kmod.
(base-initrd): Add kmod.
(expression->initrd): Add kmod, linux-module-directory.
(flat-linux-module-directory): Add kmod; invoke depmod.
* gnu/build/linux-initrd.scm (build-initrd): Add kmod, linux-module-directory.
---
 gnu/build/linux-initrd.scm  | 12 +++++++++++-
 gnu/system/linux-initrd.scm | 44 +++++++++++++++++++++++++++++++++-----------
 2 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..6356007df 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init kmod linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,16 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+    ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (when kmod
+      (mkdir-p "sbin")
+      (symlink (string-append kmod "/bin/modprobe") "sbin/modprobe"))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 7170d1c0e..91e498787 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -59,6 +59,8 @@
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             kmod
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -94,6 +96,8 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
+                        #:kmod #$kmod
+                        #:linux-module-directory #$linux-module-directory
                         ;; Copy everything INIT refers to into the initrd.
                         #:references-graphs '("closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
@@ -101,7 +105,7 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (gexp->derivation name builder
                     #:references-graphs `(("closure" ,init))))
 
-(define (flat-linux-module-directory linux modules)
+(define (flat-linux-module-directory linux modules kmod)
   "Return a flat directory containing the Linux kernel modules listed in
 MODULES and taken from LINUX."
   (define build-exp
@@ -109,7 +113,7 @@ MODULES and taken from LINUX."
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex)
+          (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
                        (srfi srfi-1)
                        (guix build utils)
                        (gnu build linux-modules))
@@ -138,13 +142,26 @@ MODULES and taken from LINUX."
                       (recursive-module-dependencies modules
                                                      #:lookup-module lookup))))
 
-          (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
+          (define version
+            (car
+             (filter
+              (lambda (name)
+                (not (string-prefix? "." name)))
+              (scandir module-dir))))
+
+          (let ((output (string-append #$output "/lib/modules/" version)))
+            (mkdir-p output)
+            (for-each (lambda (module)
+                        (format #t "copying '~a'...~%" module)
+                        (copy-file module
+                                   (string-append output "/"
+                                                  (basename module))))
+                      (delete-duplicates modules)))
+          (invoke (string-append #$kmod "/bin/depmod") "-a" "-b" #$output
+                  ; -E
+                  "-F" (string-append #$linux "/System.map")
+                  version)
+          #t)))
 
   (computed-file "linux-modules" build-exp))
 
@@ -152,6 +169,7 @@ MODULES and taken from LINUX."
                       #:key
                       (linux linux-libre)
                       (linux-modules '())
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       (helper-packages '())
                       qemu-networking?
@@ -185,7 +203,7 @@ upon error."
          mapped-devices))
 
   (define kodir
-    (flat-linux-module-directory linux linux-modules))
+    (flat-linux-module-directory linux linux-modules kmod))
 
   (expression->initrd
    (with-imported-modules (source-module-closure
@@ -223,6 +241,8 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:kmod kmod
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))
@@ -245,6 +265,7 @@ FILE-SYSTEMS."
 (define* (base-initrd file-systems
                       #:key
                       (linux linux-libre)
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       qemu-networking?
                       volatile-root?
@@ -322,8 +343,9 @@ loaded at boot time in the order in which they appear."
   (raw-initrd file-systems
               #:linux linux
               #:linux-modules linux-modules
+              #:kmod kmod
               #:mapped-devices mapped-devices
-              #:helper-packages helper-packages
+              #:helper-packages (cons kmod helper-packages)
               #:qemu-networking? qemu-networking?
               #:volatile-root? volatile-root?
               #:on-error on-error))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 03:50:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 22:50:37 2018
Received: from localhost ([127.0.0.1]:60889 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eq9oD-0004Gt-2S
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:37 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43534)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eq9o8-0004GM-ED
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:35 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 884E63361672;
 Mon, 26 Feb 2018 04:50:30 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v2 0/6] Load Linux module only when supported hardware is
 present.
Date: Mon, 26 Feb 2018 04:50:19 +0100
Message-Id: <20180226035025.1698-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180225114557.816-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Danny Milosavljevic (6):
  gnu: kmod: Split off kmod-minimal.
  gnu: Add kmod-minimal-static.
  linux-initrd: Add kmod.
  linux-boot: Load kernel modules only when the hardware is present.
  vm: Allow qemu-image builder to load Linux kernel modules.
  vm: Make the virtio-blk is uniquely identifyable in /sys.

 gnu/build/linux-boot.scm                           | 31 +++++++-
 gnu/build/linux-initrd.scm                         | 12 ++-
 gnu/build/vm.scm                                   |  2 +-
 gnu/local.mk                                       |  1 +
 gnu/packages/linux.scm                             | 91 ++++++++++++++++++----
 .../patches/kmod-13-module-directory.patch         | 33 ++++++++
 gnu/system/linux-initrd.scm                        | 48 +++++++++---
 gnu/system/vm.scm                                  | 28 ++++++-
 8 files changed, 210 insertions(+), 36 deletions(-)
 create mode 100644 gnu/packages/patches/kmod-13-module-directory.patch





Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 03:50:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 22:50:37 2018
Received: from localhost ([127.0.0.1]:60886 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eq9oC-0004Gq-OA
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:37 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43558)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eq9oB-0004GY-2W
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:35 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 0668A3361FF7;
 Mon, 26 Feb 2018 04:50:33 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v2 2/6] gnu: Add kmod-minimal-static.
Date: Mon, 26 Feb 2018 04:50:21 +0100
Message-Id: <20180226035025.1698-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226035025.1698-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180226035025.1698-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal/static): New variable.
* gnu/packages/patches/kmod-13-module-directory.patch: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/linux.scm                             | 44 ++++++++++++++++++++++
 .../patches/kmod-13-module-directory.patch         | 33 ++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 gnu/packages/patches/kmod-13-module-directory.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 21195f8c1..b1e3c878d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -795,6 +795,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/kiki-makefile.patch			\
   %D%/packages/patches/kiki-missing-includes.patch		\
   %D%/packages/patches/kiki-portability-64bit.patch		\
+  %D%/packages/patches/kmod-13-module-directory.patch		\
   %D%/packages/patches/kmod-module-directory.patch		\
   %D%/packages/patches/kobodeluxe-paths.patch			\
   %D%/packages/patches/kobodeluxe-enemies-pipe-decl.patch	\
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 1f8bf3050..b2e47f79a 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1994,6 +1994,50 @@ from the module-init-tools project.")
                      #t))
                  %standard-phases)))))
 
+(define-public kmod-minimal/static
+  (static-package
+   (package (inherit kmod-minimal)
+    (name "kmod-minimal-static")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (arguments
+     (substitute-keyword-arguments
+       (package-arguments (static-package kmod-minimal))
+       ((#:configure-flags flags ''())
+        `(cons* "--disable-manpages" "--disable-static" "--disable-shared" ,flags))
+       ((#:make-flags flags ''())
+        `(cons* "LDFLAGS=-all-static" ,flags))
+       ((#:phases phases '%standard-phases)
+        `(modify-phases ,phases
+          (delete 'install-license-files)
+          (add-after 'unpack 'patch-kmod
+           (lambda _
+             ;; Reduce size by 200 kiB.
+             (substitute* "tools/kmod.c"
+              (("[&]kmod_cmd_compat_lsmod,") "")
+              (("[&]kmod_cmd_compat_rmmod,") "")
+              (("[&]kmod_cmd_compat_insmod,") "")
+              (("[&]kmod_cmd_compat_modinfo,") ""))
+             #t))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "tools/kmod" bin)
+                (for-each
+                 (lambda (tool)
+                   (symlink "kmod" (string-append bin "/" tool)))
+                 '("modprobe" "depmod"))
+                #t))))))))))
+
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.
   (package
diff --git a/gnu/packages/patches/kmod-13-module-directory.patch b/gnu/packages/patches/kmod-13-module-directory.patch
new file mode 100644
index 000000000..5ff2f8a60
--- /dev/null
+++ b/gnu/packages/patches/kmod-13-module-directory.patch
@@ -0,0 +1,33 @@
+This patch changes libkmod so it honors the 'LINUX_MODULE_DIRECTORY'
+environment variable, rather than looking for modules exclusively in
+/lib/modules.
+
+Patch by Shea Levy and Eelco Dolstra, from Nixpkgs; adjusted to
+use 'LINUX_MODULE_DIRECTORY' rather than 'MODULE_DIR' as the variable
+name.
+
+
+--- kmod-7/libkmod/libkmod.c	2012-03-15 08:19:16.750010226 -0400
++++ kmod-7/libkmod/libkmod.c	2012-04-04 15:21:29.532074313 -0400
+@@ -200,7 +200,7 @@
+ static char *get_kernel_release(const char *dirname)
+ {
+ 	struct utsname u;
+-	char *p;
++	char *p, *dirname_prefix;
+ 
+ 	if (dirname != NULL)
+ 		return path_make_absolute_cwd(dirname);
+@@ -208,7 +208,10 @@
+ 	if (uname(&u) < 0)
+ 		return NULL;
+ 
+-	if (asprintf(&p, "%s/%s", dirname_default_prefix, u.release) < 0)
++	if ((dirname_prefix = getenv("LINUX_MODULE_DIRECTORY")) == NULL)
++		dirname_prefix = dirname_default_prefix;
++
++	if (asprintf(&p, "%s/%s", dirname_prefix, u.release) < 0)
+ 		return NULL;
+ 
+ 	return p;
+




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 03:50:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 22:50:34 2018
Received: from localhost ([127.0.0.1]:60883 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eq9oA-0004GV-G3
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:34 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:43548)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1eq9o8-0004GO-Qr
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 22:50:33 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id BD84D3362AB9;
 Mon, 26 Feb 2018 04:50:31 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH v2 1/6] gnu: kmod: Split off kmod-minimal.
Date: Mon, 26 Feb 2018 04:50:20 +0100
Message-Id: <20180226035025.1698-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180226035025.1698-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180226035025.1698-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal): New variable.
(kmod): Modify.
---
 gnu/packages/linux.scm | 49 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 238398e84..1f8bf3050 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1933,8 +1933,35 @@ for systems using the Linux kernel.  This includes commands such as
 to use Linux' inotify mechanism, which allows file accesses to be monitored.")
     (license license:gpl2+)))
 
-(define-public kmod
+(define kmod-minimal
   (package
+    (name "kmod-minimal")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f)) ; FIXME: Investigate test failures
+    (home-page "https://www.kernel.org/")
+    (synopsis "Kernel module tools")
+    (description "Kmod is a set of tools to handle common tasks with Linux
+kernel modules like insert, remove, list, check properties, resolve
+dependencies and aliases.
+
+These tools are designed on top of libkmod, a library that is shipped with
+kmod.  The aim is to be compatible with tools, configurations and indices
+from the module-init-tools project.")
+    (license license:gpl2+))) ; library under lgpl2.1+
+
+(define-public kmod
+  (package (inherit kmod-minimal)
     (name "kmod")
     (version "24")
     (source (origin
@@ -1946,15 +1973,14 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                (base32
                 "15xkkkzvca9flvkm48gkh8y8f13vlm3sl7nz9ydc7b3jy4fqs2v1"))
               (patches (search-patches "kmod-module-directory.patch"))))
-    (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)))
     (inputs
      `(("xz" ,xz)
        ("zlib" ,zlib)))
     (arguments
-     `(#:tests? #f ; FIXME: Investigate test failures
-       #:configure-flags '("--with-xz" "--with-zlib")
+     `(#:configure-flags '("--with-xz" "--with-zlib")
+       #:tests? #f ; FIXME: Investigate test failures
        #:phases (alist-cons-after
                  'install 'install-modprobe&co
                  (lambda* (#:key outputs #:allow-other-keys)
@@ -1964,18 +1990,9 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                                  (symlink "kmod"
                                           (string-append bin "/" tool)))
                                '("insmod" "rmmod" "lsmod" "modprobe"
-                                 "modinfo" "depmod"))))
-                 %standard-phases)))
-    (home-page "https://www.kernel.org/")
-    (synopsis "Kernel module tools")
-    (description "Kmod is a set of tools to handle common tasks with Linux
-kernel modules like insert, remove, list, check properties, resolve
-dependencies and aliases.
-
-These tools are designed on top of libkmod, a library that is shipped with
-kmod.  The aim is to be compatible with tools, configurations and indices
-from the module-init-tools project.")
-    (license license:gpl2+))) ; library under lgpl2.1+
+                                 "modinfo" "depmod"))
+                     #t))
+                 %standard-phases)))))
 
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 26 Feb 2018 01:10:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 20:10:18 2018
Received: from localhost ([127.0.0.1]:60798 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eq7J4-0000e5-3C
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 20:10:18 -0500
Received: from out5-smtp.messagingengine.com ([66.111.4.29]:49367)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mbakke@HIDDEN>) id 1eq7J2-0000dw-Ox
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 20:10:17 -0500
Received: from compute5.internal (compute5.nyi.internal [10.202.2.45])
 by mailout.nyi.internal (Postfix) with ESMTP id 8399320D79;
 Sun, 25 Feb 2018 20:10:16 -0500 (EST)
Received: from frontend2 ([10.202.2.161])
 by compute5.internal (MEProxy); Sun, 25 Feb 2018 20:10:16 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h=
 content-type:date:from:in-reply-to:message-id:mime-version
 :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=
 fm2; bh=JZnlXr5pUawNBgTEQ2/mTtgNUVAwVHJFENtQyLoYgrE=; b=i24S8jEQ
 8t/58HRl8Sg4E73MdjrKlyiaBmmZtQZ10ffChwRBgEPaYHeqor+SDLGQ9hGyLF9p
 10g5jc/DIq8d8AznHPJjhF5CQc8jT71b7ZOiiWfe+lZuMgxGGt//MNPPOP8G0xnI
 Gbr9l0YBhbpVx3RgdtsJlvgL4wq80i7JHCrjhFyTOYiOjOyQECGq7y+M8VNlfqEV
 T/jBxQkll1ctVcxnvSxqEqiEb+ZnUcpBu3pcD3kRfYERwqrfqHs3PBq6YW3UvZGj
 S3AixT0nw4M/VNOtG4BesE8F9lDSeFiGLzpgBypNXXN40IpoQCjzt7HnTp6qS7gX
 lZ6tt/MSq1GXnQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=content-type:date:from:in-reply-to
 :message-id:mime-version:references:subject:to:x-me-sender
 :x-me-sender:x-sasl-enc; s=fm2; bh=JZnlXr5pUawNBgTEQ2/mTtgNUVAwV
 HJFENtQyLoYgrE=; b=hE+tmTMQ4oM4lt/HggTg5+xlrASestzl4v+KKST5T8I3K
 U0SZR4qIbq1zieQAW+NUSWedXdgelUoBA/Cn+5bLXUo9wWOqAmkEyOGMwRxUYeSj
 FC3ESVjlR68wKHT/WvK3expOxG9aVLa9afFdX54ZlUlIEp4DphAfI6KES/QhYvZ4
 S33CRad8CgKXYFmgaEEUqCR3udlG7rZr5koD8px2pqcD6+yNgpTW3AqpDSHwilBl
 MbRmLzYyEyHGiwUTQfffi65yK/I0szOBdid2Qjsfw1glc5CmORlU49fr3SCxyrwn
 Zeom4ALkwhuSe06vlnl/91BjopxZWdVB3ISP+ynSA==
X-ME-Sender: <xms:eF6TWkTkeXX7inJXfJgqYRFnx9XtimvgYJ484TIkgQh7ctwDt0EZBg>
Received: from localhost (cm-84.214.173.174.getinternet.no [84.214.173.174])
 by mail.messagingengine.com (Postfix) with ESMTPA id 23BDD24651;
 Sun, 25 Feb 2018 20:10:16 -0500 (EST)
From: Marius Bakke <mbakke@HIDDEN>
To: Danny Milosavljevic <dannym@HIDDEN>, 30604 <at> debbugs.gnu.org
Subject: Re: [bug#30604] [PATCH 1/4] gnu: kmod: Split off kmod-minimal.
In-Reply-To: <20180225114816.869-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180225114816.869-1-dannym@HIDDEN>
User-Agent: Notmuch/0.26 (https://notmuchmail.org) Emacs/25.3.1
 (x86_64-pc-linux-gnu)
Date: Mon, 26 Feb 2018 02:10:14 +0100
Message-ID: <87h8q4wo7d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Danny Milosavljevic <dannym@HIDDEN> writes:

> * gnu/packages/linux.scm (kmod-minimal): New variable.
> (kmod): Modify.
> ---
>  gnu/packages/linux.scm | 49 +++++++++++++++++++++++++++++++++-----------=
-----
>  1 file changed, 33 insertions(+), 16 deletions(-)
>
> diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
> index 238398e84..1f8bf3050 100644
> --- a/gnu/packages/linux.scm
> +++ b/gnu/packages/linux.scm
> @@ -1933,8 +1933,35 @@ for systems using the Linux kernel.  This includes=
 commands such as
>  to use Linux' inotify mechanism, which allows file accesses to be monito=
red.")
>      (license license:gpl2+)))
>=20=20
> -(define-public kmod
> +(define kmod-minimal
>    (package
> +    (name "kmod-minimal")
> +    (version "13")

Why this old version?

> +    (source (origin
> +              (method url-fetch)
> +              (uri
> +               (string-append "mirror://kernel.org/linux/utils/kernel/km=
od/"
> +                              "kmod-" version ".tar.xz"))
> +              (sha256
> +               (base32
> +                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
> +              (patches (search-patches "kmod-13-module-directory.patch")=
)))

This patch seems to be missing.

> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:tests? #f)) ; FIXME: Investigate test failures
> +    (home-page "https://www.kernel.org/")
> +    (synopsis "Kernel module tools")
> +    (description "Kmod is a set of tools to handle common tasks with Lin=
ux
> +kernel modules like insert, remove, list, check properties, resolve
> +dependencies and aliases.
> +
> +These tools are designed on top of libkmod, a library that is shipped wi=
th
> +kmod.  The aim is to be compatible with tools, configurations and indices
> +from the module-init-tools project.")
> +    (license license:gpl2+))) ; library under lgpl2.1+
> +
> +(define-public kmod
> +  (package (inherit kmod-minimal)
>      (name "kmod")
>      (version "24")
>      (source (origin
> @@ -1946,15 +1973,14 @@ to use Linux' inotify mechanism, which allows fil=
e accesses to be monitored.")
>                 (base32
>                  "15xkkkzvca9flvkm48gkh8y8f13vlm3sl7nz9ydc7b3jy4fqs2v1"))
>                (patches (search-patches "kmod-module-directory.patch"))))
> -    (build-system gnu-build-system)
>      (native-inputs
>       `(("pkg-config" ,pkg-config)))
>      (inputs
>       `(("xz" ,xz)
>         ("zlib" ,zlib)))
>      (arguments
> -     `(#:tests? #f ; FIXME: Investigate test failures
> -       #:configure-flags '("--with-xz" "--with-zlib")
> +     `(#:configure-flags '("--with-xz" "--with-zlib")
> +       #:tests? #f ; FIXME: Investigate test failures
>         #:phases (alist-cons-after
>                   'install 'install-modprobe&co
>                   (lambda* (#:key outputs #:allow-other-keys)
> @@ -1964,18 +1990,9 @@ to use Linux' inotify mechanism, which allows file=
 accesses to be monitored.")
>                                   (symlink "kmod"
>                                            (string-append bin "/" tool)))
>                                 '("insmod" "rmmod" "lsmod" "modprobe"
> -                                 "modinfo" "depmod"))))
> -                 %standard-phases)))
> -    (home-page "https://www.kernel.org/")
> -    (synopsis "Kernel module tools")
> -    (description "Kmod is a set of tools to handle common tasks with Lin=
ux
> -kernel modules like insert, remove, list, check properties, resolve
> -dependencies and aliases.
> -
> -These tools are designed on top of libkmod, a library that is shipped wi=
th
> -kmod.  The aim is to be compatible with tools, configurations and indices
> -from the module-init-tools project.")
> -    (license license:gpl2+))) ; library under lgpl2.1+
> +                                 "modinfo" "depmod"))
> +                     #t))
> +                 %standard-phases)))))
>=20=20
>  (define-public eudev
>    ;; The post-systemd fork, maintained by Gentoo.

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAlqTXnYACgkQoqBt8qM6
VPpGtAf9HdKJjuRHFJxIT76qB3Yjub3mj5c3LRNhSA1vPnaPEMOXVDDTlq4t8XcR
K0oaixbKYcSvSmHJ+Sp17jy+SYpeA1WGGpCxKVsBl8FCKhEYh2ztbgRUtMwjXZyF
ZjO15dLd2SU40hWXVabKDeDTZyD9whMZMrbKAmu1OelG9lSPJw7fWfSU8UnZeXJg
TflXbAN+9Ikm5ey4kxY/v+IjE60aWd5CRlUqcWVzKzZ7bSmU81r+paUWSe+11V7n
7LoBFm/MwQM3JFkglmSkWsDv/9eQwfm6CI6yV15qChL+MXuSFKzuJNKeETd7TvV9
P8zks8IDY7CA9I3PwJXPEZRuwA7QYw==
=YgmH
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 25 Feb 2018 15:07:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 10:07:58 2018
Received: from localhost ([127.0.0.1]:60535 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1epxu9-0001yP-WD
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 10:07:58 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:46008)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1epxu8-0001yH-8G
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 10:07:56 -0500
Received: from localhost (77.118.165.54.wireless.dyn.drei.com [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 9A68E33606CB;
 Sun, 25 Feb 2018 16:07:54 +0100 (CET)
Date: Sun, 25 Feb 2018 16:07:50 +0100
From: Danny Milosavljevic <dannym@HIDDEN>
To: Mathieu Othacehe <m.othacehe@HIDDEN>
Subject: Re: [bug#30604] [PATCH 3/4] linux-initrd: Add kmod.
Message-ID: <20180225160750.46bf5b50@HIDDEN>
In-Reply-To: <87vaelf9ln.fsf@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180225114816.869-1-dannym@HIDDEN>
 <20180225114816.869-3-dannym@HIDDEN>
 <87vaelf9ln.fsf@HIDDEN>
X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Hi Mathieu,

thanks for the review.

On Sun, 25 Feb 2018 15:05:24 +0100
Mathieu Othacehe <m.othacehe@HIDDEN> wrote:

> > +                  ; -E  
> 
> Why is this commented ?

Because it's an option for specifying the location of "Module.symvers" - and
I don't know whether guix uses it (probably not).  If one doesn't specify an
option, depmod will default to the running kernel - which is not what we want.

I should elaborate in the comment that, if we start using Module.symvers, we
MUST pass "-E" there.  Maybe better to even just check for the file existence
and add it right now, otherwise we might forget later.  What do you think?




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 25 Feb 2018 14:05:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 09:05:35 2018
Received: from localhost ([127.0.0.1]:59541 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1epwvm-0000LL-S9
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 09:05:35 -0500
Received: from mail-wm0-f41.google.com ([74.125.82.41]:33180)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <m.othacehe@HIDDEN>) id 1epwvk-0000Ky-6R
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 09:05:32 -0500
Received: by mail-wm0-f41.google.com with SMTP id s206so13397552wme.0
 for <30604 <at> debbugs.gnu.org>; Sun, 25 Feb 2018 06:05:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=references:user-agent:from:to:cc:subject:in-reply-to:date
 :message-id:mime-version;
 bh=eE8g9rlXxJtiMzrcCfh8ctgXBw/SVaPMsMpJ+nRtbAw=;
 b=pW0SFX+4WL/WOab00IB+iC5SmuJ3IWWDpKAr4jdLVEFwBZ0kzb+HCLj69WgWfC2r+O
 7dJ+o92bNkPE3BOiNXrpbCBdfYzetyqLOojlp4k1VWEwzIwwVhwHtxC01FYdRDbdWPGo
 jy5qyG+ivvEtz1bF+oP2QrVmP5xN29sCf6qJW6FqEBoicruE9KsbhMMqYrCIuuXq9CdX
 noGUsddPISy/7HHwpclsCAXE5SUw5vmBdS1sZiAkD1FhAPtF9ed38AE9L2hbajEA+7fT
 48KyGtiw2X2l6hsFjyvAi82hMbt/3mmFjRfS22+AJjCTV6Gz79RLnuY+1f9cbgkJNpYK
 Sijw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:references:user-agent:from:to:cc:subject
 :in-reply-to:date:message-id:mime-version;
 bh=eE8g9rlXxJtiMzrcCfh8ctgXBw/SVaPMsMpJ+nRtbAw=;
 b=eMNNxTuWCUEo1TGlmUyXeYC0tRAXDqWQ7829f8fs7E7kufWE0whSDS7OeGSuu/QqP2
 24OKs2y9LSueGmkHtYfzc+7xpwS2cuVxNpwXtVcD81hfTbAGvjG+0+ymKAusKAzmNTqj
 HPAZLTwFlvOLquTSikuYu0spcbxT7LIyKXKzBQsN5jCC7ZXgKI5P4pUVRiDkP6RnJEBd
 RVxy3ssKyb6sKr/ULoUp/9ELpEjf996ozxE2R2XWkIeSmZnjtTPyzO9d1b7g/x69nSCe
 0taFK9l2iZW6qwCSxYzQR2un59L16BJbQ3IsyQCDvGcYrWbOyFncC8OaivrmWDzPIblc
 n+eA==
X-Gm-Message-State: APf1xPDA42j8JyOM/J1GKYWtfAeYR206BILzN/ElFm9qXlYhkd3vtbRk
 g2KLWotBqJ2TgVnCu5sBiBbkHA==
X-Google-Smtp-Source: AH8x22688oTEM6HfMRXyaFrBcgT82T3TW6DAOBqgcl6IWN3em2LeJNc47qcDMYQ67dAaWI15l8JxXA==
X-Received: by 10.28.0.88 with SMTP id 85mr5817354wma.63.1519567526003;
 Sun, 25 Feb 2018 06:05:26 -0800 (PST)
Received: from cervin ([78.192.96.126])
 by smtp.gmail.com with ESMTPSA id q14sm5316150wre.83.2018.02.25.06.05.25
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Sun, 25 Feb 2018 06:05:25 -0800 (PST)
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180225114816.869-1-dannym@HIDDEN>
 <20180225114816.869-3-dannym@HIDDEN>
User-agent: mu4e 0.9.18; emacs 25.3.1
From: Mathieu Othacehe <m.othacehe@HIDDEN>
To: Danny Milosavljevic <dannym@HIDDEN>
Subject: Re: [bug#30604] [PATCH 3/4] linux-initrd: Add kmod.
In-reply-to: <20180225114816.869-3-dannym@HIDDEN>
Date: Sun, 25 Feb 2018 15:05:24 +0100
Message-ID: <87vaelf9ln.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 30604
Cc: 30604 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)


Hi Danny,

Here are some small remarks,

> +    ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
> +    (if kmod
> +        (begin

You can use "when" to avoid "begin".

> +          (define version
> +            (car

Prefer match to car/cdr use.

> +             (filter
> +              (lambda (name)
> +                (not (string-prefix? "." name)))
> +              (scandir module-dir))))
> +
> +          (display "VERSION")
> +          (display version)
> +          (newline)

(format #t "VERSION" ~a~%" version) would be shorter.

> +                  ; -E

Why is this commented ?

> +                  "-F" (string-append #$linux "/System.map")
> +                  version)
> +          #t)))
>  

Thanks,

Mathieu




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 25 Feb 2018 11:48:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 06:48:40 2018
Received: from localhost ([127.0.0.1]:59486 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1epunI-0003g2-2v
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:48:40 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:58702)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1epunE-0003fj-Bl
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:48:36 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 286F2336028A;
 Sun, 25 Feb 2018 12:48:35 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH 4/4] linux-boot: Load kernel modules only when the hardware is
 present.
Date: Sun, 25 Feb 2018 12:48:16 +0100
Message-Id: <20180225114816.869-4-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180225114816.869-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180225114816.869-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 24 ++++++++++++++++++++----
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..65c91c50f 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -473,6 +473,25 @@ upon error."
     (string-append linux-module-directory "/"
                    (ensure-dot-ko name)))
 
+  (define (load-kernel-modules)
+    (define enter?
+      (const #t))
+    (file-system-fold
+     enter?
+     ;; This is the Leaf handler.  It tries to modprobe all the modaliases.
+     (lambda (path stat result) ; leaf
+       (let ((modalias-name (string-append path "/modalias")))
+         (if (file-exists? modalias-name)
+             (let ((modalias (call-with-input-file modalias-name read-string)))
+               (if (not (string=? modalias ""))
+                   (system* "/sbin/modprobe" "-q" "--" modalias))))))
+     (const #t) ; down
+     (const #t) ; up
+     (const #f) ; skip
+     (const #f) ; error
+     #f ; init
+     "/sys/devices"))
+
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
 
@@ -486,10 +505,7 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 93089a869..573f4a324 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -228,7 +228,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 25 Feb 2018 11:48:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 06:48:40 2018
Received: from localhost ([127.0.0.1]:59484 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1epunH-0003fz-Ol
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:48:40 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:58694)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1epunD-0003fc-34
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:48:35 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 03F9D3360249;
 Sun, 25 Feb 2018 12:48:33 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH 3/4] linux-initrd: Add kmod.
Date: Sun, 25 Feb 2018 12:48:15 +0100
Message-Id: <20180225114816.869-3-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180225114816.869-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180225114816.869-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/system/linux-initrd.scm (raw-initrd): Add kmod.
(base-initrd): Add kmod.
(expression->initrd): Add kmod, linux-module-directory.
(flat-linux-module-directory): Add kmod; invoke depmod.
* gnu/build/linux-initrd.scm (build-initrd): Add kmod, linux-module-directory.
---
 gnu/build/linux-initrd.scm  | 13 +++++++++++-
 gnu/system/linux-initrd.scm | 48 ++++++++++++++++++++++++++++++++++-----------
 2 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index c65b5aacf..52cc180b4 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -107,7 +107,7 @@ This is similar to what 'compiled-file-name' in (system base compile) does."
 
 (define* (build-initrd output
                        #:key
-                       guile init
+                       guile init kmod linux-module-directory
                        (references-graphs '())
                        (gzip "gzip"))
   "Write an initial RAM disk (initrd) to OUTPUT.  The initrd starts the script
@@ -131,6 +131,17 @@ REFERENCES-GRAPHS."
     (symlink (string-append guile "/bin/guile") "proc/self/exe")
     (readlink "proc/self/exe")
 
+    ;; Make modprobe available as /sbin/modprobe so the kernel finds it.
+    (if kmod
+        (begin
+          (mkdir-p "sbin")
+          (symlink (string-append kmod "/bin/modprobe") "sbin/modprobe")))
+
+    ;; Make modules available as /lib/modules so modprobe finds them.
+    (mkdir-p "lib")
+    (symlink (string-append linux-module-directory "/lib/modules")
+             "lib/modules")
+
     ;; Reset the timestamps of all the files that will make it in the initrd.
     (for-each (lambda (file)
                 (unless (eq? 'symlink (stat:type (lstat file)))
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 7170d1c0e..93089a869 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -59,6 +59,8 @@
                              #:key
                              (guile %guile-static-stripped)
                              (gzip gzip)
+                             kmod
+                             linux-module-directory
                              (name "guile-initrd")
                              (system (%current-system)))
   "Return a derivation that builds a Linux initrd (a gzipped cpio archive)
@@ -94,6 +96,8 @@ the derivations referenced by EXP are automatically copied to the initrd."
           (build-initrd (string-append #$output "/initrd")
                         #:guile #$guile
                         #:init #$init
+                        #:kmod #$kmod
+                        #:linux-module-directory #$linux-module-directory
                         ;; Copy everything INIT refers to into the initrd.
                         #:references-graphs '("closure")
                         #:gzip (string-append #$gzip "/bin/gzip")))))
@@ -101,7 +105,7 @@ the derivations referenced by EXP are automatically copied to the initrd."
   (gexp->derivation name builder
                     #:references-graphs `(("closure" ,init))))
 
-(define (flat-linux-module-directory linux modules)
+(define (flat-linux-module-directory linux modules kmod)
   "Return a flat directory containing the Linux kernel modules listed in
 MODULES and taken from LINUX."
   (define build-exp
@@ -109,7 +113,7 @@ MODULES and taken from LINUX."
                             '((guix build utils)
                               (gnu build linux-modules)))
       #~(begin
-          (use-modules (ice-9 match) (ice-9 regex)
+          (use-modules (ice-9 match) (ice-9 regex) (ice-9 ftw)
                        (srfi srfi-1)
                        (guix build utils)
                        (gnu build linux-modules))
@@ -138,13 +142,30 @@ MODULES and taken from LINUX."
                       (recursive-module-dependencies modules
                                                      #:lookup-module lookup))))
 
-          (mkdir #$output)
-          (for-each (lambda (module)
-                      (format #t "copying '~a'...~%" module)
-                      (copy-file module
-                                 (string-append #$output "/"
-                                                (basename module))))
-                    (delete-duplicates modules)))))
+          (define version
+            (car
+             (filter
+              (lambda (name)
+                (not (string-prefix? "." name)))
+              (scandir module-dir))))
+
+          (display "VERSION")
+          (display version)
+          (newline)
+
+          (let ((output (string-append #$output "/lib/modules/" version)))
+            (mkdir-p output)
+            (for-each (lambda (module)
+                        (format #t "copying '~a'...~%" module)
+                        (copy-file module
+                                   (string-append output "/"
+                                                  (basename module))))
+                      (delete-duplicates modules)))
+          (invoke (string-append #$kmod "/bin/depmod") "-a" "-b" #$output
+                  ; -E
+                  "-F" (string-append #$linux "/System.map")
+                  version)
+          #t)))
 
   (computed-file "linux-modules" build-exp))
 
@@ -152,6 +173,7 @@ MODULES and taken from LINUX."
                       #:key
                       (linux linux-libre)
                       (linux-modules '())
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       (helper-packages '())
                       qemu-networking?
@@ -185,7 +207,7 @@ upon error."
          mapped-devices))
 
   (define kodir
-    (flat-linux-module-directory linux linux-modules))
+    (flat-linux-module-directory linux linux-modules kmod))
 
   (expression->initrd
    (with-imported-modules (source-module-closure
@@ -223,6 +245,8 @@ upon error."
                       #:qemu-guest-networking? #$qemu-networking?
                       #:volatile-root? '#$volatile-root?
                       #:on-error '#$on-error)))
+   #:kmod kmod
+   #:linux-module-directory kodir
    #:name "raw-initrd"))
 
 (define* (file-system-packages file-systems #:key (volatile-root? #f))
@@ -245,6 +269,7 @@ FILE-SYSTEMS."
 (define* (base-initrd file-systems
                       #:key
                       (linux linux-libre)
+                      (kmod kmod-minimal/static)
                       (mapped-devices '())
                       qemu-networking?
                       volatile-root?
@@ -322,8 +347,9 @@ loaded at boot time in the order in which they appear."
   (raw-initrd file-systems
               #:linux linux
               #:linux-modules linux-modules
+              #:kmod kmod
               #:mapped-devices mapped-devices
-              #:helper-packages helper-packages
+              #:helper-packages (cons kmod helper-packages)
               #:qemu-networking? qemu-networking?
               #:volatile-root? volatile-root?
               #:on-error on-error))




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 25 Feb 2018 11:48:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 06:48:36 2018
Received: from localhost ([127.0.0.1]:59481 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1epunE-0003fk-Fu
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:48:36 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:58684)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1epunB-0003fN-9G
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:48:33 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 39A63336028A;
 Sun, 25 Feb 2018 12:48:32 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH 2/4] gnu: Add kmod-minimal-static.
Date: Sun, 25 Feb 2018 12:48:14 +0100
Message-Id: <20180225114816.869-2-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180225114816.869-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
 <20180225114816.869-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal/static): New variable.
---
 gnu/packages/linux.scm | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 1f8bf3050..b2e47f79a 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1994,6 +1994,50 @@ from the module-init-tools project.")
                      #t))
                  %standard-phases)))))
 
+(define-public kmod-minimal/static
+  (static-package
+   (package (inherit kmod-minimal)
+    (name "kmod-minimal-static")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (arguments
+     (substitute-keyword-arguments
+       (package-arguments (static-package kmod-minimal))
+       ((#:configure-flags flags ''())
+        `(cons* "--disable-manpages" "--disable-static" "--disable-shared" ,flags))
+       ((#:make-flags flags ''())
+        `(cons* "LDFLAGS=-all-static" ,flags))
+       ((#:phases phases '%standard-phases)
+        `(modify-phases ,phases
+          (delete 'install-license-files)
+          (add-after 'unpack 'patch-kmod
+           (lambda _
+             ;; Reduce size by 200 kiB.
+             (substitute* "tools/kmod.c"
+              (("[&]kmod_cmd_compat_lsmod,") "")
+              (("[&]kmod_cmd_compat_rmmod,") "")
+              (("[&]kmod_cmd_compat_insmod,") "")
+              (("[&]kmod_cmd_compat_modinfo,") ""))
+             #t))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin")))
+                (install-file "tools/kmod" bin)
+                (for-each
+                 (lambda (tool)
+                   (symlink "kmod" (string-append bin "/" tool)))
+                 '("modprobe" "depmod"))
+                #t))))))))))
+
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.
   (package




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at 30604 <at> debbugs.gnu.org:


Received: (at 30604) by debbugs.gnu.org; 25 Feb 2018 11:48:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 06:48:34 2018
Received: from localhost ([127.0.0.1]:59478 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1epunC-0003fU-6s
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:48:34 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:58676)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1epunA-0003fG-5q
 for 30604 <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:48:32 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 809413360249;
 Sun, 25 Feb 2018 12:48:30 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: 30604 <at> debbugs.gnu.org
Subject: [PATCH 1/4] gnu: kmod: Split off kmod-minimal.
Date: Sun, 25 Feb 2018 12:48:13 +0100
Message-Id: <20180225114816.869-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
In-Reply-To: <20180225114557.816-1-dannym@HIDDEN>
References: <20180225114557.816-1-dannym@HIDDEN>
Tags: patch
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 30604
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

* gnu/packages/linux.scm (kmod-minimal): New variable.
(kmod): Modify.
---
 gnu/packages/linux.scm | 49 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 238398e84..1f8bf3050 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1933,8 +1933,35 @@ for systems using the Linux kernel.  This includes commands such as
 to use Linux' inotify mechanism, which allows file accesses to be monitored.")
     (license license:gpl2+)))
 
-(define-public kmod
+(define kmod-minimal
   (package
+    (name "kmod-minimal")
+    (version "13")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "mirror://kernel.org/linux/utils/kernel/kmod/"
+                              "kmod-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0mkrklih0f33c3zc4mkk9qqbzy36r18mj9xffd4wi61gpamx6dkc"))
+              (patches (search-patches "kmod-13-module-directory.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f)) ; FIXME: Investigate test failures
+    (home-page "https://www.kernel.org/")
+    (synopsis "Kernel module tools")
+    (description "Kmod is a set of tools to handle common tasks with Linux
+kernel modules like insert, remove, list, check properties, resolve
+dependencies and aliases.
+
+These tools are designed on top of libkmod, a library that is shipped with
+kmod.  The aim is to be compatible with tools, configurations and indices
+from the module-init-tools project.")
+    (license license:gpl2+))) ; library under lgpl2.1+
+
+(define-public kmod
+  (package (inherit kmod-minimal)
     (name "kmod")
     (version "24")
     (source (origin
@@ -1946,15 +1973,14 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                (base32
                 "15xkkkzvca9flvkm48gkh8y8f13vlm3sl7nz9ydc7b3jy4fqs2v1"))
               (patches (search-patches "kmod-module-directory.patch"))))
-    (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)))
     (inputs
      `(("xz" ,xz)
        ("zlib" ,zlib)))
     (arguments
-     `(#:tests? #f ; FIXME: Investigate test failures
-       #:configure-flags '("--with-xz" "--with-zlib")
+     `(#:configure-flags '("--with-xz" "--with-zlib")
+       #:tests? #f ; FIXME: Investigate test failures
        #:phases (alist-cons-after
                  'install 'install-modprobe&co
                  (lambda* (#:key outputs #:allow-other-keys)
@@ -1964,18 +1990,9 @@ to use Linux' inotify mechanism, which allows file accesses to be monitored.")
                                  (symlink "kmod"
                                           (string-append bin "/" tool)))
                                '("insmod" "rmmod" "lsmod" "modprobe"
-                                 "modinfo" "depmod"))))
-                 %standard-phases)))
-    (home-page "https://www.kernel.org/")
-    (synopsis "Kernel module tools")
-    (description "Kmod is a set of tools to handle common tasks with Linux
-kernel modules like insert, remove, list, check properties, resolve
-dependencies and aliases.
-
-These tools are designed on top of libkmod, a library that is shipped with
-kmod.  The aim is to be compatible with tools, configurations and indices
-from the module-init-tools project.")
-    (license license:gpl2+))) ; library under lgpl2.1+
+                                 "modinfo" "depmod"))
+                     #t))
+                 %standard-phases)))))
 
 (define-public eudev
   ;; The post-systemd fork, maintained by Gentoo.




Information forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 25 Feb 2018 11:46:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 25 06:46:19 2018
Received: from localhost ([127.0.0.1]:59472 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1epul0-0003bY-Pu
	for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:46:18 -0500
Received: from eggs.gnu.org ([208.118.235.92]:34572)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dannym@HIDDEN>) id 1epuky-0003bL-N7
 for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:46:16 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <dannym@HIDDEN>) id 1epuks-0005mv-Ge
 for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:46:11 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:44986)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <dannym@HIDDEN>)
 id 1epuks-0005mo-D4
 for submit <at> debbugs.gnu.org; Sun, 25 Feb 2018 06:46:10 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53771)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <dannym@HIDDEN>) id 1epukr-0000g8-A7
 for guix-patches@HIDDEN; Sun, 25 Feb 2018 06:46:10 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <dannym@HIDDEN>) id 1epuko-0005kt-6v
 for guix-patches@HIDDEN; Sun, 25 Feb 2018 06:46:09 -0500
Received: from dd26836.kasserver.com ([85.13.145.193]:39928)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <dannym@HIDDEN>)
 id 1epukn-0005kZ-VY
 for guix-patches@HIDDEN; Sun, 25 Feb 2018 06:46:06 -0500
Received: from dayas.3.home (77.118.165.54.wireless.dyn.drei.com
 [77.118.165.54])
 by dd26836.kasserver.com (Postfix) with ESMTPSA id 5BFF33360249;
 Sun, 25 Feb 2018 12:46:04 +0100 (CET)
From: Danny Milosavljevic <dannym@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 0/4] Load Linux module only when supported hardware is present.
Date: Sun, 25 Feb 2018 12:45:57 +0100
Message-Id: <20180225114557.816-1-dannym@HIDDEN>
X-Mailer: git-send-email 2.15.1
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
Cc: Danny Milosavljevic <dannym@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

Danny Milosavljevic (4):
  gnu: kmod: Split off kmod-minimal.
  gnu: Add kmod-minimal-static.
  linux-initrd: Add kmod.
  linux-boot: Load kernel modules only when the hardware is present.

 gnu/build/linux-boot.scm    | 24 ++++++++++--
 gnu/build/linux-initrd.scm  | 13 ++++++-
 gnu/packages/linux.scm      | 91 +++++++++++++++++++++++++++++++++++++--------
 gnu/system/linux-initrd.scm | 52 ++++++++++++++++++++------
 4 files changed, 148 insertions(+), 32 deletions(-)





Acknowledgement sent to Danny Milosavljevic <dannym@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#30604; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 13 Mar 2018 09:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.