diff options
-rw-r--r-- | doc/guix.texi | 12 | ||||
-rw-r--r-- | gnu/system/vm.scm | 49 | ||||
-rw-r--r-- | guix/scripts/system.scm | 4 |
3 files changed, 46 insertions, 19 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 2da956cc73..bc839ecbbb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4151,9 +4151,15 @@ Build a virtual machine that contain the operating system declared in The VM shares its store with the host system. -On GNU/Linux, the default is to boot directly to the kernel. The -@code{--full-boot} option forces a complete boot sequence, starting with -the bootloader. +On GNU/Linux, the default is to boot directly to the kernel; this has +the advantage of requiring only a very tiny root disk image since the +host's store can then be mounted. + +The @code{--full-boot} option forces a complete boot sequence, starting +with the bootloader. This requires more disk space since a root image +containing at least the kernel, initrd, and bootloader data files must +be created. The @code{--image-size} option can be used to specify the +image's size. @item vm-image @itemx disk-image diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index c687bb43f5..efe943a7b4 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -376,20 +376,31 @@ environment with the store shared with the host." (define* (system-qemu-image/shared-store os - #:key (disk-image-size (* 15 (expt 2 20)))) + #:key + full-boot? + (disk-image-size (* (if full-boot? 500 15) (expt 2 20)))) "Return a derivation that builds a QEMU image of OS that shares its store -with the host." - (mlet* %store-monad - ((os-drv (operating-system-derivation os)) - (grub.cfg (operating-system-grub.cfg os))) +with the host. + +When FULL-BOOT? is true, return an image that does a complete boot sequence, +bootloaded included; thus, make a disk image that contains everything the +bootloader refers to: OS kernel, initrd, bootloader data, etc." + (mlet* %store-monad ((os-drv (operating-system-derivation os)) + (grub.cfg (operating-system-grub.cfg os))) + ;; XXX: When FULL-BOOT? is true, we end up creating an image that contains + ;; GRUB.CFG and all its dependencies, including the output of OS-DRV. + ;; This is more than needed (we only need the kernel, initrd, GRUB for its + ;; font, and the background image), but it's hard to filter that. (qemu-image #:os-derivation os-drv #:grub-configuration grub.cfg #:disk-image-size disk-image-size - #:inputs `(("system" ,os-drv)) + #:inputs (if full-boot? + `(("grub.cfg" ,grub.cfg)) + '()) ;; XXX: Passing #t here is too slow, so let it off by default. #:register-closures? #f - #:copy-inputs? #f))) + #:copy-inputs? full-boot?))) (define* (common-qemu-options image) "Return the a string-value gexp with the common QEMU options to boot IMAGE." @@ -406,15 +417,23 @@ with the host." #:key (qemu qemu) (graphic? #t) - full-boot?) + full-boot? + (disk-image-size + (* (if full-boot? 500 15) + (expt 2 20)))) "Return a derivation that builds a script to run a virtual machine image of -OS that shares its store with the host. When FULL-BOOT? is true, the returned -script runs everything starting from the bootloader; otherwise it directly -starts the operating system kernel." - (mlet* %store-monad - ((os -> (virtualized-operating-system os)) - (os-drv (operating-system-derivation os)) - (image (system-qemu-image/shared-store os))) +OS that shares its store with the host. + +When FULL-BOOT? is true, the returned script runs everything starting from the +bootloader; otherwise it directly starts the operating system kernel. The +DISK-IMAGE-SIZE parameter specifies the size in bytes of the root disk image; +it is mostly useful when FULL-BOOT? is true." + (mlet* %store-monad ((os -> (virtualized-operating-system os)) + (os-drv (operating-system-derivation os)) + (image (system-qemu-image/shared-store + os + #:full-boot? full-boot? + #:disk-image-size disk-image-size))) (define builder #~(call-with-output-file #$output (lambda (port) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 7eb86c293d..ebad13e5e0 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -258,7 +258,9 @@ it atomically, and then run OS's activation script." ((vm-image) (system-qemu-image os #:disk-image-size image-size)) ((vm) - (system-qemu-image/shared-store-script os #:full-boot? full-boot?)) + (system-qemu-image/shared-store-script os + #:full-boot? full-boot? + #:disk-image-size image-size)) ((disk-image) (system-disk-image os #:disk-image-size image-size)))) |