From e4efaf2ffc6d7c699f9d1c41744cfff89be65c12 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 11 Jan 2022 13:27:35 +0100 Subject: [PATCH 1/1] system: vm: Do not store rw image in the /tmp directory. * gnu/system/vm.scm (system-qemu-image/shared-store-script): Store them in the cache directory instead. --- gnu/system/vm.scm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 0fc9fb57f4..bd21f9416c 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -283,7 +283,9 @@ (define kernel-arguments #+@(operating-system-kernel-arguments os "/dev/vda1"))) (define rw-image - #~(format #f "/tmp/.~a-rw" (basename #$base-image))) + #~(format #f "~a/~a-rw" + #$(string-append (cache-directory) "/images") + (basename #$base-image))) (define qemu-exec #~(list #+(file-append qemu "/bin/" @@ -310,10 +312,15 @@ (define builder #+(file-append bash "/bin/sh")) (when (not #$volatile?) (format port "~a~%" - #$(program-file "copy-image" - #~(unless (file-exists? #$rw-image) - (copy-file #$base-image #$rw-image) - (chmod #$rw-image #o640))))) + #$(program-file + "copy-image" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (unless (file-exists? #$rw-image) + (mkdir-p (dirname #$rw-image)) + (copy-file #$base-image #$rw-image) + (chmod #$rw-image #o640))))))) (format port "exec ~a \"$@\"~%" (string-join #$qemu-exec " ")) (chmod port #o555)))) -- 2.34.0