summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-12-06 15:06:35 +0100
committerLudovic Courtès <ludo@gnu.org>2022-12-06 15:06:35 +0100
commitf59aa79ca342ef311a20dafc782adea6eed29b1a (patch)
tree27b6b2740bf537b2396af999dad7c33f238f44ad /gnu
parent2493de0d1a481f079580a354430b26977afbdbd1 (diff)
system: vm: Non-volatile 'run-vm.sh' creates a CoW image.
Previously, copying the image would consume a lot of space and was I/O-intensive, to the point that the marionette connection timeout of 20s could be reached when running tests like "docker-system". * gnu/system/vm.scm (common-qemu-options): Pass 'format=' for each '-drive' option. (system-qemu-image/shared-store-script)[copy-image]: New variable. [builder]: Use it when VOLATILE? is false.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/system/vm.scm27
1 files changed, 18 insertions, 9 deletions
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index c2f7efa966d..b7bccd72a48 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2013-2022 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2016 Christine Lemmer-Webber <cwebber@dustycloud.org> 3;;; Copyright © 2016 Christine Lemmer-Webber <cwebber@dustycloud.org>
4;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name> 4;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
5;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> 5;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -234,8 +234,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS."
234 234
235 #$@(map virtfs-option shared-fs) 235 #$@(map virtfs-option shared-fs)
236 #$@(if rw-image? 236 #$@(if rw-image?
237 #~((format #f "-drive file=~a,if=virtio" #$image)) 237 #~((format #f "-drive file=~a,format=qcow2,if=virtio" #$image))
238 #~((format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly=on" 238 #~((format #f "-drive file=~a,format=raw,if=virtio,cache=writeback,werror=report,readonly=on"
239 #$image))))) 239 #$image)))))
240 240
241(define* (system-qemu-image/shared-store-script os 241(define* (system-qemu-image/shared-store-script os
@@ -303,17 +303,26 @@ useful when FULL-BOOT? is true."
303 "-m " (number->string #$memory-size) 303 "-m " (number->string #$memory-size)
304 #$@options)) 304 #$@options))
305 305
306 (define copy-image
307 ;; Script that "copies" BASE-IMAGE to /tmp. Make a copy-on-write image,
308 ;; which is much cheaper than actually copying it.
309 (program-file "copy-image"
310 (with-imported-modules '((guix build utils))
311 #~(begin
312 (use-modules (guix build utils))
313 (unless (file-exists? #$rw-image)
314 (invoke #+(file-append qemu "/bin/qemu-img")
315 "create" "-b" #$base-image
316 "-F" "raw" "-f" "qcow2" #$rw-image))))))
317
306 (define builder 318 (define builder
307 #~(call-with-output-file #$output 319 #~(call-with-output-file #$output
308 (lambda (port) 320 (lambda (port)
309 (format port "#!~a~%" 321 (format port "#!~a~%"
310 #+(file-append bash "/bin/sh")) 322 #+(file-append bash "/bin/sh"))
311 (when (not #$volatile?) 323 #$@(if volatile?
312 (format port "~a~%" 324 #~()
313 #$(program-file "copy-image" 325 #~((format port "~a~%" #+copy-image)))
314 #~(unless (file-exists? #$rw-image)
315 (copy-file #$base-image #$rw-image)
316 (chmod #$rw-image #o640)))))
317 (format port "exec ~a \"$@\"~%" 326 (format port "exec ~a \"$@\"~%"
318 (string-join #$qemu-exec " ")) 327 (string-join #$qemu-exec " "))
319 (chmod port #o555)))) 328 (chmod port #o555))))