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>
7 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
59 (define (qemu-patch commit file-name sha256)
60 "Return an origin for COMMIT."
64 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
67 (file-name file-name)))
75 (uri (string-append "http://wiki.qemu-project.org/download/qemu-"
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)
93 '(;; Running tests in parallel can occasionally lead to failures, like:
94 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
98 (modify-phases %standard-phases
100 (lambda* (#:key inputs outputs (configure-flags '())
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"))
107 ;; While we're at it, patch for tests.
108 (substitute* "tests/libqtest.c"
109 (("/bin/sh") (which "sh")))
111 ;; The binaries need to be linked against -lrt.
112 (setenv "LDFLAGS" "-lrt")
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"))
134 (add-before 'check 'make-gtester-verbose
136 ;; Make GTester verbose to facilitate investigation upon failure.
137 (setenv "V" "1") #t))
138 (add-before 'check 'disable-test-qga
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)))
146 (inputs ; TODO: Add optional inputs.
147 `(("alsa-lib" ,alsa-lib)
150 ;; ("libaio" ,libaio)
152 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
153 ("libjpeg" ,libjpeg-8)
155 ("libusb" ,libusb) ;USB pass-through support
158 ;; ("pciutils" ,pciutils)
162 ("util-linux" ,util-linux)
164 ("virglrenderer" ,virglrenderer)
166 (native-inputs `(("glib:bin" ,glib "bin") ; gtester, etc.
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")
174 "QEMU is a generic machine emulator and virtualizer.
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.
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.")
186 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
189 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
190 (supported-systems (delete "mips64el-linux" %supported-systems))))
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)")
199 ;; Restrict to the targets supported by Guix.
200 '("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu")
201 ,@(package-arguments qemu)))
203 ;; Remove dependencies on optional libraries, notably GUI libraries.
204 (inputs (fold alist-delete (package-inputs qemu)
205 '("libusb" "mesa" "sdl" "spice" "virglrenderer")))))
207 (define-public libosinfo
214 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
218 "0srrs2m6irqd4f867g8ls6jp2dq3ql0l9d0fh80d55sivvn2bd7p"))))
219 (build-system gnu-build-system)
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")))
227 (modify-phases %standard-phases
228 ;; This odd test fails for unknown reasons.
229 (add-after 'unpack 'disable-broken-test
231 (substitute* "test/Makefile.in"
232 (("test-isodetect\\$\\(EXEEXT\\)") ""))
235 `(("libsoup" ,libsoup)
238 ("gobject-introspection" ,gobject-introspection)))
241 ("glib" ,glib "bin") ; glib-mkenums, etc.
244 ("intltool" ,intltool)
245 ("pkg-config" ,pkg-config)
249 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
252 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
256 (uri "http://linux-usb.cvs.sourceforge.net/viewvc/linux-usb/htdocs/usb.ids?revision=1.551")
257 (file-name "usb.ids")
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+))))
273 (define-public libvirt
279 (uri (string-append "http://libvirt.org/sources/libvirt-"
283 "0sriasjc573c519yqw1hcfb3qqjcsm9hm8vayw0anwkl6di9ay8s"))))
284 (build-system gnu-build-system)
287 ;; FAIL: virfirewalltest
289 ;; FAIL: virnetsockettest
290 ;; FAIL: networkxml2firewalltest
291 ;; FAIL: nwfilterebiptablestest
292 ;; FAIL: nwfilterxml2firewalltest
293 ;; Times out after PASS: virsh-vcpupin
296 (list "--with-polkit"
297 "--localstatedir=/var")
299 (modify-phases %standard-phases
300 (add-after 'unpack 'fix-tests
302 (substitute* '("tests/commandtest.c"
303 "gnulib/tests/test-posix_spawn1.c"
304 "gnulib/tests/test-posix_spawn2.c")
305 (("/bin/sh") (which "sh")))
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)))
318 `(("libxml2" ,libxml2)
325 ("libuuid" ,util-linux)
326 ("lvm2" ,lvm2) ; for libdevmapper
329 ("cyrus-sasl" ,cyrus-sasl)
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.")
344 (define-public libvirt-glib
346 (name "libvirt-glib")
350 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
351 "libvirt-glib-" version ".tar.gz"))
354 "1pahj8qa7k2307sd57rwqwq1hijya02v0sxk91hl3cw48niimcf3"))))
355 (build-system gnu-build-system)
358 (modify-phases %standard-phases
359 (add-after 'unpack 'fix-tests
361 (substitute* "tests/test-events.c"
362 (("/bin/true") (which "true")))
365 `(("libxml2" ,libxml2)
367 ("gobject-introspection" ,gobject-introspection)
370 ("cyrus-sasl" ,cyrus-sasl)
371 ("lvm2" ,lvm2) ; for libdevmapper
372 ("libyajl" ,libyajl)))
374 `(("pkg-config" ,pkg-config)
375 ("intltool" ,intltool)
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
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
392 (define-public python-libvirt
394 (name "python-libvirt")
398 (uri (pypi-uri "libvirt-python" version))
401 "0h0x5lpsx97bvw20pzfcsdmmivximddq4qmn8fk0n55dqv0wn5kq"))))
402 (build-system python-build-system)
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") "\"")))
414 `(("libvirt" ,libvirt)))
416 `(("python-lxml" ,python-lxml)))
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.")
426 (define-public python2-libvirt
427 (package-with-python2 python-libvirt))
429 (define-public virt-manager
431 (name "virt-manager")
435 (uri (string-append "https://virt-manager.org/download/sources"
436 "/virt-manager/virt-manager-"
440 "1jnawqjmcqd2db78ngx05x7cxxn3iy1sb4qfgbwcn045qh6a8cdz"))))
441 (build-system python-build-system)
444 #:use-setuptools? #f ; Uses custom distutils 'install' command.
445 ;; Some of the tests seem to require network access to install virtual
448 #:modules ((ice-9 match)
450 (guix build python-build-system)
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")))
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
467 "/lib/girepository-1.0")))
468 (if (file-exists? girepodir)
471 (for-each (lambda (file)
472 (format #t "wrapping ~a\n" file)
474 `("GI_TYPELIB_PATH" ":" prefix
475 ,(filter identity paths))))
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.
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")
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.")