1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu packages qemu)
21 #:use-module (guix download)
22 #:use-module (guix packages)
23 #:use-module (guix utils)
24 #:use-module ((guix licenses) #:select (gpl2))
25 #:use-module (guix build-system gnu)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages autotools)
28 #:use-module (gnu packages texinfo)
29 #:use-module (gnu packages pkg-config)
30 #:use-module (gnu packages glib)
31 #:use-module (gnu packages python)
32 #:use-module (gnu packages ncurses)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages image)
35 #:use-module (gnu packages attr)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages libusb)
38 #:use-module (gnu packages xdisorg)
39 #:use-module (gnu packages gl)
40 #:use-module (gnu packages sdl)
41 #:use-module (gnu packages perl))
43 (define (qemu-patch commit file-name sha256)
44 "Return an origin for COMMIT."
48 "http://git.qemu.org/?p=qemu.git;a=commitdiff_plain;h="
51 (file-name file-name)))
53 (define %glib-memory-vtable-patch
54 (qemu-patch "deb847bf"
55 "qemu-glib-memory-vtable.patch"
57 "0afb7rvxy14104jxmhr7m02w5baiz0c7vhq3h642h09jgxrcmzzi")))
59 (define %glib-duplicate-test-patch
60 (qemu-patch "98cf48f6"
61 "qemu-glib-duplicate-test.patch"
63 "1aicbplzdj5s5y13jmqyvfajay05x9dnkzd197waz8v6kha7d9d5")))
65 (define-public qemu-headless
66 ;; This is QEMU without GUI support.
68 (name "qemu-headless")
72 (uri (string-append "http://wiki.qemu-project.org/download/qemu-"
76 "1nqv5p94zpnhcaqkifnn83ap7dd0qrb0qiicswbyhhby0f48pzpc"))
77 (patches (list (search-patch "qemu-CVE-2015-6855.patch")
79 ;; These two patches allow QEMU's tests to run
80 ;; correctly with 'gtester' from the latest GLib.
81 %glib-memory-vtable-patch
82 %glib-duplicate-test-patch))))
83 (build-system gnu-build-system)
85 '(#:phases (alist-replace
87 (lambda* (#:key inputs outputs (configure-flags '())
89 ;; The `configure' script doesn't understand some of the
90 ;; GNU options. Thus, add a new phase that's compatible.
91 (let ((out (assoc-ref outputs "out")))
92 (setenv "SHELL" (which "bash"))
94 ;; While we're at it, patch for tests.
95 (substitute* "tests/libqtest.c"
96 (("/bin/sh") (which "sh")))
98 ;; The binaries need to be linked against -lrt.
99 (setenv "LDFLAGS" "-lrt")
103 ,(string-append "--cc=" (which "gcc"))
104 "--disable-debug-info" ; save build space
105 "--enable-virtfs" ; just to be sure
106 ,(string-append "--prefix=" out)
107 ,@configure-flags)))))
109 'install 'install-info
110 (lambda* (#:key inputs outputs #:allow-other-keys)
111 ;; Install the Info manual, unless Texinfo is missing.
112 (or (not (assoc-ref inputs "texinfo"))
113 (let ((out (assoc-ref outputs "out")))
114 (and (zero? (system* "make" "info"))
115 (let ((infodir (string-append out "/share/info")))
117 (for-each (lambda (info)
120 (string-append infodir "/" info)))
121 (find-files "." "\\.info$"))
125 (inputs ; TODO: Add optional inputs.
126 `(;; ("libaio" ,libaio)
130 ("libjpeg" ,libjpeg-8)
133 ("util-linux" ,util-linux)
134 ("libcap" ,libcap) ; virtfs support requires libcap & libattr
136 ;; ("pciutils" ,pciutils)
137 ("alsa-lib" ,alsa-lib)
140 (native-inputs `(("pkg-config" ,pkg-config)
141 ("python" ,python-2) ; incompatible with Python 3 according to error message
142 ("glib" ,glib "bin") ; gtester, etc.
145 (home-page "http://www.qemu-project.org")
146 (synopsis "Machine emulator and virtualizer (without GUI)")
148 "QEMU is a generic machine emulator and virtualizer.
150 When used as a machine emulator, QEMU can run OSes and programs made for one
151 machine (e.g. an ARM board) on a different machine---e.g., your own PC. By
152 using dynamic translation, it achieves very good performance.
154 When used as a virtualizer, QEMU achieves near native performances by
155 executing the guest code directly on the host CPU. QEMU supports
156 virtualization when executing under the Xen hypervisor or using
157 the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86,
158 server and embedded PowerPC, and S390 guests.")
160 ;; Many files are GPLv2+, but some are GPLv2-only---e.g., `memory.c'.
163 ;; Several tests fail on MIPS; see <http://hydra.gnu.org/build/117914>.
164 (supported-systems (delete "mips64el-linux" %supported-systems))))
167 ;; QEMU with GUI support.
168 (package (inherit qemu-headless)
170 (synopsis "Machine emulator and virtualizer")
171 (inputs `(("sdl" ,sdl)
173 ("libusb" ,libusb) ;USB pass-through support
174 ,@(package-inputs qemu-headless)))))