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 ;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
7 ;;; Copyright © 2017 Andy Patterson <ajpatter@uwaterloo.ca>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages virtualization)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages admin)
27 #:use-module (gnu packages attr)
28 #:use-module (gnu packages autotools)
29 #:use-module (gnu packages check)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages curl)
32 #:use-module (gnu packages cyrus-sasl)
33 #:use-module (gnu packages disk)
34 #:use-module (gnu packages dns)
35 #:use-module (gnu packages gl)
36 #:use-module (gnu packages glib)
37 #:use-module (gnu packages gnome)
38 #:use-module (gnu packages gtk)
39 #:use-module (gnu packages image)
40 #:use-module (gnu packages libusb)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages ncurses)
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages polkit)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages selinux)
48 #:use-module (gnu packages sdl)
49 #:use-module (gnu packages spice)
50 #:use-module (gnu packages texinfo)
51 #:use-module (gnu packages tls)
52 #:use-module (gnu packages web)
53 #:use-module (gnu packages xdisorg)
54 #:use-module (gnu packages xml)
55 #:use-module (guix build-system gnu)
56 #:use-module (guix build-system python)
57 #:use-module (guix download)
58 #:use-module ((guix licenses) #:select (gpl2 gpl2+ lgpl2.1+))
59 #:use-module (guix packages)
60 #:use-module (guix utils)
61 #:use-module (srfi srfi-1))
63 (define (qemu-patch commit file-name sha256)
64 "Return an origin for COMMIT."
68 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
71 (file-name file-name)))
79 (uri (string-append "https://download.qemu.org/qemu-"
83 "1ahwl7r18iw2ds0q3c51nlivqsan9hcgnc8bbf9pv366iy81mm8x"))))
84 (build-system gnu-build-system)
86 '(;; Running tests in parallel can occasionally lead to failures, like:
87 ;; boot_sector_test: assertion failed (signature == SIGNATURE): (0x00000000 == 0x0000dead)
89 #:configure-flags '("--enable-usb-redir" "--enable-opengl")
91 (modify-phases %standard-phases
93 (lambda* (#:key inputs outputs (configure-flags '())
95 ;; The `configure' script doesn't understand some of the
96 ;; GNU options. Thus, add a new phase that's compatible.
97 (let ((out (assoc-ref outputs "out")))
98 (setenv "SHELL" (which "bash"))
100 ;; While we're at it, patch for tests.
101 (substitute* "tests/libqtest.c"
102 (("/bin/sh") (which "sh")))
104 ;; The binaries need to be linked against -lrt.
105 (setenv "LDFLAGS" "-lrt")
109 ,(string-append "--cc=" (which "gcc"))
110 ;; Some architectures insist on using HOST_CC
111 ,(string-append "--host-cc=" (which "gcc"))
112 "--disable-debug-info" ; save build space
113 "--enable-virtfs" ; just to be sure
114 ,(string-append "--prefix=" out)
115 ,(string-append "--sysconfdir=/etc")
116 ,@configure-flags))))))
117 (add-after 'install 'install-info
118 (lambda* (#:key inputs outputs #:allow-other-keys)
119 ;; Install the Info manual, unless Texinfo is missing.
120 (or (not (assoc-ref inputs "texinfo"))
121 (let ((out (assoc-ref outputs "out")))
122 (and (zero? (system* "make" "info"))
123 (let ((infodir (string-append out "/share/info")))
124 (for-each (lambda (info)
125 (install-file info infodir))
126 (find-files "." "\\.info"))
128 (add-before 'check 'make-gtester-verbose
130 ;; Make GTester verbose to facilitate investigation upon failure.
131 (setenv "V" "1") #t))
132 (add-before 'check 'disable-test-qga
134 (substitute* "tests/Makefile.include"
135 ;; Comment out the test-qga test, which needs /sys and
136 ;; fails within the build environment.
137 (("check-unit-.* tests/test-qga" all)
138 (string-append "# " all)))
140 (inputs ; TODO: Add optional inputs.
141 `(("alsa-lib" ,alsa-lib)
146 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
148 ("libepoxy" ,libepoxy)
149 ("libjpeg" ,libjpeg-8)
151 ("libusb" ,libusb) ;USB pass-through support
154 ;; ("pciutils" ,pciutils)
158 ("usbredir" ,usbredir)
159 ("util-linux" ,util-linux)
161 ("virglrenderer" ,virglrenderer)
163 (native-inputs `(("glib:bin" ,glib "bin") ; gtester, etc.
165 ("pkg-config" ,pkg-config)
166 ("python" ,python-2) ; incompatible with Python 3 according to error message
167 ("texinfo" ,texinfo)))
168 (home-page "http://www.qemu-project.org")
169 (synopsis "Machine emulator and virtualizer")
171 "QEMU is a generic machine emulator and virtualizer.
173 When used as a machine emulator, QEMU can run OSes and programs made for one
174 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
175 using dynamic translation, it achieves very good performance.
177 When used as a virtualizer, QEMU achieves near native performances by
178 executing the guest code directly on the host CPU. QEMU supports
179 virtualization when executing under the Xen hypervisor or using
180 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
181 server and embedded PowerPC, and S390 guests.")
183 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
186 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
187 (supported-systems (delete "mips64el-linux" %supported-systems))))
189 (define-public qemu-minimal
190 ;; QEMU without GUI support.
191 (package (inherit qemu)
192 (name "qemu-minimal")
193 (synopsis "Machine emulator and virtualizer (without GUI)")
195 (substitute-keyword-arguments (package-arguments qemu)
196 ((#:configure-flags _ '(list))
197 ;; Restrict to the targets supported by Guix.
198 ''("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu,aarch64-softmmu"))))
200 ;; Remove dependencies on optional libraries, notably GUI libraries.
201 (inputs (fold alist-delete (package-inputs qemu)
202 '("libusb" "mesa" "sdl" "spice" "virglrenderer"
203 "usbredir" "libdrm" "libepoxy")))))
205 (define-public libosinfo
212 (uri (string-append "https://releases.pagure.org/libosinfo/libosinfo-"
216 "0srrs2m6irqd4f867g8ls6jp2dq3ql0l9d0fh80d55sivvn2bd7p"))))
217 (build-system gnu-build-system)
220 (list (string-append "--with-usb-ids-path="
221 (assoc-ref %build-inputs "usb.ids"))
222 (string-append "--with-pci-ids-path="
223 (assoc-ref %build-inputs "pci.ids")))
225 (modify-phases %standard-phases
226 ;; This odd test fails for unknown reasons.
227 (add-after 'unpack 'disable-broken-test
229 (substitute* "test/Makefile.in"
230 (("test-isodetect\\$\\(EXEEXT\\)") ""))
233 `(("libsoup" ,libsoup)
236 ("gobject-introspection" ,gobject-introspection)))
239 ("glib" ,glib "bin") ; glib-mkenums, etc.
242 ("intltool" ,intltool)
243 ("pkg-config" ,pkg-config)
247 (uri "https://github.com/pciutils/pciids/raw/ad02084f0bc143e3c15e31a6152a3dfb1d7a3156/pci.ids")
250 "0kfhpj5rnh24hz2714qhfmxk281vwc2w50sm73ggw5d15af7zfsw"))))
254 (uri "http://linux-usb.cvs.sourceforge.net/viewvc/linux-usb/htdocs/usb.ids?revision=1.551")
255 (file-name "usb.ids")
258 "17rg5i0wbyk289gr8v4kgvnc9q5bidz7ldcvv9x58l083wn16hq3"))))))
259 (home-page "https://libosinfo.org/")
260 (synopsis "Operating system information database")
261 (description "libosinfo is a GObject based library API for managing
262 information about operating systems, hypervisors and the (virtual) hardware
263 devices they can support. It includes a database containing device metadata
264 and provides APIs to match/identify optimal devices for deploying an operating
265 system on a hypervisor. Via GObject Introspection, the API is available in
266 all common programming languages. Vala bindings are also provided.")
267 ;; The library files are released under LGPLv2.1 or later; the source
268 ;; files in the "tools" directory are released under GPLv2+.
269 (license (list lgpl2.1+ gpl2+))))
278 "https://linuxcontainers.org/downloads/lxc/lxc-"
282 "15449r56rqg3487kzsnfvz0w4p5ajrq0krcsdh6c9r6g0ark93hd"))))
283 (build-system gnu-build-system)
285 `(("pkg-config" ,pkg-config)))
289 ("libseccomp" ,libseccomp)
290 ("libselinux" ,libselinux)))
293 '("--sysconfdir=/etc"
294 "--localstatedir=/var")
296 (modify-phases %standard-phases
298 (lambda* (#:key outputs #:allow-other-keys)
299 (let* ((out (assoc-ref outputs "out"))
300 (bashcompdir (string-append out "/etc/bash_completion.d")))
303 (string-append "bashcompdir=" bashcompdir)
304 ;; Don't install files into /var and /etc.
305 "LXCPATH=/tmp/var/lib/lxc"
306 "localstatedir=/tmp/var"
307 "sysconfdir=/tmp/etc"
308 "sysconfigdir=/tmp/etc/default"))))))))
309 (synopsis "Linux container tools")
310 (home-page "https://linuxcontainers.org/")
312 "LXC is a userspace interface for the Linux kernel containment features.
313 Through a powerful API and simple tools, it lets Linux users easily create and
314 manage system or application containers.")
317 (define-public libvirt
323 (uri (string-append "https://libvirt.org/sources/libvirt-"
327 "1fk75cdzg59y9hnfdpdwv83fsc1yffy3lac4ch19zygfkqhcnysf"))))
328 (build-system gnu-build-system)
331 ;; FAIL: virfirewalltest
333 ;; FAIL: virnetsockettest
334 ;; FAIL: networkxml2firewalltest
335 ;; FAIL: nwfilterebiptablestest
336 ;; FAIL: nwfilterxml2firewalltest
337 ;; Times while running commandest.
340 (list "--with-polkit"
342 "--localstatedir=/var")
344 (modify-phases %standard-phases
345 (add-after 'unpack 'fix-tests
347 (substitute* '("tests/commandtest.c"
348 "gnulib/tests/test-posix_spawn1.c"
349 "gnulib/tests/test-posix_spawn2.c")
350 (("/bin/sh") (which "sh")))
353 ;; Since the sysconfdir and localstatedir should be /etc and /var
354 ;; at runtime, we must prevent writing to them at installation
357 (zero? (system* "make" "install"
358 "sysconfdir=/tmp/etc"
359 "localstatedir=/tmp/var"))))
360 (add-after 'install 'wrap-libvirtd
361 (lambda* (#:key inputs outputs #:allow-other-keys)
362 (let ((out (assoc-ref outputs "out")))
363 (wrap-program (string-append out "/sbin/libvirtd")
364 `("PATH" = (,(string-append (assoc-ref inputs "iproute")
366 ,(string-append (assoc-ref inputs "qemu")
370 `(("libxml2" ,libxml2)
376 ("libuuid" ,util-linux)
377 ("lvm2" ,lvm2) ; for libdevmapper
380 ("cyrus-sasl" ,cyrus-sasl)
383 ("dmidecode" ,dmidecode)
385 ("ebtables" ,ebtables)
387 ("iptables" ,iptables)))
389 `(("xsltproc" ,libxslt)
391 ("pkg-config" ,pkg-config)
393 ("python" ,python-2)))
394 (home-page "https://libvirt.org")
395 (synopsis "Simple API for virtualization")
396 (description "Libvirt is a C toolkit to interact with the virtualization
397 capabilities of recent versions of Linux. The library aims at providing long
398 term stable C API initially for the Xen paravirtualization but should be able
399 to integrate other virtualization mechanisms if needed.")
402 (define-public libvirt-glib
404 (name "libvirt-glib")
408 (uri (string-append "ftp://libvirt.org/libvirt/glib/"
409 "libvirt-glib-" version ".tar.gz"))
412 "0iwa5sdbii52pjpdm5j37f67sdmf0kpcky4liwhy1nf43k85i4fa"))))
413 (build-system gnu-build-system)
416 (modify-phases %standard-phases
417 (add-after 'unpack 'fix-tests
419 (substitute* "tests/test-events.c"
420 (("/bin/true") (which "true")))
423 `(("libxml2" ,libxml2)
425 ("gobject-introspection" ,gobject-introspection)
428 ("cyrus-sasl" ,cyrus-sasl)
429 ("lvm2" ,lvm2) ; for libdevmapper
430 ("libyajl" ,libyajl)))
432 `(("pkg-config" ,pkg-config)
433 ("intltool" ,intltool)
436 (home-page "https://libvirt.org")
437 (synopsis "GLib wrapper around libvirt")
438 (description "libvirt-glib wraps the libvirt library to provide a
439 high-level object-oriented API better suited for glib-based applications, via
443 @item libvirt-glib - GLib main loop integration & misc helper APIs
444 @item libvirt-gconfig - GObjects for manipulating libvirt XML documents
445 @item libvirt-gobject - GObjects for managing libvirt objects
450 (define-public python-libvirt
452 (name "python-libvirt")
456 (uri (pypi-uri "libvirt-python" version))
459 "0vy0ai8z88yhzqfk1n08z1gda5flrqxcw9lg1012b3zg125qljhy"))))
460 (build-system python-build-system)
463 (modify-phases %standard-phases
464 (add-after 'unpack 'patch-nosetests-path
465 (lambda* (#:key inputs #:allow-other-keys)
466 (substitute* "setup.py"
467 (("\"/usr/bin/nosetests\"")
468 (string-append "\"" (which "nosetests") "\""))
469 (("self\\.spawn\\(\\[sys\\.executable, nose\\]\\)")
470 (format #f "self.spawn([\"~a\", nose])" (which "bash"))))
473 `(("libvirt" ,libvirt)))
475 `(("python-lxml" ,python-lxml)))
477 `(("pkg-config" ,pkg-config)
478 ("python-nose" ,python-nose)))
479 (home-page "https://libvirt.org")
480 (synopsis "Python bindings to libvirt")
481 (description "This package provides Python bindings to the libvirt
482 virtualization library.")
485 (define-public python2-libvirt
486 (package-with-python2 python-libvirt))
488 (define-public virt-manager
490 (name "virt-manager")
494 (uri (string-append "https://virt-manager.org/download/sources"
495 "/virt-manager/virt-manager-"
499 "093azs8p4p7y4nf5j25xpsvdxww7gky1g0hs8mkcvmpxl2wjd0jj"))))
500 (build-system python-build-system)
503 #:use-setuptools? #f ; Uses custom distutils 'install' command.
504 ;; Some of the tests seem to require network access to install virtual
507 #:modules ((ice-9 match)
509 (guix build python-build-system)
512 (modify-phases %standard-phases
513 (add-after 'unpack 'fix-setup
514 (lambda* (#:key outputs #:allow-other-keys)
515 (substitute* "virtcli/cliconfig.py"
516 (("/usr") (assoc-ref outputs "out")))
518 (add-before 'wrap 'wrap-with-GI_TYPELIB_PATH
519 (lambda* (#:key inputs outputs #:allow-other-keys)
520 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
521 (bin-files (find-files bin ".*"))
522 (paths (map (match-lambda
523 ((output . directory)
524 (let* ((girepodir (string-append
526 "/lib/girepository-1.0")))
527 (if (file-exists? girepodir)
530 (for-each (lambda (file)
531 (format #t "wrapping ~a\n" file)
533 `("GI_TYPELIB_PATH" ":" prefix
534 ,(filter identity paths))))
541 ("libvirt-glib" ,libvirt-glib)
542 ("libosinfo" ,libosinfo)
544 ("gobject-introspection" ,gobject-introspection)
545 ("python2-libvirt" ,python2-libvirt)
546 ("python2-requests" ,python2-requests)
547 ("python2-ipaddr" ,python2-ipaddr)
548 ("python2-pygobject" ,python2-pygobject)
549 ("python2-libxml2" ,python2-libxml2)
550 ("spice-gtk" ,spice-gtk)))
551 ;; virt-manager searches for qemu-img or kvm-img in the PATH.
555 `(("glib" ,glib "bin") ; glib-compile-schemas.
556 ("gtk+" ,gtk+ "bin") ; gtk-update-icon-cache
557 ("perl" ,perl) ; pod2man
558 ("intltool" ,intltool)))
559 (home-page "https://virt-manager.org/")
560 (synopsis "Manage virtual machines")
562 "The virt-manager application is a desktop user interface for managing
563 virtual machines through libvirt. It primarily targets KVM VMs, but also
564 manages Xen and LXC (Linux containers). It presents a summary view of running
565 domains, their live performance and resource utilization statistics.")