[bug#76488,2/4] vm: ‘common-qemu-options’ splits command-line tokens.
Commit Message
The result returned so far by ‘common-qemu-options’ assumed that it
would be passed to a shell. This is the case when using
‘system-qemu-image/shared-store-script’ but possibly not in other cases.
* gnu/system/vm.scm (common-qemu-options): Add #:image-format.
[virtfs-option]: Return a list of strings instead of a single
"-virtfs xyz" string. Update caller to use ‘append-map’.
Separate "-drive" string.
Change-Id: Ib07c27e2c4b2d222d7db2c612bb045d330bc7f68
---
gnu/system/vm.scm | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013-2024 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013-2025 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Christine Lemmer-Webber <cwebber@dustycloud.org>
;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -211,14 +211,16 @@ (define* (virtualized-operating-system os
(define* (common-qemu-options image shared-fs
#:key
+ (image-format "raw")
rw-image?
(target (%current-target-system)))
"Return the a string-value gexp with the common QEMU options to boot IMAGE,
with '-virtfs' options for the host file systems listed in SHARED-FS."
(define (virtfs-option fs)
- #~(format #f "-virtfs local,path=~s,security_model=none,mount_tag=~s"
- #$fs #$(file-system->mount-tag fs)))
+ #~("-virtfs"
+ (format #f "local,path=~a,security_model=none,mount_tag=~a"
+ #$fs #$(file-system->mount-tag fs))))
#~(;; Only enable kvm if we see /dev/kvm exists.
;; This allows users without hardware virtualization to still use these
@@ -230,11 +232,12 @@ (define* (common-qemu-options image shared-fs
"-object" "rng-random,filename=/dev/urandom,id=guix-vm-rng"
"-device" "virtio-rng-pci,rng=guix-vm-rng"
- #$@(map virtfs-option shared-fs)
- #$@(if rw-image?
- #~((format #f "-drive file=~a,format=qcow2,if=virtio" #$image))
- #~((format #f "-drive file=~a,format=raw,if=virtio,cache=writeback,werror=report,readonly=on"
- #$image)))))
+ #$@(append-map virtfs-option shared-fs)
+ "-drive"
+ #$(if rw-image?
+ #~(format #f "file=~a,format=qcow2,if=virtio" #$image)
+ #~(format #f "file=~a,format=~a,if=virtio,cache=writeback,werror=report,readonly=on"
+ #$image #$image-format))))
(define* (system-qemu-image/shared-store-script os
#:key