unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan <stefan-guix@vodafonemail.de>
To: Mathieu Othacehe <othacehe@gnu.org>,
	Danny Milosavljevic <dannym@scratchpost.org>
Cc: 47744@debbugs.gnu.org
Subject: bug#47744: nfs-root-fs test is failing
Date: Sun, 18 Apr 2021 20:29:40 +0200	[thread overview]
Message-ID: <FFED044A-4E8B-48B8-8E5B-EDF8C40D6777@vodafonemail.de> (raw)
In-Reply-To: <5D1C7300-09CB-49C6-8256-5CD25563FE20@vodafonemail.de>

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

Hi Mathieu and Danny!

I’m now sure that this test has never been working.

To get it working, first of all we need a change in (gnu system vm) to not discard a root file-system of type “nfs”. I did this change. I also cleaned up the test itself. See the attached patch.

The test needs two virtual machines communicating over TCP. The NFS client machine needs the linux command line argument “ip=dhcp“ (or a static IP setting) or some other code inside the initrd to bring the network interface up and running before mounting its root file-system over NFS. And finally some QEMU networking needs to be setup to have the NFS server and client talk to each other with proper IP addresses.

Unfortunately I have no clue how to achieve these two prerequisites. The kernel argument “ip=dhcp” does not help, as the driver for the network interface is not part of the linux-libre kernel. And also adding the initrd-module e1000 comes too late. On my Raspberry Pi I’m using a modified kernel with a build-in network driver and the “ip=dhcp” argument.

It seems to me that the base-initrd is missing an argument to add some arbitrary expression, or an option to configure the network interface, or the shepherd service which is provisioning 'networking. For network booting the initrd in Guix currently seems to be useless – however, getting rid of it is not trivial either.

With the attached changes, the NFS server side tests are passing, but the NFS client is missing an own IP address when trying to mount its root file-system, which results in this error when executing “make check-system TESTS=nfs-root”:

Welcome, this is GNU's early boot Guile.
Use '--repl' for an initrd REPL.

loading kernel modules...
[   27.250034] e1000: Intel(R) PRO/1000 Network Driver
[   27.250975] e1000: Copyright (c) 1999-2006 Intel Corporation.
[   28.026651] PCI Interrupt Link [LNKC] enabled at IRQ 11
[   28.377771] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 52:54:00:12:34:56
[   28.388012] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
[   28.706203] usbcore: registered new interface driver usb-storage
[   28.839354] usbcore: registered new interface driver uas
[   28.922481] hid: raw HID events driver (C) Jiri Kosina
[   28.942031] usbcore: registered new interface driver usbhid
[   28.943247] usbhid: USB HID core driver
[   29.425330] isci: Intel(R) C600 SAS Controller Driver - version 1.2.0
[   30.100062] PCI Interrupt Link [LNKD] enabled at IRQ 10
[   30.724003] PCI Interrupt Link [LNKA] enabled at IRQ 10
[   31.335165] PCI Interrupt Link [LNKB] enabled at IRQ 11
[   32.129714] virtio_blk virtio3: [vda] 143360 512-byte logical blocks (73.4 MB/70.0 MiB)
[   32.167257]  vda: vda1 vda2
[   32.526742] random: crng init done
[   32.624351] FS-Cache: Loaded
[   32.675399] 9pnet: Installing 9P2000 support
[   32.692551] 9p: Installing v9fs 9p2000 file system support
[   32.695268] FS-Cache: Netfs '9p' registered for caching
configuring QEMU networking...
[   32.842717] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
[   32.859236] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
In gnu/build/linux-boot.scm:
   599:12  3 (_)
    423:8  2 (mount-root-file-system ":/export" "nfs" # _ #:flags _ # ?)
In unknown file:
           1 (mount ":/export" "/real-root" "nfs" 1 "addr=127.0.0.1")
In ice-9/boot-9.scm:
  1669:16  0 (raise-exception _ #:continuable? _)
In procedure mount: No such device
[   33.616971] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000


Bye

Stefan



[-- Attachment #2: 0001-NFS-root-for-virtual-machines.patch --]
[-- Type: application/octet-stream, Size: 13268 bytes --]

From 76ef5ee8d5505bf82c3226398844224e22fa78e1 Mon Sep 17 00:00:00 2001
From: Stefan <stefan-guix@vodafonemail.de>
Date: Sun, 18 Apr 2021 19:32:55 +0200
Subject: [PATCH] NFS root for virtual machines.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

gnu: system: Allow a root file-system over NFS for virtual machines.
gnu: tests: Improve the test for a root file-system over NFS.  However, the
test is still failing.

* gnu/system/vm.scm (virtualized-operating-system): Allow root file-systems
over NFS.
(system-qemu-image/shared-store-script): Respect the configured root
file-system-device.
* gnu/tests/nfs.scm (run-nfs-root-fs-test): Renamed to …
(run-nfs-root-test): … this. Cleanup and improvements.
(%test-nfs-root-fs): Renamed to …
(%test-nfs-root): … this. Renamed the test from "nfs-root-fs" to "nfs-root".
---
 gnu/system/vm.scm |  30 ++++++---
 gnu/tests/nfs.scm | 160 ++++++++++++++++++++--------------------------
 2 files changed, 92 insertions(+), 98 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 97adfa12fa..be0a4695f2 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -608,7 +608,8 @@ environment with the store shared with the host.  MAPPINGS is a list of
               (let ((target (file-system-mount-point fs))
                     (source (file-system-device fs)))
                 (or (string=? target (%store-prefix))
-                    (string=? target "/")
+                    (and (string=? target "/")
+                         (not (string=? (file-system-type fs) "nfs")))
                     (and (string? source)
                          (string-prefix? "/dev/" source))
 
@@ -618,14 +619,20 @@ environment with the store shared with the host.  MAPPINGS is a list of
                              (uuid? source))))))
             (operating-system-file-systems os)))
 
