[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/24: system: vm: Build vm-image using native qemu.
From: |
guix-commits |
Subject: |
03/24: system: vm: Build vm-image using native qemu. |
Date: |
Sun, 17 May 2020 06:00:49 -0400 (EDT) |
janneke pushed a commit to branch wip-hurd-vm
in repository guix.
commit 4db077eee91c51ac0a77f9c90c6f9a3869d9e649
Author: Jan (janneke) Nieuwenhuizen <address@hidden>
AuthorDate: Sat May 2 19:17:34 2020 +0200
system: vm: Build vm-image using native qemu.
Cross-building a vm-image used to be done using a cross-qemu, e.g, qemu-ARM.
That does not work for the Hurd, as there is no qemu-HURD.
This patch switches to cross building vm-images using a native qemu vm.
* gnu/system/vm.scm (expression->derivation-in-linux-vm): Run native
qemu-command; use native linux, initrd, bootloader-package and
bootloader-installer.
[preserve-target]: New helper to install cross-packages into the native vm.
* gnu/bootloader/grub.scm (eye-candy): Use native font.
Co-authored-by: Ludovic Courtès <address@hidden>
---
gnu/bootloader/grub.scm | 4 ++--
gnu/system/vm.scm | 46 +++++++++++++++++++++++++++++-----------------
2 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 8c5b5ea..842592c 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -211,8 +211,8 @@ else
set menu_color_highlight=white/blue
fi~%"
#$setup-gfxterm-body
- #$(grub-root-search store-device font-file)
- #$(setup-gfxterm config font-file)
+ #+(grub-root-search store-device font-file)
+ #+(setup-gfxterm config font-file)
#$(grub-setup-io config)
#$(strip-mount-point store-mount-point image)
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 97b0bf4..aa094b0 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2017 Mathieu Othacehe <address@hidden>
;;; Copyright © 2017 Marius Bakke <address@hidden>
;;; Copyright © 2018 Chris Marusich <address@hidden>
+;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -180,19 +181,30 @@ made available under the /xchg CIFS share.
SUBSTITUTABLE? determines whether the returned derivation should be marked as
substitutable."
(define user-builder
- (program-file "builder-in-linux-vm" exp))
+ (scheme-file "builder-in-linux-vm" exp))
+
+ (define (preserve-target obj)
+ (if target
+ (with-parameters ((%current-target-system target))
+ obj)
+ obj))
(define loader
- ;; Invoke USER-BUILDER instead using 'primitive-load'. The reason for
- ;; this is to allow USER-BUILDER to dlopen stuff by using a full-featured
- ;; Guile, which it couldn't do using the statically-linked guile used in
- ;; the initrd. See example at
+ ;; Instead of using 'primitive-load', evaluate USER-BUILDER in a
+ ;; full-featured Guile so it can use dlopen stuff, which it couldn't do
+ ;; using the statically-linked guile used in the initrd. See example at
;; <https://lists.gnu.org/archive/html/guix-devel/2017-10/msg00233.html>.
(program-file "linux-vm-loader"
- ;; Communicate USER-BUILDER's exit status via /xchg so that
- ;; the host can distinguish between success, failure, and
- ;; kernel panic.
- #~(let ((status (system* #$user-builder)))
+ ;; When cross-compiling, USER-BUILDER refers to the target
+ ;; (cross-compiled) system. Preserve that, even though
+ ;; LOADER itself is executed as a native program.
+ #~(let ((status (system* #+(file-append (default-guile)
+ "/bin/guile")
+ "--no-auto-compile"
+ #$(preserve-target user-builder))))
+ ;; Communicate USER-BUILDER's exit status via /xchg so
+ ;; that the host can distinguish between success,
+ ;; failure, and kernel panic.
(call-with-output-file "/xchg/.exit-status"
(lambda (port)
(write status port)))
@@ -226,10 +238,10 @@ substitutable."
(let* ((native-inputs
'#+(list qemu (canonical-package coreutils)))
- (linux (string-append #$linux "/"
- #$(system-linux-image-file-name)))
- (initrd #$initrd)
- (loader #$loader)
+ (linux (string-append #+linux "/"
+ #+(system-linux-image-file-name)))
+ (initrd #+initrd)
+ (loader #+loader)
(graphs '#$(match references-graphs
(((graph-files . _) ...) graph-files)
(_ #f)))
@@ -245,7 +257,7 @@ substitutable."
(load-in-linux-vm loader
#:output #$output
#:linux linux #:initrd initrd
- #:qemu (qemu-command target)
+ #:qemu (qemu-command)
#:memory-size #$memory-size
#:make-disk-image? #$make-disk-image?
#:single-file-output? #$single-file-output?
@@ -348,7 +360,7 @@ system that is passed to 'populate-root-file-system'."
(setlocale LC_ALL "en_US.utf8")
(let ((inputs
- '#$(append (list parted e2fsprogs dosfstools)
+ '#+(append (list parted e2fsprogs dosfstools)
(map canonical-package
(list sed grep coreutils findutils gawk))))
@@ -425,12 +437,12 @@ system that is passed to 'populate-root-file-system'."
#:partitions partitions
#:grub-efi grub-efi
#:bootloader-package
- #$(bootloader-package bootloader)
+ #+(bootloader-package bootloader)
#:bootcfg #$bootcfg-drv
#:bootcfg-location
#$(bootloader-configuration-file
bootloader)
#:bootloader-installer
- #$(bootloader-installer bootloader)))))))
+ #+(bootloader-installer bootloader)))))))
#:system system
#:target target
#:make-disk-image? #t
- branch wip-hurd-vm created (now e4e1876), guix-commits, 2020/05/17
- 01/24: utils: Move 'reset-timestamps' out of database., guix-commits, 2020/05/17
- 02/24: system: vm: Do not register-closures when cross-building., guix-commits, 2020/05/17
- 03/24: system: vm: Build vm-image using native qemu.,
guix-commits <=
- 05/24: system: hurd: Add hurd-default-essential-services., guix-commits, 2020/05/17
- 11/24: system: Use 'hurd' package in label., guix-commits, 2020/05/17
- 08/24: system: Add 'hurd' field to <boot-parameters>., guix-commits, 2020/05/17
- 16/24: gnu: hurd: Create minimal "runsystem" script to invoke "rc"., guix-commits, 2020/05/17
- 07/24: bootloader: Add `<hurd-menu-entry>'., guix-commits, 2020/05/17
- 09/24: bootloader: grub: Add support for '<hurd-menu-entry>'., guix-commits, 2020/05/17
- 13/24: services: hurd: Add `hurd-etc-service'., guix-commits, 2020/05/17
- 12/24: system: examples: Add bare-hurd.tmpl., guix-commits, 2020/05/17
- 14/24: system: Add `hurd-activation'., guix-commits, 2020/05/17
- 17/24: services: Add `hurd-console-service-type'., guix-commits, 2020/05/17