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 virtualization)
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 dns)
33 #:use-module (gnu packages gl)
34 #:use-module (gnu packages glib)
35 #:use-module (gnu packages gnome)
36 #:use-module (gnu packages gtk)
37 #:use-module (gnu packages image)
38 #:use-module (gnu packages libusb)
39 #:use-module (gnu packages linux)
40 #:use-module (gnu packages ncurses)
41 #:use-module (gnu packages perl)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages polkit)
44 #:use-module (gnu packages python)
45 #:use-module (gnu packages sdl)
46 #:use-module (gnu packages spice)
47 #:use-module (gnu packages texinfo)
48 #:use-module (gnu packages tls)
49 #:use-module (gnu packages web)
50 #:use-module (gnu packages xdisorg)
51 #:use-module (gnu packages xml)
52 #:use-module (guix build-system gnu)
53 #:use-module (guix build-system python)
54 #:use-module (guix download)
55 #:use-module ((guix licenses) #:select (gpl2 gpl2+ lgpl2.1+))
56 #:use-module (guix packages)
57 #:use-module (guix utils)
58 #:use-module (srfi srfi-1))
60 (define (qemu-patch commit file-name sha256)
61 "Return an origin for COMMIT."
65 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
68 (file-name file-name)))
76 (uri (string-append "http://wiki.qemu-project.org/download/qemu-"
78 (patches (search-patches "qemu-CVE-2017-7493.patch"
79 "qemu-CVE-2017-8112.patch"
80 "qemu-CVE-2017-8309.patch"
81 "qemu-CVE-2017-8379.patch"
82 "qemu-CVE-2017-8380.patch"
83 "qemu-CVE-2017-9524.patch"))
86 "08mhfs0ndbkyqgw7fjaa9vjxf4dinrly656f6hjzvmaz7hzc677h"))))
87 (build-system gnu-build-system)
89 '(;; Running tests in parallel can occasionally lead to failures, like:
90 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
94 (modify-phases %standard-phases
96 (lambda* (#:key inputs outputs (configure-flags '())
98 ;; The `configure' script doesn't understand some of the
99 ;; GNU options. Thus, add a new phase that's compatible.
100 (let ((out (assoc-ref outputs "out")))
101 (setenv "SHELL" (which "bash"))
103 ;; While we're at it, patch for tests.
104 (substitute* "tests/libqtest.c"
105 (("/bin/sh") (which "sh")))
107 ;; The binaries need to be linked against -lrt.
108 (setenv "LDFLAGS" "-lrt")
112 ,(string-append "--cc=" (which "gcc"))
113 ;; Some architectures insist on using HOST_CC
114 ,(string-append "--host-cc=" (which "gcc"))
115 "--disable-debug-info" ; save build space
116 "--enable-virtfs" ; just to be sure
117 ,(string-append "--prefix=" out)
118 ,@configure-flags))))))
119 (add-after 'install 'install-info
120 (lambda* (#:key inputs outputs #:allow-other-keys)
121 ;; Install the Info manual, unless Texinfo is missing.
122 (or (not (assoc-ref inputs "texinfo"))
123 (let ((out (assoc-ref outputs "out")))
124 (and (zero? (system* "make" "info"))
125 (let ((infodir (string-append out "/share/info")))
126 (for-each (lambda (info)
127 (install-file info infodir))
128 (find-files "." "\\.info"))
130 (add-before 'check 'make-gtester-verbose
132 ;; Make GTester verbose to facilitate investigation upon failure.
133 (setenv "V" "1") #t))
134 (add-before 'check 'disable-test-qga
136 (substitute* "tests/Makefile.include"
137 ;; Comment out the test-qga test, which needs /sys and
138 ;; fails within the build environment.
139 (("check-unit-.* tests/test-qga" all)
140 (string-append "# " all)))
142 (inputs ; TODO: Add optional inputs.
143 `(("alsa-lib" ,alsa-lib)
146 ;; ("libaio" ,libaio)
148 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
149 ("libjpeg" ,libjpeg-8)
151 ("libusb" ,libusb) ;USB pass-through support
154 ;; ("pciutils" ,pciutils)
158 ("util-linux" ,util-linux)
160 ("virglrenderer" ,virglrenderer)
162 (native-inputs `(("glib:bin" ,glib "bin") ; gtester, etc.
164 ("pkg-config" ,pkg-config)
165 ("python" ,python-2) ; incompatible with Python 3 according to error message
166 ("texinfo" ,texinfo)))
167 (home-page "http://www.qemu-project.org")
168 (synopsis "Machine emulator and virtualizer")
170 "QEMU is a generic machine emulator and virtualizer.
172 When used as a machine emulator, QEMU can run OSes and programs made for one
173 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
174 using dynamic translation, it achieves very good performance.
176 When used as a virtualizer, QEMU achieves near native performances by
177 executing the guest code directly on the host CPU. QEMU supports
178 virtualization when executing under the Xen hypervisor or using
179 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
180 server and embedded PowerPC, and S390 guests.")
182 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
185 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
186 (supported-systems (delete "mips64el-linux" %supported-systems))))
188 (define-public qemu-minimal
189 ;; QEMU without GUI support.
190 (package (inherit qemu)
191 (name "qemu-minimal")
192 (synopsis "Machine emulator and virtualizer (without GUI)")
195 ;; Restrict to the targets supported by Guix.
196 '("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu,aarch64-softmmu")
197 ,@(package-arguments qemu)))
199 ;; Remove dependencies on optional libraries, notably GUI libraries.
200 (inputs (fold alist-delete (package-inputs qemu)
201 '("libusb" "mesa" "sdl" "spice" "virglrenderer")))))
203 (define-public libosinfo
210 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
214 "0srrs2m6irqd4f867g8ls6jp2dq3ql0l9d0fh80d55sivvn2bd7p"))))
215 (build-system gnu-build-system)
218 (list (string-append "--with-usb-ids-path="
219 (assoc-ref %build-inputs "usb.ids"))
220 (string-append "--with-pci-ids-path="
221 (assoc-ref %build-inputs "pci.ids")))
223 (modify-phases %standard-phases
224 ;; This odd test fails for unknown reasons.
225 (add-after 'unpack 'disable-broken-test
227 (substitute* "test/Makefile.in"
228 (("test-isodetect\\$\\(EXEEXT\\)") ""))
231 `(("libsoup" ,libsoup)
234 ("gobject-introspection" ,gobject-introspection)))
237 ("glib" ,glib "bin") ; glib-mkenums, etc.
240 ("intltool" ,intltool)
241 ("pkg-config" ,pkg-config)
245 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
248 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
252 (uri "http://linux-usb.cvs.sourceforge.net/viewvc/linux-usb/htdocs/usb.ids?revision=1.551")
253 (file-name "usb.ids")
256 "17rg5i0wbyk289gr8v4kgvnc9q5bidz7ldcvv9x58l083wn16hq3"))))))
257 (home-page "https://libosinfo.org/")
258 (synopsis "Operating system information database")
259 (description "libosinfo is a GObject based library API for managing
260 information about operating systems, hypervisors and the (virtual) hardware
261 devices they can support. It includes a database containing device metadata
262 and provides APIs to match/identify optimal devices for deploying an operating
263 system on a hypervisor. Via GObject Introspection, the API is available in
264 all common programming languages. Vala bindings are also provided.")
265 ;; The library files are released under LGPLv2.1 or later; the source
266 ;; files in the "tools" directory are released under GPLv2+.
267 (license (list lgpl2.1+ gpl2+))))
269 (define-public libvirt
275 (uri (string-append "http://libvirt.org/sources/libvirt-"
279 "05mm4xdw6g960rwvc9189nhxpm1vrilnmpl4h4m1lha11pivlqr9"))))
280 (build-system gnu-build-system)
283 ;; FAIL: virfirewalltest
285 ;; FAIL: virnetsockettest
286 ;; FAIL: networkxml2firewalltest
287 ;; FAIL: nwfilterebiptablestest
288 ;; FAIL: nwfilterxml2firewalltest
289 ;; Times out after PASS: virsh-vcpupin
292 (list "--with-polkit"
294 "--localstatedir=/var")
296 (modify-phases %standard-phases
297 (add-after 'unpack 'fix-tests
299 (substitute* '("tests/commandtest.c"
300 "gnulib/tests/test-posix_spawn1.c"
301 "gnulib/tests/test-posix_spawn2.c")
302 (("/bin/sh") (which "sh")))
305 ;; Since the sysconfdir and localstatedir should be /etc and /var
306 ;; at runtime, we must prevent writing to them at installation
309 (zero? (system* "make" "install"
310 "sysconfdir=/tmp/etc"
311 "localstatedir=/tmp/var")))))))
313 `(("libxml2" ,libxml2)
320 ("libuuid" ,util-linux)
321 ("lvm2" ,lvm2) ; for libdevmapper
324 ("cyrus-sasl" ,cyrus-sasl)
329 ("dmidecode" ,dmidecode)
331 ("ebtables" ,ebtables)
333 ("iptables" ,iptables)))
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 "0iwa5sdbii52pjpdm5j37f67sdmf0kpcky4liwhy1nf43k85i4fa"))))
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 "04dma3979171p9yf0cg7m03shk038hc9vyfm9lb8z60qyn0pg9xg"))))
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 (("\"/usr/bin/nosetests\"")
410 (string-append "\"" (which "nosetests") "\""))
411 (("self\\.spawn\\(\\[sys\\.executable, nose\\]\\)")
412 (format #f "self.spawn([\"~a\", nose])" (which "bash"))))
415 `(("libvirt" ,libvirt)))
417 `(("python-lxml" ,python-lxml)))
419 `(("pkg-config" ,pkg-config)
420 ("python-nose" ,python-nose)))
421 (home-page "http://libvirt.org")
422 (synopsis "Python bindings to libvirt")
423 (description "This package provides Python bindings to the libvirt
424 virtualization library.")
427 (define-public python2-libvirt
428 (package-with-python2 python-libvirt))
430 (define-public virt-manager
432 (name "virt-manager")
436 (uri (string-append "https://virt-manager.org/download/sources"
437 "/virt-manager/virt-manager-"
441 "0i1rkxz730vw1nqghrp189jhhp53pw81k0h71hhxmyqlkyclkig6"))))
442 (build-system python-build-system)
445 #:use-setuptools? #f ; Uses custom distutils 'install' command.
446 ;; Some of the tests seem to require network access to install virtual
449 #:modules ((ice-9 match)
451 (guix build python-build-system)
454 (modify-phases %standard-phases
455 (add-after 'unpack 'fix-setup
456 (lambda* (#:key outputs #:allow-other-keys)
457 (substitute* "virtcli/cliconfig.py"
458 (("/usr") (assoc-ref outputs "out")))
460 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
461 (lambda* (#:key inputs outputs #:allow-other-keys)
462 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
463 (bin-files (find-files bin ".*"))
464 (paths (map (match-lambda
465 ((output . directory)
466 (let* ((girepodir (string-append
468 "/lib/girepository-1.0")))
469 (if (file-exists? girepodir)
472 (for-each (lambda (file)
473 (format #t "wrapping ~a\n" file)
475 `("GI_TYPELIB_PATH" ":" prefix
476 ,(filter identity paths))))
483 ("libvirt-glib" ,libvirt-glib)
484 ("libosinfo" ,libosinfo)
486 ("gobject-introspection" ,gobject-introspection)
487 ("python2-libvirt" ,python2-libvirt)
488 ("python2-requests" ,python2-requests)
489 ("python2-ipaddr" ,python2-ipaddr)
490 ("python2-pygobject" ,python2-pygobject)
491 ("python2-libxml2" ,python2-libxml2)))
492 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
496 `(("glib" ,glib "bin") ; glib-compile-schemas.
497 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
498 ("perl" ,perl) ; pod2man
499 ("intltool" ,intltool)))
500 (home-page "https://virt-manager.org/")
501 (synopsis "Manage virtual machines")
503 "The virt-manager application is a desktop user interface for managing
504 virtual machines through libvirt. It primarily targets KVM VMs, but also
505 manages Xen and LXC (Linux containers). It presents a summary view of running
506 domains, their live performance and resource utilization statistics.")