-  (define virtual-file-systems
-    (cons (file-system
-            (mount-point "/")
-            (device "/dev/vda1")
-            (type "ext4"))
+  (define (add-missing-root-fs user-file-systems)
+    (if (null? (filter (lambda (fs)
+                         (string=? (file-system-mount-point fs) "/"))
+                       user-file-systems))
+        (cons (file-system
+                (mount-point "/")
+                (device "/dev/vda1")
+                (type "ext4"))
+              user-file-systems)
+        user-file-systems))
 
-          (append (map mapping->file-system mappings)
-                  user-file-systems)))
+  (define virtual-file-systems
+    (append (map mapping->file-system mappings)
+            (add-missing-root-fs user-file-systems)))
 
   (operating-system (inherit os)
 
@@ -754,7 +761,12 @@ it is mostly useful when FULL-BOOT?  is true."
                                 #:disk-image-size disk-image-size)))
     (define kernel-arguments
       #~(list #$@(if graphic? #~() #~("console=ttyS0"))
-              #+@(operating-system-kernel-arguments os "/dev/vda1")))
+              #+@(operating-system-kernel-arguments
+                  os
+                  (file-system-device
+                   (first (filter (lambda (fs)
+                                    (string=? (file-system-mount-point fs) "/"))
+                                  (operating-system-file-systems os)))))))
 
     (define qemu-exec
       #~(list #+(file-append qemu "/bin/"
diff --git a/gnu/tests/nfs.scm b/gnu/tests/nfs.scm
index 9b2b785176..33c019da89 100644
--- a/gnu/tests/nfs.scm
+++ b/gnu/tests/nfs.scm
@@ -27,6 +27,7 @@
   #:use-module (gnu bootloader grub)
   #:use-module (gnu system)
   #:use-module (gnu system file-systems)
+  #:use-module (gnu system linux-initrd)
   #:use-module (gnu system shadow)
   #:use-module (gnu system vm)
   #:use-module (gnu services)
@@ -40,7 +41,7 @@
   #:use-module (guix monads)
   #:export (%test-nfs
             %test-nfs-server
-            %test-nfs-root-fs))
+            %test-nfs-root))
 
 (define %base-os
   (operating-system
@@ -265,7 +266,7 @@ directories can be mounted.")
    (value (run-nfs-server-test))))
 
 

