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-2017-5525.patch"
81 "qemu-CVE-2017-5526.patch"))))
82 (build-system gnu-build-system)
84 '(;; Running tests in parallel can occasionally lead to failures, like:
85 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
89 (modify-phases %standard-phases
91 (lambda* (#:key inputs outputs (configure-flags '())
93 ;; The `configure' script doesn't understand some of the
94 ;; GNU options. Thus, add a new phase that's compatible.
95 (let ((out (assoc-ref outputs "out")))
96 (setenv "SHELL" (which "bash"))
98 ;; While we're at it, patch for tests.
99 (substitute* "tests/libqtest.c"
100 (("/bin/sh") (which "sh")))
102 ;; The binaries need to be linked against -lrt.
103 (setenv "LDFLAGS" "-lrt")
107 ,(string-append "--cc=" (which "gcc"))
108 ;; Some architectures insist on using HOST_CC
109 ,(string-append "--host-cc=" (which "gcc"))
110 "--disable-debug-info" ; save build space
111 "--enable-virtfs" ; just to be sure
112 ,(string-append "--prefix=" out)
113 ,@configure-flags))))))
114 (add-after 'install 'install-info
115 (lambda* (#:key inputs outputs #:allow-other-keys)
116 ;; Install the Info manual, unless Texinfo is missing.
117 (or (not (assoc-ref inputs "texinfo"))
118 (let ((out (assoc-ref outputs "out")))
119 (and (zero? (system* "make" "info"))
120 (let ((infodir (string-append out "/share/info")))
121 (for-each (lambda (info)
122 (install-file info infodir))
123 (find-files "." "\\.info"))
125 (add-before 'check 'make-gtester-verbose
127 ;; Make GTester verbose to facilitate investigation upon failure.
128 (setenv "V" "1") #t))
129 (add-before 'check 'disable-test-qga
131 (substitute* "tests/Makefile.include"
132 ;; Comment out the test-qga test, which needs /sys and
133 ;; fails within the build environment.
134 (("check-unit-.* tests/test-qga" all)
135 (string-append "# " all)))
137 (inputs ; TODO: Add optional inputs.
138 `(("alsa-lib" ,alsa-lib)
141 ;; ("libaio" ,libaio)
143 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
144 ("libjpeg" ,libjpeg-8)
146 ("libusb" ,libusb) ;USB pass-through support
149 ;; ("pciutils" ,pciutils)
153 ("util-linux" ,util-linux)
155 ("virglrenderer" ,virglrenderer)
157 (native-inputs `(("glib:bin" ,glib "bin") ; gtester, etc.
159 ("pkg-config" ,pkg-config)
160 ("python" ,python-2) ; incompatible with Python 3 according to error message
161 ("texinfo" ,texinfo)))
162 (home-page "http://www.qemu-project.org")
163 (synopsis "Machine emulator and virtualizer")
165 "QEMU is a generic machine emulator and virtualizer.
167 When used as a machine emulator, QEMU can run OSes and programs made for one
168 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
169 using dynamic translation, it achieves very good performance.
171 When used as a virtualizer, QEMU achieves near native performances by
172 executing the guest code directly on the host CPU. QEMU supports
173 virtualization when executing under the Xen hypervisor or using
174 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
175 server and embedded PowerPC, and S390 guests.")
177 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
180 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
181 (supported-systems (delete "mips64el-linux" %supported-systems))))
183 (define-public qemu-minimal
184 ;; QEMU without GUI support.
185 (package (inherit qemu)
186 (name "qemu-minimal")
187 (synopsis "Machine emulator and virtualizer (without GUI)")
190 ;; Restrict to the targets supported by Guix.
191 '("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu")
192 ,@(package-arguments qemu)))
194 ;; Remove dependencies on optional libraries, notably GUI libraries.
195 (inputs (fold alist-delete (package-inputs qemu)
196 '("libusb" "mesa" "sdl" "spice" "virglrenderer")))))
198 (define-public libosinfo
205 (uri (string-append "https://fedorahosted.org/releases/l/i/libosinfo/libosinfo-"
209 "151qrzmafxww5yfamrr7phk8217xmihfhazpb597vdv87na75cjh"))))
210 (build-system gnu-build-system)
213 (modify-phases %standard-phases
214 (add-after 'unpack 'copy-ids
215 (lambda* (#:key inputs #:allow-other-keys)
216 (copy-file (assoc-ref inputs "pci.ids") "data/pci.ids")
217 (copy-file (assoc-ref inputs "usb.ids") "data/usb.ids")
220 `(("libsoup" ,libsoup)
223 ("gobject-introspection" ,gobject-introspection)))
226 ("glib" ,glib "bin") ; glib-mkenums, etc.
229 ("intltool" ,intltool)
230 ("pkg-config" ,pkg-config)
234 (uri "https://raw.githubusercontent.com/pciutils/pciids/f9477789526f9d380bc57aa92e357c521738d5dd/pci.ids")
237 "0g6dbwlamagxqxvng67xng3w2x56c0np4md1v1p1jn32qw518az0"))))
241 (uri "http://linux-usb.cvs.sourceforge.net/viewvc/linux-usb/htdocs/usb.ids?revision=1.539")
242 (file-name "usb.ids")
245 "0w9ila7662lzpx416lqy69zx6gfwq2xiigwd5fdyqcrg3dj07m80"))))))
246 (home-page "https://libosinfo.org/")
247 (synopsis "Operating system information database")
248 (description "libosinfo is a GObject based library API for managing
249 information about operating systems, hypervisors and the (virtual) hardware
250 devices they can support. It includes a database containing device metadata
251 and provides APIs to match/identify optimal devices for deploying an operating
252 system on a hypervisor. Via GObject Introspection, the API is available in
253 all common programming languages. Vala bindings are also provided.")
254 ;; The library files are released under LGPLv2.1 or later; the source
255 ;; files in the "tools" directory are released under GPLv2+.
256 (license (list lgpl2.1+ gpl2+))))
258 (define-public libvirt
264 (uri (string-append "http://libvirt.org/sources/libvirt-"
268 "0sriasjc573c519yqw1hcfb3qqjcsm9hm8vayw0anwkl6di9ay8s"))))
269 (build-system gnu-build-system)
272 ;; FAIL: virfirewalltest
274 ;; FAIL: virnetsockettest
275 ;; FAIL: networkxml2firewalltest
276 ;; FAIL: nwfilterebiptablestest
277 ;; FAIL: nwfilterxml2firewalltest
278 ;; Times out after PASS: virsh-vcpupin
281 (list "--with-polkit"
282 "--localstatedir=/var")
284 (modify-phases %standard-phases
285 (add-after 'unpack 'fix-tests
287 (substitute* '("tests/commandtest.c"
288 "gnulib/tests/test-posix_spawn1.c"
289 "gnulib/tests/test-posix_spawn2.c")
290 (("/bin/sh") (which "sh")))
292 (add-after 'unpack 'do-not-mkdir-in-/var
293 ;; Since the localstatedir should be /var at runtime, we must
294 ;; prevent writing to /var at installation time.
295 (lambda* (#:key outputs #:allow-other-keys)
296 (let* ((out (assoc-ref outputs "out"))
297 (localstatedir (string-append out "/var")))
298 (substitute* '("src/Makefile.in"
299 "daemon/Makefile.in")
300 (("\\$\\(DESTDIR\\)\\$\\(localstatedir)") localstatedir)))
303 `(("libxml2" ,libxml2)
310 ("libuuid" ,util-linux)
311 ("lvm2" ,lvm2) ; for libdevmapper
314 ("cyrus-sasl" ,cyrus-sasl)
320 `(("pkg-config" ,pkg-config)))
321 (home-page "http://libvirt.org")
322 (synopsis "Simple API for virtualization")
323 (description "Libvirt is a C toolkit to interact with the virtualization
324 capabilities of recent versions of Linux. The library aims at providing long
325 term stable C API initially for the Xen paravirtualization but should be able
326 to integrate other virtualization mechanisms if needed.")
329 (define-public libvirt-glib
331 (name "libvirt-glib")
335 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
336 "libvirt-glib-" version ".tar.gz"))
339 "1pahj8qa7k2307sd57rwqwq1hijya02v0sxk91hl3cw48niimcf3"))))
340 (build-system gnu-build-system)
343 (modify-phases %standard-phases
344 (add-after 'unpack 'fix-tests
346 (substitute* "tests/test-events.c"
347 (("/bin/true") (which "true")))
350 `(("libxml2" ,libxml2)
352 ("gobject-introspection" ,gobject-introspection)
355 ("cyrus-sasl" ,cyrus-sasl)
356 ("lvm2" ,lvm2) ; for libdevmapper
357 ("libyajl" ,libyajl)))
359 `(("pkg-config" ,pkg-config)
360 ("intltool" ,intltool)
363 (home-page "http://libvirt.org")
364 (synopsis "GLib wrapper around libvirt")
365 (description "libvirt-glib wraps the libvirt library to provide a
366 high-level object-oriented API better suited for glib-based applications, via
370 @item libvirt-glib - GLib main loop integration & misc helper APIs
371 @item libvirt-gconfig - GObjects for manipulating libvirt XML documents
372 @item libvirt-gobject - GObjects for managing libvirt objects
377 (define-public python-libvirt
379 (name "python-libvirt")
383 (uri (pypi-uri "libvirt-python" version))
386 "0h0x5lpsx97bvw20pzfcsdmmivximddq4qmn8fk0n55dqv0wn5kq"))))
387 (build-system python-build-system)
390 (modify-phases %standard-phases
391 (add-after 'unpack 'patch-nosetests-path
392 (lambda* (#:key inputs #:allow-other-keys)
393 (substitute* "setup.py"
394 (("sys.executable, \"/usr/bin/nosetests\"")
395 (string-append "\"" (which "bash") "\", \""
396 (which "nosetests") "\"")))
399 `(("libvirt" ,libvirt)))
401 `(("python-lxml" ,python-lxml)))
403 `(("pkg-config" ,pkg-config)
404 ("python-nose" ,python-nose)))
405 (home-page "http://libvirt.org")
406 (synopsis "Python bindings to libvirt")
407 (description "This package provides Python bindings to the libvirt
408 virtualization library.")
411 (define-public python2-libvirt
412 (package-with-python2 python-libvirt))
414 (define-public virt-manager
416 (name "virt-manager")
420 (uri (string-append "https://virt-manager.org/download/sources"
421 "/virt-manager/virt-manager-"
425 "1jnawqjmcqd2db78ngx05x7cxxn3iy1sb4qfgbwcn045qh6a8cdz"))))
426 (build-system python-build-system)
429 #:use-setuptools? #f ; Uses custom distutils 'install' command.
430 ;; Some of the tests seem to require network access to install virtual
433 #:modules ((ice-9 match)
435 (guix build python-build-system)
438 (modify-phases %standard-phases
439 (add-after 'unpack 'fix-setup
440 (lambda* (#:key outputs #:allow-other-keys)
441 (substitute* "virtcli/cliconfig.py"
442 (("/usr") (assoc-ref outputs "out")))
444 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
445 (lambda* (#:key inputs outputs #:allow-other-keys)
446 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
447 (bin-files (find-files bin ".*"))
448 (paths (map (match-lambda
449 ((output . directory)
450 (let* ((girepodir (string-append
452 "/lib/girepository-1.0")))
453 (if (file-exists? girepodir)
456 (for-each (lambda (file)
457 (format #t "wrapping ~a\n" file)
459 `("GI_TYPELIB_PATH" ":" prefix
460 ,(filter identity paths))))
466 ("libvirt-glib" ,libvirt-glib)
467 ("libosinfo" ,libosinfo)
468 ("gobject-introspection" ,gobject-introspection)
469 ("python2-libvirt" ,python2-libvirt)
470 ("python2-requests" ,python2-requests)
471 ("python2-ipaddr" ,python2-ipaddr)
472 ("python2-pygobject" ,python2-pygobject)
473 ("python2-libxml2" ,python2-libxml2)))
474 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
478 `(("glib" ,glib "bin") ; glib-compile-schemas.
479 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
480 ("perl" ,perl) ; pod2man
481 ("intltool" ,intltool)))
482 (home-page "https://virt-manager.org/")
483 (synopsis "Manage virtual machines")
485 "The virt-manager application is a desktop user interface for managing
486 virtual machines through libvirt. It primarily targets KVM VMs, but also
487 manages Xen and LXC (Linux containers). It presents a summary view of running
488 domains, their live performance and resource utilization statistics.")