diff options
| -rw-r--r-- | gnu/system/vm.scm | 27 |
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)))) |