-(define (run-nfs-root-fs-test)
+(define (run-nfs-root-test)
   "Run a test of an OS mounting its root file system via NFS."
   (define nfs-root-server-os
     (marionette-operating-system
@@ -275,15 +276,8 @@ directories can be mounted.")
          (modify-services (operating-system-user-services %nfs-os)
            (nfs-service-type config =>
             (nfs-configuration
-             (debug '(nfs nfsd mountd))
-             ;;; Note: Adding the following line causes Guix to hang.
-             ;(rpcmountd-port 20001)
-             ;;; Note: Adding the following line causes Guix to hang.
-             ;(rpcstatd-port 20002) ; FIXME: Set broadcast port AND listening port.
-             (nfsd-port 2049)
-             (nfs-versions '("4.2"))
              (exports '(("/export"
-                         "*(rw,insecure,no_subtree_check,crossmnt,fsid=root,no_root_squash,insecure,async)"))))))))
+                         "*(rw,insecure,no_subtree_check,crossmnt,fsid=root,no_root_squash,async)"))))))))
      #:requirements '(nscd)
      #:imported-modules '((gnu services herd)
                           (guix combinators))))
@@ -292,13 +286,23 @@ directories can be mounted.")
     (marionette-operating-system
      (operating-system
        (inherit (simple-operating-system (service dhcp-client-service-type)))
+       (host-name "nfs-client")
        (kernel-arguments '("ip=dhcp"))
+       (initrd-modules
+         (cons "e1000" %base-initrd-modules))
+       (initrd (lambda (file-systems . rest)
+                 ;; Create a standard initrd but set up networking
+                 ;; with the parameters QEMU expects by default.
+                 (apply base-initrd
+                        file-systems
+                        #:qemu-networking? #t
+                        rest)))
        (file-systems (cons
                       (file-system
                         (type "nfs")
                         (mount-point "/")
                         (device ":/export")
-                        (options "addr=127.0.0.1,vers=4.2"))
+                        (options "addr=127.0.0.1"))
                      %base-file-systems)))
      #:requirements '(nscd)
      #:imported-modules '((gnu services herd)
@@ -313,102 +317,80 @@ directories can be mounted.")
           (mkdir #$output)
           (chdir #$output)
 
-          (test-begin "start-nfs-boot-test")
-
-          ;;; Start up NFS server host.
+          (test-begin "start nfs-root server")
 
           (mkdir "/tmp/server")
           (define server-marionette
             (make-marionette (list #$(virtual-machine
-                                      nfs-root-server-os
-                                      ;(operating-system nfs-root-server-os)
-                                      ;(port-forwardings '( ; (111 . 111)
-                                      ;                    (2049 . 2049)
-                                      ;                    (20001 . 20001)
-                                      ;                    (20002 . 20002)))
-))
+                                      nfs-root-server-os))
                              #:socket-directory "/tmp/server"))
 
-          (marionette-eval
-           '(begin
-              (use-modules (gnu services herd))
-              (current-output-port
-               (open-file "/dev/console" "w0"))
-              ;; FIXME: Instead statfs "/" and "/export" and wait until they
-              ;; are different file systems.  But Guile doesn't seem to have
-              ;; statfs.
-              (sleep 5)
-              (chmod "/export" #o777)
-              (symlink "/gnu" "/export/gnu")
-              (start-service 'nscd)
-              (start-service 'networking)
-              (start-service 'nfs))
-           server-marionette)
-
-          ;;; Wait for the NFS services to be up and running.
+          (test-assert "nfs-root server boots"
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (current-output-port
+                 (open-file "/dev/console" "w0"))
+                (chmod "/export" #o777)
+                (symlink "/gnu" "/export/gnu")
+                (start-service 'nscd)
+                (start-service 'networking)
+                (start-service 'nfs)
+                #t)
+             server-marionette))
 
           (test-assert "nfs services are running"
-           (wait-for-file "/var/run/rpc.statd.pid" server-marionette))
-
-          (test-assert "NFS port is ready"
-            (wait-for-tcp-port 2049 server-marionette))
-
-          (test-assert "NFS statd port is ready"
-            (wait-for-tcp-port 20002 server-marionette))
+            (and (wait-for-file "/var/run/rpc.statd.pid" server-marionette)
+                 (marionette-eval
+                  '(zero? (system* (string-append #$nfs-utils "/sbin/showmount")
+                                   "-e" "nfs-server"))
+                  server-marionette)))
 
-          (test-assert "NFS mountd port is ready"
-            (wait-for-tcp-port 20001 server-marionette))
-
-          ;;; FIXME: (test-assert "NFS portmapper port is ready"
-          ;;; FIXME:  (wait-for-tcp-port 111 server-marionette))
+          (test-end)
 
-          ;;; Start up NFS client host.
+          (test-begin "start nfs-root client")
 
+          (mkdir "/tmp/client")
           (define client-marionette
             (make-marionette (list #$(virtual-machine
-                                      nfs-root-client-os
-                                      ;(port-forwardings '((111 . 111)
-                                      ;                    (2049 . 2049)
-                                      ;                    (20001 . 20001)
-                                      ;                    (20002 . 20002)))
-                                                          ))))
-
-          (marionette-eval
-           '(begin
-              (use-modules (gnu services herd))
-              (use-modules (rnrs io ports))
-
-              (current-output-port
-               (open-file "/dev/console" "w0"))
-              (let ((content (call-with-input-file "/proc/mounts" get-string-all)))
-                (call-with-output-file "/mounts.new"
-                  (lambda (port)
-                    (display content port))))
-              (chmod "/mounts.new" #o777)
-              (rename-file "/mounts.new" "/mounts"))
-           client-marionette)
-
-          (test-assert "nfs-root-client booted")
+                                      nfs-root-client-os))
+                             #:socket-directory "/tmp/client"))
 
-          ;;; Check whether NFS client host communicated with NFS server host.
-
-          (test-assert "nfs client deposited file"
-           (wait-for-file "/export/mounts" server-marionette))
-          (marionette-eval
-           '(begin
-              (current-output-port
-               (open-file "/dev/console" "w0"))
-              (call-with-input-file "/export/mounts" display))
-           server-marionette)
+          (test-assert "nfs-root client boots"
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (use-modules (rnrs io ports))
+                (current-output-port
+                 (open-file "/dev/console" "w0"))
+                (let ((content (call-with-input-file "/proc/mounts" get-string-all)))
+                  (display content)
+                  (newline)
+                  (call-with-output-file "/mounts"
+                    (lambda (port)
+                      (display content port)))
+                  content))
+             client-marionette))
+
+          (test-assert "wait nfs-root client booted and deposited mounts file"
+            (and (wait-for-file "/export/mounts" server-marionette)))
+          (test-assert "nfs-root client booted and deposited mounts file"
+                 (marionette-eval
+                  '(begin
+                     (current-output-port
+                      (open-file "/dev/console" "w0"))
+                      (call-with-input-file "/export/mounts"
+                                                    get-string-all))
+                  server-marionette))
 
           (test-end)
           (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
 
-  (gexp->derivation "nfs-root-fs-test" test))
+  (gexp->derivation "nfs-root-test" test))
 
