gnu: python-pandas: Fix build on 32-bit.
[jackhill/guix/guix.git] / gnu / packages / qemu.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages qemu)
23 #:use-module (gnu packages)
24 #:use-module (gnu packages admin)
25 #:use-module (gnu packages attr)
26 #:use-module (gnu packages autotools)
27 #:use-module (gnu packages check)
28 #:use-module (gnu packages compression)
29 #:use-module (gnu packages curl)
30 #:use-module (gnu packages cyrus-sasl)
31 #:use-module (gnu packages disk)
32 #:use-module (gnu packages gl)
33 #:use-module (gnu packages glib)
34 #:use-module (gnu packages gnome)
35 #:use-module (gnu packages gtk)
36 #:use-module (gnu packages image)
37 #:use-module (gnu packages libusb)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages ncurses)
40 #:use-module (gnu packages perl)
41 #:use-module (gnu packages pkg-config)
42 #:use-module (gnu packages polkit)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages sdl)
45 #:use-module (gnu packages spice)
46 #:use-module (gnu packages texinfo)
47 #:use-module (gnu packages tls)
48 #:use-module (gnu packages web)
49 #:use-module (gnu packages xdisorg)
50 #:use-module (gnu packages xml)
51 #:use-module (guix build-system gnu)
52 #:use-module (guix build-system python)
53 #:use-module (guix download)
54 #:use-module ((guix licenses) #:select (gpl2 gpl2+ lgpl2.1+))
55 #:use-module (guix packages)
56 #:use-module (guix utils)
57 #:use-module (srfi srfi-1))
58
59 (define (qemu-patch commit file-name sha256)
60 "Return an origin for COMMIT."
61 (origin
62 (method url-fetch)
63 (uri (string-append
64 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
65 commit))
66 (sha256 sha256)
67 (file-name file-name)))
68
69 (define-public qemu
70 (package
71 (name "qemu")
72 (version "2.8.0")
73 (source (origin
74 (method url-fetch)
75 (uri (string-append "http://wiki.qemu-project.org/download/qemu-"
76 version ".tar.bz2"))
77 (sha256
78 (base32
79 "0qjy3rcrn89n42y5iz60kgr0rrl29hpnj8mq2yvbc1wrcizmvzfs"))
80 (patches (search-patches "qemu-CVE-2016-10155.patch"
81 "qemu-CVE-2017-2615.patch"
82 "qemu-CVE-2017-5525.patch"
83 "qemu-CVE-2017-5526.patch"
84 "qemu-CVE-2017-5552.patch"
85 "qemu-CVE-2017-5578.patch"
86 "qemu-CVE-2017-5579.patch"
87 "qemu-CVE-2017-5667.patch"
88 "qemu-CVE-2017-5856.patch"
89 "qemu-CVE-2017-5898.patch"
90 "qemu-CVE-2017-5931.patch"))))
91 (build-system gnu-build-system)
92 (arguments
93 '(;; Running tests in parallel can occasionally lead to failures, like:
94 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
95 #:parallel-tests? #f
96
97 #:phases
98 (modify-phases %standard-phases
99 (replace 'configure
100 (lambda* (#:key inputs outputs (configure-flags '())
101 #:allow-other-keys)
102 ;; The `configure' script doesn't understand some of the
103 ;; GNU options. Thus, add a new phase that's compatible.
104 (let ((out (assoc-ref outputs "out")))
105 (setenv "SHELL" (which "bash"))
106
107 ;; While we're at it, patch for tests.
108 (substitute* "tests/libqtest.c"
109 (("/bin/sh") (which "sh")))
110
111 ;; The binaries need to be linked against -lrt.
112 (setenv "LDFLAGS" "-lrt")
113 (zero?
114 (apply system*
115 `("./configure"
116 ,(string-append "--cc=" (which "gcc"))
117 ;; Some architectures insist on using HOST_CC
118 ,(string-append "--host-cc=" (which "gcc"))
119 "--disable-debug-info" ; save build space
120 "--enable-virtfs" ; just to be sure
121 ,(string-append "--prefix=" out)
122 ,@configure-flags))))))
123 (add-after 'install 'install-info
124 (lambda* (#:key inputs outputs #:allow-other-keys)
125 ;; Install the Info manual, unless Texinfo is missing.
126 (or (not (assoc-ref inputs "texinfo"))
127 (let ((out (assoc-ref outputs "out")))
128 (and (zero? (system* "make" "info"))
129 (let ((infodir (string-append out "/share/info")))
130 (for-each (lambda (info)
131 (install-file info infodir))
132 (find-files "." "\\.info"))
133 #t))))))
134 (add-before 'check 'make-gtester-verbose
135 (lambda _
136 ;; Make GTester verbose to facilitate investigation upon failure.
137 (setenv "V" "1") #t))
138 (add-before 'check 'disable-test-qga
139 (lambda _
140 (substitute* "tests/Makefile.include"
141 ;; Comment out the test-qga test, which needs /sys and
142 ;; fails within the build environment.
143 (("check-unit-.* tests/test-qga" all)
144 (string-append "# " all)))
145 #t)))))
146 (inputs ; TODO: Add optional inputs.
147 `(("alsa-lib" ,alsa-lib)
148 ("attr" ,attr)
149 ("glib" ,glib)
150 ;; ("libaio" ,libaio)
151 ("libattr" ,attr)
152 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
153 ("libjpeg" ,libjpeg-8)
154 ("libpng" ,libpng)
155 ("libusb" ,libusb) ;USB pass-through support
156 ("mesa" ,mesa)
157 ("ncurses" ,ncurses)
158 ;; ("pciutils" ,pciutils)
159 ("pixman" ,pixman)
160 ("sdl" ,sdl)
161 ("spice" ,spice)
162 ("util-linux" ,util-linux)
163 ;; ("vde2" ,vde2)
164 ("virglrenderer" ,virglrenderer)
165 ("zlib" ,zlib)))
166 (native-inputs `(("glib:bin" ,glib "bin") ; gtester, etc.
167 ("perl" ,perl)
168 ("pkg-config" ,pkg-config)
169 ("python" ,python-2) ; incompatible with Python 3 according to error message
170 ("texinfo" ,texinfo)))
171 (home-page "http://www.qemu-project.org")
172 (synopsis "Machine emulator and virtualizer")
173 (description
174 "QEMU is a generic machine emulator and virtualizer.
175
176 When used as a machine emulator, QEMU can run OSes and programs made for one
177 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
178 using dynamic translation, it achieves very good performance.
179
180 When used as a virtualizer, QEMU achieves near native performances by
181 executing the guest code directly on the host CPU. QEMU supports
182 virtualization when executing under the Xen hypervisor or using
183 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
184 server and embedded PowerPC, and S390 guests.")
185
186 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
187 (license gpl2)
188
189 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
190 (supported-systems (delete "mips64el-linux" %supported-systems))))
191
192 (define-public qemu-minimal
193 ;; QEMU without GUI support.
194 (package (inherit qemu)
195 (name "qemu-minimal")
196 (synopsis "Machine emulator and virtualizer (without GUI)")
197 (arguments
198 `(#:configure-flags
199 ;; Restrict to the targets supported by Guix.
200 '("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu")
201 ,@(package-arguments qemu)))
202
203 ;; Remove dependencies on optional libraries, notably GUI libraries.
204 (inputs (fold alist-delete (package-inputs qemu)
205 '("libusb" "mesa" "sdl" "spice" "virglrenderer")))))
206
207 (define-public libosinfo
208 (package
209 (name "libosinfo")
210 (version "1.0.0")
211 (source
212 (origin
213 (method url-fetch)
214 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
215 version ".tar.gz"))
216 (sha256
217 (base32
218 "0srrs2m6irqd4f867g8ls6jp2dq3ql0l9d0fh80d55sivvn2bd7p"))))
219 (build-system gnu-build-system)
220 (arguments
221 `(#:configure-flags
222 (list (string-append "--with-usb-ids-path="
223 (assoc-ref %build-inputs "usb.ids"))
224 (string-append "--with-pci-ids-path="
225 (assoc-ref %build-inputs "pci.ids")))
226 #:phases
227 (modify-phases %standard-phases
228 ;; This odd test fails for unknown reasons.
229 (add-after 'unpack 'disable-broken-test
230 (lambda _
231 (substitute* "test/Makefile.in"
232 (("test-isodetect\\$\\(EXEEXT\\)") ""))
233 #t)))))
234 (inputs
235 `(("libsoup" ,libsoup)
236 ("libxml2" ,libxml2)
237 ("libxslt" ,libxslt)
238 ("gobject-introspection" ,gobject-introspection)))
239 (native-inputs
240 `(("check" ,check)
241 ("glib" ,glib "bin") ; glib-mkenums, etc.
242 ("gtk-doc" ,gtk-doc)
243 ("vala" ,vala)
244 ("intltool" ,intltool)
245 ("pkg-config" ,pkg-config)
246 ("pci.ids"
247 ,(origin
248 (method url-fetch)
249 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
250 (sha256
251 (base32
252 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
253 ("usb.ids"
254 ,(origin
255 (method url-fetch)
256 (uri "http://linux-usb.cvs.sourceforge.net/viewvc/linux-usb/htdocs/usb.ids?revision=1.551")
257 (file-name "usb.ids")
258 (sha256
259 (base32
260 "17rg5i0wbyk289gr8v4kgvnc9q5bidz7ldcvv9x58l083wn16hq3"))))))
261 (home-page "https://libosinfo.org/")
262 (synopsis "Operating system information database")
263 (description "libosinfo is a GObject based library API for managing
264 information about operating systems, hypervisors and the (virtual) hardware
265 devices they can support. It includes a database containing device metadata
266 and provides APIs to match/identify optimal devices for deploying an operating
267 system on a hypervisor. Via GObject Introspection, the API is available in
268 all common programming languages. Vala bindings are also provided.")
269 ;; The library files are released under LGPLv2.1 or later; the source
270 ;; files in the "tools" directory are released under GPLv2+.
271 (license (list lgpl2.1+ gpl2+))))
272
273 (define-public libvirt
274 (package
275 (name "libvirt")
276 (version "2.1.0")
277 (source (origin
278 (method url-fetch)
279 (uri (string-append "http://libvirt.org/sources/libvirt-"
280 version ".tar.xz"))
281 (sha256
282 (base32
283 "0sriasjc573c519yqw1hcfb3qqjcsm9hm8vayw0anwkl6di9ay8s"))))
284 (build-system gnu-build-system)
285 (arguments
286 `(;; FAIL: virshtest
287 ;; FAIL: virfirewalltest
288 ;; FAIL: virkmodtest
289 ;; FAIL: virnetsockettest
290 ;; FAIL: networkxml2firewalltest
291 ;; FAIL: nwfilterebiptablestest
292 ;; FAIL: nwfilterxml2firewalltest
293 ;; Times out after PASS: virsh-vcpupin
294 #:tests? #f
295 #:configure-flags
296 (list "--with-polkit"
297 "--localstatedir=/var")
298 #:phases
299 (modify-phases %standard-phases
300 (add-after 'unpack 'fix-tests
301 (lambda _
302 (substitute* '("tests/commandtest.c"
303 "gnulib/tests/test-posix_spawn1.c"
304 "gnulib/tests/test-posix_spawn2.c")
305 (("/bin/sh") (which "sh")))
306 #t))
307 (add-after 'unpack 'do-not-mkdir-in-/var
308 ;; Since the localstatedir should be /var at runtime, we must
309 ;; prevent writing to /var at installation time.
310 (lambda* (#:key outputs #:allow-other-keys)
311 (let* ((out (assoc-ref outputs "out"))
312 (localstatedir (string-append out "/var")))
313 (substitute* '("src/Makefile.in"
314 "daemon/Makefile.in")
315 (("\\$\\(DESTDIR\\)\\$\\(localstatedir)") localstatedir)))
316 #t)))))
317 (inputs
318 `(("libxml2" ,libxml2)
319 ("gnutls" ,gnutls)
320 ("dbus" ,dbus)
321 ("qemu" ,qemu)
322 ("polkit" ,polkit)
323 ("libpcap" ,libpcap)
324 ("libnl" ,libnl)
325 ("libuuid" ,util-linux)
326 ("lvm2" ,lvm2) ; for libdevmapper
327 ("curl" ,curl)
328 ("openssl" ,openssl)
329 ("cyrus-sasl" ,cyrus-sasl)
330 ("perl" ,perl)
331 ("python" ,python-2)
332 ("libyajl" ,libyajl)
333 ("audit" ,audit)))
334 (native-inputs
335 `(("pkg-config" ,pkg-config)))
336 (home-page "http://libvirt.org")
337 (synopsis "Simple API for virtualization")
338 (description "Libvirt is a C toolkit to interact with the virtualization
339 capabilities of recent versions of Linux. The library aims at providing long
340 term stable C API initially for the Xen paravirtualization but should be able
341 to integrate other virtualization mechanisms if needed.")
342 (license lgpl2.1+)))
343
344 (define-public libvirt-glib
345 (package
346 (name "libvirt-glib")
347 (version "0.2.3")
348 (source (origin
349 (method url-fetch)
350 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
351 "libvirt-glib-" version ".tar.gz"))
352 (sha256
353 (base32
354 "1pahj8qa7k2307sd57rwqwq1hijya02v0sxk91hl3cw48niimcf3"))))
355 (build-system gnu-build-system)
356 (arguments
357 `(#:phases
358 (modify-phases %standard-phases
359 (add-after 'unpack 'fix-tests
360 (lambda _
361 (substitute* "tests/test-events.c"
362 (("/bin/true") (which "true")))
363 #t)))))
364 (inputs
365 `(("libxml2" ,libxml2)
366 ("libvirt" ,libvirt)
367 ("gobject-introspection" ,gobject-introspection)
368 ("glib" ,glib)
369 ("openssl" ,openssl)
370 ("cyrus-sasl" ,cyrus-sasl)
371 ("lvm2" ,lvm2) ; for libdevmapper
372 ("libyajl" ,libyajl)))
373 (native-inputs
374 `(("pkg-config" ,pkg-config)
375 ("intltool" ,intltool)
376 ("glib" ,glib "bin")
377 ("vala" ,vala)))
378 (home-page "http://libvirt.org")
379 (synopsis "GLib wrapper around libvirt")
380 (description "libvirt-glib wraps the libvirt library to provide a
381 high-level object-oriented API better suited for glib-based applications, via
382 three libraries:
383
384 @enumerate
385 @item libvirt-glib - GLib main loop integration & misc helper APIs
386 @item libvirt-gconfig - GObjects for manipulating libvirt XML documents
387 @item libvirt-gobject - GObjects for managing libvirt objects
388 @end enumerate
389 ")
390 (license lgpl2.1+)))
391
392 (define-public python-libvirt
393 (package
394 (name "python-libvirt")
395 (version "2.0.0")
396 (source (origin
397 (method url-fetch)
398 (uri (pypi-uri "libvirt-python" version))
399 (sha256
400 (base32
401 "0h0x5lpsx97bvw20pzfcsdmmivximddq4qmn8fk0n55dqv0wn5kq"))))
402 (build-system python-build-system)
403 (arguments
404 `(#:phases
405 (modify-phases %standard-phases
406 (add-after 'unpack 'patch-nosetests-path
407 (lambda* (#:key inputs #:allow-other-keys)
408 (substitute* "setup.py"
409 (("sys.executable, \"/usr/bin/nosetests\"")
410 (string-append "\"" (which "bash") "\", \""
411 (which "nosetests") "\"")))
412 #t)))))
413 (inputs
414 `(("libvirt" ,libvirt)))
415 (propagated-inputs
416 `(("python-lxml" ,python-lxml)))
417 (native-inputs
418 `(("pkg-config" ,pkg-config)
419 ("python-nose" ,python-nose)))
420 (home-page "http://libvirt.org")
421 (synopsis "Python bindings to libvirt")
422 (description "This package provides Python bindings to the libvirt
423 virtualization library.")
424 (license lgpl2.1+)))
425
426 (define-public python2-libvirt
427 (package-with-python2 python-libvirt))
428
429 (define-public virt-manager
430 (package
431 (name "virt-manager")
432 (version "1.4.0")
433 (source (origin
434 (method url-fetch)
435 (uri (string-append "https://virt-manager.org/download/sources"
436 "/virt-manager/virt-manager-"
437 version ".tar.gz"))
438 (sha256
439 (base32
440 "1jnawqjmcqd2db78ngx05x7cxxn3iy1sb4qfgbwcn045qh6a8cdz"))))
441 (build-system python-build-system)
442 (arguments
443 `(#:python ,python-2
444 #:use-setuptools? #f ; Uses custom distutils 'install' command.
445 ;; Some of the tests seem to require network access to install virtual
446 ;; machines.
447 #:tests? #f
448 #:modules ((ice-9 match)
449 (srfi srfi-26)
450 (guix build python-build-system)
451 (guix build utils))
452 #:phases
453 (modify-phases %standard-phases
454 (add-after 'unpack 'fix-setup
455 (lambda* (#:key outputs #:allow-other-keys)
456 (substitute* "virtcli/cliconfig.py"
457 (("/usr") (assoc-ref outputs "out")))
458 #t))
459 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
460 (lambda* (#:key inputs outputs #:allow-other-keys)
461 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
462 (bin-files (find-files bin ".*"))
463 (paths (map (match-lambda
464 ((output . directory)
465 (let* ((girepodir (string-append
466 directory
467 "/lib/girepository-1.0")))
468 (if (file-exists? girepodir)
469 girepodir #f))))
470 inputs)))
471 (for-each (lambda (file)
472 (format #t "wrapping ~a\n" file)
473 (wrap-program file
474 `("GI_TYPELIB_PATH" ":" prefix
475 ,(filter identity paths))))
476 bin-files))
477 #t)))))
478 (inputs
479 `(("gtk+" ,gtk+)
480 ("libvirt" ,libvirt)
481 ("libvirt-glib" ,libvirt-glib)
482 ("libosinfo" ,libosinfo)
483 ("gobject-introspection" ,gobject-introspection)
484 ("python2-libvirt" ,python2-libvirt)
485 ("python2-requests" ,python2-requests)
486 ("python2-ipaddr" ,python2-ipaddr)
487 ("python2-pygobject" ,python2-pygobject)
488 ("python2-libxml2" ,python2-libxml2)))
489 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
490 (propagated-inputs
491 `(("qemu" ,qemu)))
492 (native-inputs
493 `(("glib" ,glib "bin") ; glib-compile-schemas.
494 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
495 ("perl" ,perl) ; pod2man
496 ("intltool" ,intltool)))
497 (home-page "https://virt-manager.org/")
498 (synopsis "Manage virtual machines")
499 (description
500 "The virt-manager application is a desktop user interface for managing
501 virtual machines through libvirt. It primarily targets KVM VMs, but also
502 manages Xen and LXC (Linux containers). It presents a summary view of running
503 domains, their live performance and resource utilization statistics.")
504 (license gpl2+)))