linux-initrd: Make the virtio kernel modules optional.

* gnu/system/linux-initrd.scm (qemu-initrd): Add #:virtio? parameter.
  Use it.
* gnu/system/vm.scm (expression->derivation-in-linux-vm): Pass
  'qemu-initrd' #:virtio?.
  (virtualized-operating-system): Likewise.
master
Ludovic Courtès 2014-06-30 06:49:38 +02:00
parent cafc3f5ad7
commit 24e0160a4a
2 changed files with 17 additions and 6 deletions

View File

@ -203,16 +203,18 @@ initrd code."
(define* (qemu-initrd file-systems (define* (qemu-initrd file-systems
#:key #:key
guile-modules-in-chroot?
(qemu-networking? #t) (qemu-networking? #t)
volatile-root?) virtio?
volatile-root?
guile-modules-in-chroot?)
"Return a monadic derivation that builds an initrd for use in a QEMU guest "Return a monadic derivation that builds an initrd for use in a QEMU guest
where the store is shared with the host. FILE-SYSTEMS is a list of where the store is shared with the host. FILE-SYSTEMS is a list of
file-systems to be mounted by the initrd, possibly in addition to the root file-systems to be mounted by the initrd, possibly in addition to the root
file system specified on the kernel command line via '--root'. file system specified on the kernel command line via '--root'.
When QEMU-NETWORKING? is true, set up networking with the standard QEMU When QEMU-NETWORKING? is true, set up networking with the standard QEMU
parameters. parameters. When VIRTIO? is true, load additional modules so the initrd can
be used as a QEMU guest with para-virtualized I/O drivers.
When VOLATILE-ROOT? is true, the root file system is writable but any changes When VOLATILE-ROOT? is true, the root file system is writable but any changes
to it are lost. to it are lost.
@ -221,6 +223,11 @@ When GUILE-MODULES-IN-CHROOT? is true, make core Guile modules available in
the new root. This is necessary is the file specified as '--load' needs the new root. This is necessary is the file specified as '--load' needs
access to these modules (which is the case if it wants to even just print an access to these modules (which is the case if it wants to even just print an
exception and backtrace!)." exception and backtrace!)."
(define virtio-modules
;; Modules for Linux para-virtualized devices, for use in QEMU guests.
'("virtio.ko" "virtio_ring.ko" "virtio_pci.ko"
"virtio_balloon.ko" "virtio_blk.ko" "virtio_net.ko"))
(define cifs-modules (define cifs-modules
;; Modules needed to mount CIFS file systems. ;; Modules needed to mount CIFS file systems.
'("md4.ko" "ecb.ko" "cifs.ko")) '("md4.ko" "ecb.ko" "cifs.ko"))
@ -235,8 +242,9 @@ exception and backtrace!)."
(define linux-modules (define linux-modules
;; Modules added to the initrd and loaded from the initrd. ;; Modules added to the initrd and loaded from the initrd.
`("virtio.ko" "virtio_ring.ko" "virtio_pci.ko" `(,@(if (or virtio? qemu-networking?)
"virtio_balloon.ko" "virtio_blk.ko" "virtio_net.ko" virtio-modules
'())
,@(if (find (file-system-type-predicate "cifs") file-systems) ,@(if (find (file-system-type-predicate "cifs") file-systems)
cifs-modules cifs-modules
'()) '())

View File

@ -154,6 +154,7 @@ made available under the /xchg CIFS share."
(initrd (if initrd ; use the default initrd? (initrd (if initrd ; use the default initrd?
(return initrd) (return initrd)
(qemu-initrd %linux-vm-file-systems (qemu-initrd %linux-vm-file-systems
#:virtio? #t
#:guile-modules-in-chroot? #t)))) #:guile-modules-in-chroot? #t))))
(define builder (define builder
@ -349,7 +350,9 @@ of the GNU system as described by OS."
"Return an operating system based on OS suitable for use in a virtualized "Return an operating system based on OS suitable for use in a virtualized
environment with the store shared with the host." environment with the store shared with the host."
(operating-system (inherit os) (operating-system (inherit os)
(initrd (cut qemu-initrd <> #:volatile-root? #t)) (initrd (cut qemu-initrd <>
#:volatile-root? #t
#:virtio? #t))
(file-systems (cons* (file-system (file-systems (cons* (file-system
(mount-point "/") (mount-point "/")
(device "/dev/vda1") (device "/dev/vda1")