From 953c65ffdd43c02c934518fb7a1c68542584b223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 21 Sep 2023 16:38:22 +0200 Subject: services: hurd-vm: Implement zero-configuration offloading. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows for zero-configuration offloading to a childhurd. * gnu/services/virtualization.scm (operating-system-with-offloading-account): New procedure. ()[offloading?]: New field. (hurd-vm-disk-image): Define ‘transform’ and use it. (hurd-vm-activation): Generate SSH key for user ‘offloading’ and add authorize it via /etc/childhurd/etc/ssh/authorized_keys.d. (hurd-vm-configuration-offloading-ssh-key) (hurd-vm-guix-extension): New procedures. (hurd-vm-service-type): Add GUIX-SERVICE-TYPE extension. * gnu/tests/virtualization.scm (run-childhurd-test)[import-module?]: New procedure. [os]: Add (gnu build install) and its closure to #:import-modules. [test]: Add “copy-on-write store” and “offloading” tests. * doc/guix.texi (Virtualization Services): Document it. --- gnu/tests/virtualization.scm | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'gnu/tests') diff --git a/gnu/tests/virtualization.scm b/gnu/tests/virtualization.scm index 599e58edf0..b79164737b 100644 --- a/gnu/tests/virtualization.scm +++ b/gnu/tests/virtualization.scm @@ -38,6 +38,7 @@ #:use-module (guix gexp) #:use-module (guix records) #:use-module (guix store) + #:use-module (guix modules) #:export (%test-libvirt %test-qemu-guest-agent %test-childhurd)) @@ -244,11 +245,19 @@ (permit-root-login #t))))))))))) (define (run-childhurd-test) + (define (import-module? module) + ;; This module is optional and depends on Guile-Gcrypt, do skip it. + (and (guix-module-name? module) + (not (equal? module '(guix store deduplication))))) + (define os (marionette-operating-system %childhurd-os - #:imported-modules '((gnu services herd) - (guix combinators)))) + #:imported-modules (source-module-closure + '((gnu services herd) + (guix combinators) + (gnu build install)) + #:select? import-module?))) (define vm (virtual-machine @@ -373,6 +382,31 @@ (pk 'drv (string-trim-right drv))) drv))) + (test-assert "copy-on-write store" + ;; Set up a writable store. The root partition is already an + ;; overlayfs, which is not suitable as the bottom part of this + ;; additional overlayfs; thus, create a tmpfs for the backing + ;; store. + ;; TODO: Remove this when creates a writable + ;; store. + (marionette-eval + '(begin + (use-modules (gnu build install) + (guix build syscalls)) + + (mkdir "/run/writable-store") + (mount "none" "/run/writable-store" "tmpfs") + (mount-cow-store "/run/writable-store" "/backing-store") + (system* "df" "-hT")) + marionette)) + + (test-equal "offloading" + 0 + (marionette-eval + '(and (file-exists? "/etc/guix/machines.scm") + (system* "guix" "offload" "test")) + marionette)) + (test-end)))) (gexp->derivation "childhurd-test" test)) -- cgit v1.2.3