vm: Only pass "-enable-kvm" to qemu if /dev/kvm is present.
Fixes <http://bugs.gnu.org/22633>. * gnu/build/vm.scm (load-in-linux-vm): Only pass "-enable-kvm" flag to qemu if "/dev/kvm" is present. * gnu/system/vm.scm (common-kvm-options): Same as above.
This commit is contained in:
		
							parent
							
								
									8b16a5e199
								
							
						
					
					
						commit
						944d2b17b5
					
				
					 2 changed files with 23 additions and 6 deletions
				
			
		|  | @ -1,5 +1,7 @@ | ||||||
| ;;; GNU Guix --- Functional package management for GNU | ;;; GNU Guix --- Functional package management for GNU | ||||||
| ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> | ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> | ||||||
|  | ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org> | ||||||
|  | ;;; Copyright © 2016 Leo Famulari <leo@famulari.name> | ||||||
| ;;; | ;;; | ||||||
| ;;; This file is part of GNU Guix. | ;;; This file is part of GNU Guix. | ||||||
| ;;; | ;;; | ||||||
|  | @ -97,7 +99,7 @@ the #:references-graphs parameter of 'derivation'." | ||||||
|     (_ #f)) |     (_ #f)) | ||||||
| 
 | 
 | ||||||
|   (unless (zero? |   (unless (zero? | ||||||
|            (apply system* qemu "-enable-kvm" "-nographic" "-no-reboot" |            (apply system* qemu "-nographic" "-no-reboot" | ||||||
|                   "-m" (number->string memory-size) |                   "-m" (number->string memory-size) | ||||||
|                   "-net" "nic,model=virtio" |                   "-net" "nic,model=virtio" | ||||||
|                   "-virtfs" |                   "-virtfs" | ||||||
|  | @ -111,10 +113,17 @@ the #:references-graphs parameter of 'derivation'." | ||||||
|                   "-initrd" initrd |                   "-initrd" initrd | ||||||
|                   "-append" (string-append "console=ttyS0 --load=" |                   "-append" (string-append "console=ttyS0 --load=" | ||||||
|                                            builder) |                                            builder) | ||||||
|  |                   (append | ||||||
|                    (if make-disk-image? |                    (if make-disk-image? | ||||||
|                        `("-drive" ,(string-append "file=" image-file |                        `("-drive" ,(string-append "file=" image-file | ||||||
|                                                   ",if=virtio")) |                                                   ",if=virtio")) | ||||||
|                       '()))) |                        '()) | ||||||
|  |                    ;; Only enable kvm if we see /dev/kvm exists. | ||||||
|  |                    ;; This allows users without hardware virtualization to still | ||||||
|  |                    ;; use these commands. | ||||||
|  |                    (if (file-exists? "/dev/kvm") | ||||||
|  |                        '("-enable-kvm") | ||||||
|  |                        '())))) | ||||||
|     (error "qemu failed" qemu)) |     (error "qemu failed" qemu)) | ||||||
| 
 | 
 | ||||||
|   (if make-disk-image? |   (if make-disk-image? | ||||||
|  |  | ||||||
|  | @ -1,5 +1,7 @@ | ||||||
| ;;; GNU Guix --- Functional package management for GNU | ;;; GNU Guix --- Functional package management for GNU | ||||||
| ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> | ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> | ||||||
|  | ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org> | ||||||
|  | ;;; Copyright © 2016 Leo Famulari <leo@famulari.name> | ||||||
| ;;; | ;;; | ||||||
| ;;; This file is part of GNU Guix. | ;;; This file is part of GNU Guix. | ||||||
| ;;; | ;;; | ||||||
|  | @ -457,7 +459,13 @@ with '-virtfs' options for the host file systems listed in SHARED-FS." | ||||||
|                      "\" ")) |                      "\" ")) | ||||||
| 
 | 
 | ||||||
|   #~(string-append |   #~(string-append | ||||||
|      " -enable-kvm -no-reboot -net nic,model=virtio \ |      ;; Only enable kvm if we see /dev/kvm exists. | ||||||
|  |      ;; This allows users without hardware virtualization to still use these | ||||||
|  |      ;; commands. | ||||||
|  |      #$(if (file-exists? "/dev/kvm") | ||||||
|  |            " -enable-kvm " | ||||||
|  |            "") | ||||||
|  |      " -no-reboot -net nic,model=virtio \ | ||||||
|   " #$@(map virtfs-option shared-fs) " \ |   " #$@(map virtfs-option shared-fs) " \ | ||||||
|   -net user \ |   -net user \ | ||||||
|   -serial stdio -vga std \ |   -serial stdio -vga std \ | ||||||
|  |  | ||||||
		Reference in a new issue