gnu: Add emacs-slime.
[jackhill/guix/guix.git] / gnu / packages / qemu.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2016 Mark H Weaver <mhw@netris.org>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages qemu)
21 #:use-module (guix download)
22 #:use-module (guix packages)
23 #:use-module (guix utils)
24 #:use-module ((guix licenses) #:select (gpl2))
25 #:use-module (guix build-system gnu)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages autotools)
28 #:use-module (gnu packages texinfo)
29 #:use-module (gnu packages pkg-config)
30 #:use-module (gnu packages glib)
31 #:use-module (gnu packages python)
32 #:use-module (gnu packages ncurses)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages image)
35 #:use-module (gnu packages attr)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages libusb)
38 #:use-module (gnu packages xdisorg)
39 #:use-module (gnu packages gl)
40 #:use-module (gnu packages sdl)
41 #:use-module (gnu packages perl)
42 #:use-module (srfi srfi-1))
43
44 (define (qemu-patch commit file-name sha256)
45 "Return an origin for COMMIT."
46 (origin
47 (method url-fetch)
48 (uri (string-append
49 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
50 commit))
51 (sha256 sha256)
52 (file-name file-name)))
53
54 (define-public qemu
55 (package
56 (name "qemu")
57 (version "2.5.0")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append "http://wiki.qemu-project.org/download/qemu-"
61 version ".tar.bz2"))
62 (sha256
63 (base32
64 "1m3j6xl7msrniidkvr5pw9d44yba5m7hm42xz8xy77v105s8hhrl"))
65 (patches
66 (map search-patch
67 '("qemu-virtio-9p-use-accessor-to-get-thread-pool.patch"
68 "qemu-CVE-2015-8558.patch"
69 "qemu-CVE-2015-8567.patch"
70 "qemu-CVE-2016-1922.patch"
71 "qemu-CVE-2015-8613.patch"
72 "qemu-CVE-2015-8701.patch"
73 "qemu-CVE-2015-8743.patch"
74 "qemu-CVE-2016-1568.patch")))))
75 (build-system gnu-build-system)
76 (arguments
77 '(#:phases (alist-replace
78 'configure
79 (lambda* (#:key inputs outputs (configure-flags '())
80 #:allow-other-keys)
81 ;; The `configure' script doesn't understand some of the
82 ;; GNU options. Thus, add a new phase that's compatible.
83 (let ((out (assoc-ref outputs "out")))
84 (setenv "SHELL" (which "bash"))
85
86 ;; While we're at it, patch for tests.
87 (substitute* "tests/libqtest.c"
88 (("/bin/sh") (which "sh")))
89
90 ;; The binaries need to be linked against -lrt.
91 (setenv "LDFLAGS" "-lrt")
92 (zero?
93 (apply system*
94 `("./configure"
95 ,(string-append "--cc=" (which "gcc"))
96 "--disable-debug-info" ; save build space
97 "--enable-virtfs" ; just to be sure
98 ,(string-append "--prefix=" out)
99 ,@configure-flags)))))
100 (alist-cons-after
101 'install 'install-info
102 (lambda* (#:key inputs outputs #:allow-other-keys)
103 ;; Install the Info manual, unless Texinfo is missing.
104 (or (not (assoc-ref inputs "texinfo"))
105 (let ((out (assoc-ref outputs "out")))
106 (and (zero? (system* "make" "info"))
107 (let ((infodir (string-append out "/share/info")))
108 (mkdir-p infodir)
109 (for-each (lambda (info)
110 (copy-file
111 info
112 (string-append infodir "/" info)))
113 (find-files "." "\\.info$"))
114 #t)))))
115 (alist-cons-before
116 'check 'disable-test-qga
117 (lambda _
118 (substitute* "tests/Makefile"
119 ;; Comment out the test-qga test, which needs /sys and
120 ;; fails within the build environment.
121 (("check-unit-.* tests/test-qga" all)
122 (string-append "# " all)))
123 #t)
124 %standard-phases)))))
125
126 (inputs ; TODO: Add optional inputs.
127 `(("sdl" ,sdl)
128 ("mesa" ,mesa)
129 ("libusb" ,libusb) ;USB pass-through support
130
131 ;; ("libaio" ,libaio)
132 ("glib" ,glib)
133 ("ncurses" ,ncurses)
134 ("libpng" ,libpng)
135 ("libjpeg" ,libjpeg-8)
136 ("pixman" ,pixman)
137 ;; ("vde2" ,vde2)
138 ("util-linux" ,util-linux)
139 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
140 ("libattr" ,attr)
141 ;; ("pciutils" ,pciutils)
142 ("alsa-lib" ,alsa-lib)
143 ("zlib" ,zlib)
144 ("attr" ,attr)))
145 (native-inputs `(("pkg-config" ,pkg-config)
146 ("python" ,python-2) ; incompatible with Python 3 according to error message
147 ("glib" ,glib "bin") ; gtester, etc.
148 ("texinfo" ,texinfo)
149 ("perl" ,perl)))
150 (home-page "http://www.qemu-project.org")
151 (synopsis "Machine emulator and virtualizer")
152 (description
153 "QEMU is a generic machine emulator and virtualizer.
154
155 When used as a machine emulator, QEMU can run OSes and programs made for one
156 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
157 using dynamic translation, it achieves very good performance.
158
159 When used as a virtualizer, QEMU achieves near native performances by
160 executing the guest code directly on the host CPU. QEMU supports
161 virtualization when executing under the Xen hypervisor or using
162 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
163 server and embedded PowerPC, and S390 guests.")
164
165 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
166 (license gpl2)
167
168 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
169 (supported-systems (delete "mips64el-linux" %supported-systems))))
170
171 (define-public qemu-minimal
172 ;; QEMU without GUI support.
173 (package (inherit qemu)
174 (name "qemu-minimal")
175 (synopsis "Machine emulator and virtualizer (without GUI)")
176 (arguments
177 `(#:configure-flags
178 ;; Restrict to the targets supported by Guix.
179 '("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu")
180 ,@(package-arguments qemu)))
181
182 ;; Remove dependencies on optional libraries, notably GUI libraries.
183 (inputs (fold alist-delete (package-inputs qemu)
184 '("sdl" "mesa" "libusb")))))