unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Mathieu Othacehe <othacehe@gnu.org>
To: Leo Famulari <leo@famulari.name>
Cc: 52919@debbugs.gnu.org
Subject: bug#52919: Hidden "disk-image-rw" files aren't deleted after use, filling $tmpdir
Date: Tue, 11 Jan 2022 13:33:30 +0100	[thread overview]
Message-ID: <87v8yqv4dh.fsf@gnu.org> (raw)
In-Reply-To: <YdSDWG/pt/3I9v1e@jasmine.lan> (Leo Famulari's message of "Tue, 4 Jan 2022 12:26:48 -0500")

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


Hey,

Here is a patch to store the rw images in the cache directory. Regarding
the volatile flag, things are a little more complex than what I thought
initially.

The "guix system" help menu states that:

--8<---------------cut here---------------start------------->8---
      --volatile         for 'image', make the root file system volatile
--8<---------------cut here---------------end--------------->8---

because for an image, it often makes sense to have the root file system
persistent. For the 'vm' command however, it's probably the other way
around as we would prefer not to copy the huge image files if possible.

I feel like creating a '--volatile-image' and a '--persistent-vm' option
is going to make things too much complex.

WDYT?

Thanks,

Mathieu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-system-vm-Do-not-store-rw-image-in-the-tmp-directory.patch --]
[-- Type: text/x-patch, Size: 2073 bytes --]

From e4efaf2ffc6d7c699f9d1c41744cfff89be65c12 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@gnu.org>
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


  reply	other threads:[~2022-01-11 12:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31 18:18 bug#52919: Hidden "disk-image-rw" files aren't deleted after use, filling $tmpdir Leo Famulari
2022-01-03 14:56 ` Mathieu Othacehe
2022-01-04  8:17   ` Ludovic Courtès
2022-01-04 17:26     ` Leo Famulari
2022-01-11 12:33       ` Mathieu Othacehe [this message]
2022-01-12 20:54         ` Ludovic Courtès
2022-01-13 10:55           ` Mathieu Othacehe
2022-01-13 14:49             ` Ludovic Courtès
2022-01-14 11:27               ` 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=87v8yqv4dh.fsf@gnu.org \
    --to=othacehe@gnu.org \
    --cc=52919@debbugs.gnu.org \
    --cc=leo@famulari.name \
    /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).