scripts: system: Rationalize persistency.

Make sure that the images are created with a non volatile root by default and
the vm are created with a volatile root by default. Break the --volatile
option into --volatile-image and --persistent-vm options.

* guix/scripts/system.scm (perform-action): Turn volatile? argument into
volatile-vm-root?.
(show-help): Introduce --volatile-image and --persistent-vm options instead of
--volatile.
(%default-options): Adapt it.
(%options): Handle those options.
(process-action): Honor them.
* doc/guix.texi (Invoking guix system): Adapt it accordingly.
This commit is contained in:
Mathieu Othacehe 2022-01-13 11:35:40 +01:00
parent 3dbb7112d4
commit 2d12ec724e
No known key found for this signature in database
GPG key ID: 8354763531769CA6
2 changed files with 22 additions and 8 deletions

View file

@ -35162,6 +35162,11 @@ $ $(guix system vm my-config.scm) -m 1024 -smp 2 -nic user,model=virtio-net-pci
The VM shares its store with the host system. The VM shares its store with the host system.
By default, the root file system of the VM is mounted volatile; the
@option{--persistent} option can be provided to make it persistent
instead. In that case, the VM disk-image file will be copied from the
store to the @env{TMPDIR} directory to make it writable.
Additional file systems can be shared between the host and the VM using Additional file systems can be shared between the host and the VM using
the @option{--share} and @option{--expose} command-line options: the former the @option{--share} and @option{--expose} command-line options: the former
specifies a directory to be shared with write access, while the latter specifies a directory to be shared with write access, while the latter
@ -35199,8 +35204,8 @@ QEMU monitor and the VM.
@cindex Creating system images in various formats @cindex Creating system images in various formats
@item image @item image
@cindex image, creating disk images @cindex image, creating disk images
The @code{image} command can produce various image types. The The @code{image} command can produce various image types. The image
image type can be selected using the @option{--image-type} option. It type can be selected using the @option{--image-type} option. It
defaults to @code{efi-raw}. When its value is @code{iso9660}, the defaults to @code{efi-raw}. When its value is @code{iso9660}, the
@option{--label} option can be used to specify a volume ID with @option{--label} option can be used to specify a volume ID with
@code{image}. By default, the root file system of a disk image is @code{image}. By default, the root file system of a disk image is

View file

@ -772,7 +772,7 @@ (define* (perform-action action image
dry-run? derivations-only? dry-run? derivations-only?
use-substitutes? target use-substitutes? target
full-boot? full-boot?
volatile? volatile-vm-root?
(graphic? #t) (graphic? #t)
container-shared-network? container-shared-network?
(mappings '()) (mappings '())
@ -827,7 +827,8 @@ (define bootcfg
(mlet* %store-monad (mlet* %store-monad
((sys (system-derivation-for-action image action ((sys (system-derivation-for-action image action
#:full-boot? full-boot? #:full-boot? full-boot?
#:volatile? volatile? #:volatile?
volatile-vm-root?
#:graphic? graphic? #:graphic? graphic?
#:container-shared-network? container-shared-network? #:container-shared-network? container-shared-network?
#:mappings mappings)) #:mappings mappings))
@ -998,6 +999,8 @@ (define (show-help)
--no-bootloader for 'init', do not install a bootloader")) --no-bootloader for 'init', do not install a bootloader"))
(display (G_ " (display (G_ "
--volatile for 'image', make the root file system volatile")) --volatile for 'image', make the root file system volatile"))
(display (G_ "
--persistent for 'vm', make the root file system persistent"))
(display (G_ " (display (G_ "
--label=LABEL for 'image', label disk image with LABEL")) --label=LABEL for 'image', label disk image with LABEL"))
(display (G_ " (display (G_ "
@ -1080,7 +1083,10 @@ (define %options
(alist-cons 'install-bootloader? #f result))) (alist-cons 'install-bootloader? #f result)))
(option '("volatile") #f #f (option '("volatile") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'volatile-root? #t result))) (alist-cons 'volatile-image-root? #t result)))
(option '("persistent") #f #f
(lambda (opt name arg result)
(alist-cons 'volatile-vm-root? #f result)))
(option '("label") #t #f (option '("label") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'label arg result))) (alist-cons 'label arg result)))
@ -1149,7 +1155,8 @@ (define %default-options
(image-size . guess) (image-size . guess)
(install-bootloader? . #t) (install-bootloader? . #t)
(label . #f) (label . #f)
(volatile-root? . #f) (volatile-image-root? . #f)
(volatile-vm-root? . #t)
(graph-backend . "graphviz"))) (graph-backend . "graphviz")))
(define (verbosity-level opts) (define (verbosity-level opts)
@ -1219,7 +1226,8 @@ (define save-provenance?
((docker-image) docker-image-type) ((docker-image) docker-image-type)
(else image-type))) (else image-type)))
(image-size (assoc-ref opts 'image-size)) (image-size (assoc-ref opts 'image-size))
(volatile? (assoc-ref opts 'volatile-root?)) (volatile?
(assoc-ref opts 'volatile-image-root?))
(shared-network? (shared-network?
(assoc-ref opts 'container-shared-network?)) (assoc-ref opts 'container-shared-network?))
(base-image (if (operating-system? obj) (base-image (if (operating-system? obj)
@ -1279,7 +1287,8 @@ (define (graph-backend)
#:validate-reconfigure #:validate-reconfigure
(assoc-ref opts 'validate-reconfigure) (assoc-ref opts 'validate-reconfigure)
#:full-boot? (assoc-ref opts 'full-boot?) #:full-boot? (assoc-ref opts 'full-boot?)
#:volatile? (assoc-ref opts 'volatile-root?) #:volatile-vm-root?
(assoc-ref opts 'volatile-vm-root?)
#:graphic? (not (assoc-ref opts 'no-graphic?)) #:graphic? (not (assoc-ref opts 'no-graphic?))
#:container-shared-network? #:container-shared-network?
(assoc-ref opts 'container-shared-network?) (assoc-ref opts 'container-shared-network?)