-(define %test-nfs-root-fs
+(define %test-nfs-root
   (system-test
-   (name "nfs-root-fs")
+   (name "nfs-root")
    (description "Test that an NFS server can be started and the exported
-directory can be used as root file system.")
-   (value (run-nfs-root-fs-test))))
+directory can be used as root file system of an NFS client.")
+   (value (run-nfs-root-test))))
-- 
2.31.1

  reply	other threads:[~2021-04-18 18:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  8:10 bug#47744: nfs-root-fs test is failing Mathieu Othacehe
2021-04-17 17:19 ` Stefan
2021-04-18 18:29   ` Stefan [this message]
2021-04-22  9:30     ` Mathieu Othacehe
2021-04-22 19:28       ` bug#47956: " Stefan
2021-04-25 17:30         ` Mathieu Othacehe
2021-05-31 20:03           ` Stefan
2021-09-26 12:57 ` bug#47744: " Stefan
2021-09-27 22:34   ` Stefan
2021-12-23 10:01     ` bug#47744: [PATCH] nfs-root " Mathieu Othacehe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FFED044A-4E8B-48B8-8E5B-EDF8C40D6777@vodafonemail.de \
    --to=stefan-guix@vodafonemail.de \
    --cc=47744@debbugs.gnu.org \
    --cc=dannym@scratchpost.org \
    --cc=othacehe@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).