diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index a5d9fefa62..aa2418f495 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -30,6 +30,7 @@ #:use-module (gnu build install) #:use-module (gnu system uuid) #:use-module (guix records) + #:use-module (guix utils) #:use-module ((guix combinators) #:select (fold2)) #:use-module (ice-9 format) #:use-module (ice-9 match) @@ -81,6 +82,7 @@ linux initrd make-disk-image? single-file-output? + target-arm? target-arm32? (disk-image-size (* 100 (expt 2 20))) (disk-image-format "qcow2") @@ -100,14 +102,16 @@ the #:references-graphs parameter of 'derivation'." (define arch-specific-flags `(;; On ARM, a machine has to be specified. Use "virt" machine to avoid ;; hardware limits imposed by other machines. - ,@(if target-arm32? '("-M" "virt") '()) + ;,@(if target-arm? '("-M" "virt") '()) + "-M" "virt" ;; Only enable kvm if we see /dev/kvm exists. This allows users without ;; hardware virtualization to still use these commands. KVM support is ;; still buggy on some ARM32 boards. Do not use it even if available. ,@(if (and (file-exists? "/dev/kvm") - (not target-arm32?)) - '("-enable-kvm") + (not target-arm?)) + ;'("-enable-kvm") + '() '()) ;; Pass "panic=1" so that the guest dies upon error. @@ -117,11 +121,11 @@ the #:references-graphs parameter of 'derivation'." ;; The serial port name differs between emulated ;; architectures/machines. " console=" - (if target-arm32? "ttyAMA0" "ttyS0")) + (if target-arm? "ttyAMA0" "ttyS0")) ;; NIC is not supported on ARM "virt" machine, so use a user mode ;; network stack instead. - ,@(if target-arm32? + ,@(if target-arm? '("-device" "virtio-net-pci,netdev=mynet" "-netdev" "user,id=mynet") '("-net" "nic,model=virtio")))) diff --git a/guix/utils.scm b/guix/utils.scm index 1f99c5b3f5..c1eeff7b07 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -78,6 +78,7 @@ package-name->name+version target-mingw? target-arm32? + target-arm? target-64bit? version-compare version>? @@ -494,6 +495,10 @@ a character other than '@'." (define (target-arm32?) (string-prefix? "arm" (or (%current-target-system) (%current-system)))) +(define (target-arm?) + (let ((system (or (%current-target-system) (%current-system)))) + (any (cut string-prefix? <> system) '("armhf" "aarch64")))) + (define (target-64bit?) (let ((system (or (%current-target-system) (%current-system)))) (any (cut string-prefix? <> system) '("x86_64" "aarch64" "mips64" "ppc64"))))