all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs
@ 2020-06-17 18:44 Ivan Kozlov
  2020-06-17 21:18 ` Ivan Kozlov
  2020-06-18 18:16 ` Danny Milosavljevic
  0 siblings, 2 replies; 7+ messages in thread
From: Ivan Kozlov @ 2020-06-17 18:44 UTC (permalink / raw)
  To: 41924

This allows a Linux package with CONFIG_MODULES=n, that doesn’t contain the ‘lib/modules’ directory, to be used.

* guix/profiles.scm (linux-module-database): Add if clause to ignore unrelated inputs. Allow empty result.
---
 guix/profiles.scm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/guix/profiles.scm b/guix/profiles.scm
index 25ff146bdf..a3868e8343 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1220,9 +1220,11 @@ This is meant to be used as a profile hook."
                        inputs))
                  (directory-entries
                   (lambda (directory)
-                    (scandir directory (lambda (basename)
-                                         (not
-                                           (string-prefix? "." basename))))))
+                    (if (file-exists? directory)
+                        (scandir directory (lambda (basename)
+                                             (not
+                                              (string-prefix? "." basename))))
+                        '())))
                  ;; Note: Should usually result in one entry.
                  (versions (delete-duplicates
                             (append-map directory-entries
@@ -1233,6 +1235,8 @@ This is meant to be used as a profile hook."
                   (setenv "PATH" #+(file-append kmod "/bin"))
                   (make-linux-module-directory inputs version #$output)
                   (setenv "PATH" old-path)))
+               ;; Do nothing when there is nothing to do
+               (() (mkdir #$output))
                (_ (error "Specified Linux kernel and Linux kernel modules
 are not all of the same version")))))))
   (gexp->derivation "linux-module-database" build
-- 
2.26.2






^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs
  2020-06-17 18:44 [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs Ivan Kozlov
@ 2020-06-17 21:18 ` Ivan Kozlov
  2020-06-18 18:16 ` Danny Milosavljevic
  1 sibling, 0 replies; 7+ messages in thread
From: Ivan Kozlov @ 2020-06-17 21:18 UTC (permalink / raw)
  To: 41924@debbugs.gnu.org

mkdir should of course be changed to mkdir-p.

17.06.2020, 21:45, "Ivan Kozlov" <kanichos@yandex.ru>:
> This allows a Linux package with CONFIG_MODULES=n, that doesn’t contain the ‘lib/modules’ directory, to be used.
>
> * guix/profiles.scm (linux-module-database): Add if clause to ignore unrelated inputs. Allow empty result.
> ---
>  guix/profiles.scm | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/guix/profiles.scm b/guix/profiles.scm
> index 25ff146bdf..a3868e8343 100644
> --- a/guix/profiles.scm
> +++ b/guix/profiles.scm
> @@ -1220,9 +1220,11 @@ This is meant to be used as a profile hook."
>                         inputs))
>                   (directory-entries
>                    (lambda (directory)
> - (scandir directory (lambda (basename)
> - (not
> - (string-prefix? "." basename))))))
> + (if (file-exists? directory)
> + (scandir directory (lambda (basename)
> + (not
> + (string-prefix? "." basename))))
> + '())))
>                   ;; Note: Should usually result in one entry.
>                   (versions (delete-duplicates
>                              (append-map directory-entries
> @@ -1233,6 +1235,8 @@ This is meant to be used as a profile hook."
>                    (setenv "PATH" #+(file-append kmod "/bin"))
>                    (make-linux-module-directory inputs version #$output)
>                    (setenv "PATH" old-path)))
> + ;; Do nothing when there is nothing to do
> + (() (mkdir #$output))
>                 (_ (error "Specified Linux kernel and Linux kernel modules
>  are not all of the same version")))))))
>    (gexp->derivation "linux-module-database" build
> --
> 2.26.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs
  2020-06-17 18:44 [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs Ivan Kozlov
  2020-06-17 21:18 ` Ivan Kozlov
@ 2020-06-18 18:16 ` Danny Milosavljevic
  2020-06-19  7:47   ` Ludovic Courtès
  2020-06-19  8:20   ` [bug#41924] " Ivan Kozlov
  1 sibling, 2 replies; 7+ messages in thread
From: Danny Milosavljevic @ 2020-06-18 18:16 UTC (permalink / raw)
  To: Ivan Kozlov; +Cc: 41924

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

Hi Ivan,

thanks for the patch, and for persevering on this.

Could you also add a system test to gnu/tests/linux-modules.scm ?

That would also mean that you'd create a variant of linux-libre that has
CONFIG_MODULES=n.

>                   (directory-entries
>                    (lambda (directory)
> -                    (scandir directory (lambda (basename)
> -                                         (not
> -                                           (string-prefix? "." basename))))))
> +                    (if (file-exists? directory)
> +                        (scandir directory (lambda (basename)
> +                                             (not
> +                                              (string-prefix? "." basename))))
> +                        '())))

That would silently skip packages that don't contain kernel modules (but for
example supertux or something), too, right?
(so misconfigured guix wouldn't be detected)

Also, if you tried to use a kernel without module support and then added modules
(for the wrong kernel, one with CONFIG_MODULES=y) via extra guix packages,
this would erroneously succeed, right?
(I guess depmod would have something against it, though.  Still, I'd like a test
for that)

Usually I'd be fine with these unsupported constellations, but misconfigured
kernel vs module ABI makes me reconsider my life choices, so probably not here :->

What I would do is try to find a file that's only in the kernel when there's
module support (/lib/modules doesn't count since there could be a kernel with
module support but no modules compiled), and then try to ascertain whether
CONFIG_MODULES=y that way, so
(define config-modules? (any (append-map directory-entries with marker-file)))
or something.

Then succeed either with config-modules? and at least one file per entry, or
with (not config-modules?) and no files anywhere.

Alternatively, we could at least make it only possible for the FIRST entry
in the list of module packages (which is the Linux kernel) to have no
/lib/modules, and not care about any of the other entries in that way.

> +               ;; Do nothing when there is nothing to do
> +               (() (mkdir #$output))

Good idea.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs
  2020-06-18 18:16 ` Danny Milosavljevic
@ 2020-06-19  7:47   ` Ludovic Courtès
  2020-06-19 14:23     ` Ivan Kozlov
  2020-06-19  8:20   ` [bug#41924] " Ivan Kozlov
  1 sibling, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2020-06-19  7:47 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 41924, Ivan Kozlov

Hi Ivan & Danny,

I forgot to email you back (sorry about that!): I pushed a variant of
this patch here:

  https://git.savannah.gnu.org/cgit/guix.git/commit/?id=05f79da93fb4fd5216feb41510bf0a41f8eedf5b

WDYT?

Ludo’.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs
  2020-06-18 18:16 ` Danny Milosavljevic
  2020-06-19  7:47   ` Ludovic Courtès
@ 2020-06-19  8:20   ` Ivan Kozlov
  1 sibling, 0 replies; 7+ messages in thread
From: Ivan Kozlov @ 2020-06-19  8:20 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 41924@debbugs.gnu.org

Hi,

> What I would do is try to find a file that's only in the kernel when there's
> module support (/lib/modules doesn't count since there could be a kernel with
> module support but no modules compiled), and then try to ascertain whether
> CONFIG_MODULES=y that way, so
> (define config-modules? (any (append-map directory-entries with marker-file)))
> or something.

The only way to do this sort of thing is to have the config. Otherwise the kernel will always sort of exist in a separate world. You can always compile it in a way that breaks the rest of the Guix system’s assumptions, e.g. by disabling the necessary system calls or cgroups controllers, and get no warnings/build failures. This applies to any extra kernel modules, too. I don’t think LKM support stands out. I actually don’t think it is a big problem that using an unofficial Linux package puts some burden on the maintainer, I merely want such setups to be possible.

The problem in question really applies to all cases when there aren’t any modules to deal with, as you correctly point out, not necessary having to do with CONFIG_MODULES; e.g. building a system with CONFIG_MODULES=y and no loadable modules, and no extra modules, is perfectly legitimate.

> That would silently skip packages that don't contain kernel modules (but for
> example supertux or something), too, right?
> (so misconfigured guix wouldn't be detected)

It is possible to rely on the way operating-system-directory-base-entries builds the manifest to avoid this specific issue: (car #$(manifest-inputs manifest)) should be the kernel.

I haven’t really looked into the test suite, here is my guess:

diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scm
index 953b132ef7..2fc8f52b90 100644
--- a/gnu/tests/linux-modules.scm
+++ b/gnu/tests/linux-modules.scm
@@ -25,6 +25,7 @@
   #:use-module (gnu system)
   #:use-module (gnu system vm)
   #:use-module (gnu tests)
+  #:use-module (gnu tests base)
   #:use-module (guix derivations)
   #:use-module (guix gexp)
   #:use-module (guix modules)
@@ -129,3 +130,37 @@ with two extra modules.")
                                                  (package-arguments
                                                   ddcci-driver-linux))))))
            '("acpi_call" "ddcci")))))
+
+(define %test-no-loadable-kernel-modules
+  (let* ((kernel (package
+                   (inherit linux-libre)
+                   (arguments
+                    (substitute-keyword-arguments (package-arguments linux-libre)
+                      ((#:phases phases)
+                       `(modify-phases ,phases
+                          (add-before 'build 'no-lkm-config
+                            (lambda _
+                              (substitute* ".config"
+                                (("=m") "=y"))
+                              (let ((port (open-file ".config" "a")))
+                                (display "CONFIG_MODULES=n" port)
+                                (close-port port))))
+                          (replace 'install
+                            (lambda* (#:key outputs #:allow-other-keys)
+                              (for-each
+                               (let ((out (assoc-ref outputs "out")))
+                                 (lambda (file) (install-file file out)))
+                               (find-files "." "^(\\.config|bzImage|zImage|Image|vmlinuz|System\\.map|Module\\.symvers)$"))))))))))
+         (os (marionette-operating-system
+              (operating-system
+                (inherit (simple-operating-system))
+                (kernel kernel)
+                (initrd-modules '()))
+              #:imported-modules '((gnu services herd)
+                                   (guix combinators))))
+         (vm (virtual-machine os)))
+    (system-test
+     (name "no-loadable-kernel-modules")
+     (description "Build and run a basic system without loadable kernel module support")
+     (value (run-basic-test (virtualized-operating-system os '())
+                            #~(list #$vm))))))
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 25ff146bdf..abf0cf7f27 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1201,6 +1201,8 @@ for both major versions of GTK+."
   "Return a derivation that unites all the kernel modules of the manifest
 and creates the dependency graph of all these kernel modules.

+The first entry in the manifest must be a Linux kernel package.
+
 This is meant to be used as a profile hook."
   (define kmod  ; lazy reference
     (module-ref (resolve-interface '(gnu packages linux)) 'kmod))
@@ -1226,14 +1228,22 @@ This is meant to be used as a profile hook."
                  ;; Note: Should usually result in one entry.
                  (versions (delete-duplicates
                             (append-map directory-entries
-                                        module-directories))))
-              (match versions
-               ((version)
-                (let ((old-path (getenv "PATH")))
-                  (setenv "PATH" #+(file-append kmod "/bin"))
-                  (make-linux-module-directory inputs version #$output)
-                  (setenv "PATH" old-path)))
-               (_ (error "Specified Linux kernel and Linux kernel modules
+                                        (if (file-exists? (car module-directories))
+                                            module-directories
+                                            (cdr module-directories))))))
+            (match versions
+              ((version)
+               (let ((old-path (getenv "PATH")))
+                 (setenv "PATH" #+(file-append kmod "/bin"))
+                 (make-linux-module-directory inputs version #$output)
+                 (setenv "PATH" old-path)))
+              ;; Do nothing when there is nothing to do
+              (() (mkdir #$output))
+              ;; This might not catch a version incompatibility
+              ;; if all kernel modules reside in extra packages
+              ;; Would checking the kernel package version have
+              ;; undesirable effects?
+              (_ (error "Specified Linux kernel and Linux kernel modules
 are not all of the same version")))))))
   (gexp->derivation "linux-module-database" build
                     #:local-build? #t





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs
  2020-06-19  7:47   ` Ludovic Courtès
@ 2020-06-19 14:23     ` Ivan Kozlov
  2020-06-19 20:27       ` bug#41924: " Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: Ivan Kozlov @ 2020-06-19 14:23 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Danny Milosavljevic, 41924@debbugs.gnu.org

Hi,

Thanks, I’m happy enough with this.

19.06.2020, 10:47, "Ludovic Courtès" <ludo@gnu.org>:
> Hi Ivan & Danny,
>
> I forgot to email you back (sorry about that!): I pushed a variant of
> this patch here:
>
>   https://git.savannah.gnu.org/cgit/guix.git/commit/?id=05f79da93fb4fd5216feb41510bf0a41f8eedf5b
>
> WDYT?
>
> Ludo’.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#41924: [PATCH] profiles: Make linux-module-database skip inappropriate inputs
  2020-06-19 14:23     ` Ivan Kozlov
@ 2020-06-19 20:27       ` Ludovic Courtès
  0 siblings, 0 replies; 7+ messages in thread
From: Ludovic Courtès @ 2020-06-19 20:27 UTC (permalink / raw)
  To: Ivan Kozlov; +Cc: Danny Milosavljevic, 41924@debbugs.gnu.org

Hi,

Ivan Kozlov <kanichos@yandex.ru> skribis:

> Thanks, I’m happy enough with this.

Cool, closing.  Thank you.

Ludo’.




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-19 20:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-17 18:44 [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs Ivan Kozlov
2020-06-17 21:18 ` Ivan Kozlov
2020-06-18 18:16 ` Danny Milosavljevic
2020-06-19  7:47   ` Ludovic Courtès
2020-06-19 14:23     ` Ivan Kozlov
2020-06-19 20:27       ` bug#41924: " Ludovic Courtès
2020-06-19  8:20   ` [bug#41924] " Ivan Kozlov

Code repositories for project(s) associated with this external index

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

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