Gentoo Archives: gentoo-commits

From: Matthias Maier <tamiko@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/, app-emulation/qemu/files/
Date: Sun, 11 Feb 2018 20:27:33
Message-Id: 1518380821.725631c3eee62d147ea634c969ab90d1c70f5612.tamiko@gentoo
1 commit: 725631c3eee62d147ea634c969ab90d1c70f5612
2 Author: Matthias Maier <tamiko <AT> gentoo <DOT> org>
3 AuthorDate: Sun Feb 11 20:16:02 2018 +0000
4 Commit: Matthias Maier <tamiko <AT> gentoo <DOT> org>
5 CommitDate: Sun Feb 11 20:27:01 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=725631c3
7
8 app-emulation/qemu: version bump to 2.11.0, important security fixes
9
10 - Added slot operator for libnfs
11
12 - Added patch for glibc-2.27 compatibility
13
14 - Added patch for CVE-2017-16845
15
16 - Backported upstream msr / spec ctrl patches:
17
18 6cfbc54e89 i386: Add EPYC-IBPB CPU model
19 ac96c41354 i386: Add new -IBRS versions of Intel CPU models
20 1b3420e1c4 i386: Add FEAT_8000_0008_EBX CPUID feature word
21 a2381f0934 i386: Add spec-ctrl CPUID bit
22 a33a2cfe2f i386: Add support for SPEC_CTRL MSR
23
24 - CVEs addressed by bump:
25
26 CVE-2017-17381
27 CVE-2017-18030
28 CVE-2017-18043
29
30 - CVEs addressed by patchset:
31
32 CVE-2017-15124
33 CVE-2017-16845
34 CVE-2018-5683
35
36 - CVE-2018-5748 is a libvirt vulnerability, not a qemu issue...
37
38 Bug: https://bugs.gentoo.org/638506
39 Bug: https://bugs.gentoo.org/643432
40 Bug: https://bugs.gentoo.org/646814
41 Closes: https://bugs.gentoo.org/641100
42 Closes: https://bugs.gentoo.org/646568
43 Closes: https://bugs.gentoo.org/646710
44 Package-Manager: Portage-2.3.24, Repoman-2.3.6
45
46 app-emulation/qemu/Manifest | 2 +
47 .../qemu/files/qemu-2.11.0-glibc-2.27.patch | 54 ++
48 app-emulation/qemu/qemu-2.11.0.ebuild | 803 +++++++++++++++++++++
49 3 files changed, 859 insertions(+)
50
51 diff --git a/app-emulation/qemu/Manifest b/app-emulation/qemu/Manifest
52 index 2aded65fd90..9f60936fb82 100644
53 --- a/app-emulation/qemu/Manifest
54 +++ b/app-emulation/qemu/Manifest
55 @@ -1 +1,3 @@
56 DIST qemu-2.10.1.tar.bz2 30821108 BLAKE2B bb096139f6b387a3cf3933dd3aeb97777479022b1b34ed0212b51d7061f9a19b3e83a4e9a13c6cf81c14718731ddf8646226a5b0d99ebbc9abb387d7eec94238 SHA512 1a4a6ebf700ec6851c83cc2a71eaea8d95f14c685d094eaaa86c740eb9401e49a79074b72385f58681ca7646771a99bb6bbd9bebb39162f7220626d37ed0654f
57 +DIST qemu-2.11.0-patches-r0.tar.xz 16140 BLAKE2B 2e23908075195a7c28df574525a159e171277a2da6d7c0656a341a2db6a622237106d2dd8de5c9d61b5fb62fa5a163e9657406a2996cebc05baa53d42c5f5d15 SHA512 f7d92c2232398565b8cde294d38dc281c13503fb5967cc7871a2233b7fa354799619445e9ec89c285ef051f62ecef0bd38a135b0093bf5528c0b28c6e580c839
58 +DIST qemu-2.11.0.tar.bz2 32816398 BLAKE2B 2014a8246f3cba9069186629d9ec8c221672fcfd3e8cd28a7e57f467add81f7bd84363183ef5cc5d18af91bde9186a4da49c0133c8ead83eae4626b9fc364e99 SHA512 3681700833573c0aa6283af950bfa298970056f1b44489088d8863840a7694512138321f86961ef43b256abf15eddd2612fb9cdbe3d9a358542d4e7037cc2004
59
60 diff --git a/app-emulation/qemu/files/qemu-2.11.0-glibc-2.27.patch b/app-emulation/qemu/files/qemu-2.11.0-glibc-2.27.patch
61 new file mode 100644
62 index 00000000000..1562bb3c64a
63 --- /dev/null
64 +++ b/app-emulation/qemu/files/qemu-2.11.0-glibc-2.27.patch
65 @@ -0,0 +1,54 @@
66 +From 75e5b70e6b5dcc4f2219992d7cffa462aa406af0 Mon Sep 17 00:00:00 2001
67 +From: Paolo Bonzini <pbonzini@××××××.com>
68 +Date: Tue, 28 Nov 2017 11:51:27 +0100
69 +Subject: [PATCH] memfd: fix configure test
70 +MIME-Version: 1.0
71 +Content-Type: text/plain; charset=UTF-8
72 +Content-Transfer-Encoding: 8bit
73 +
74 +Recent glibc added memfd_create in sys/mman.h. This conflicts with
75 +the definition in util/memfd.c:
76 +
77 + /builddir/build/BUILD/qemu-2.11.0-rc1/util/memfd.c:40:12: error: static declaration of memfd_create follows non-static declaration
78 +
79 +Fix the configure test, and remove the sys/memfd.h inclusion since the
80 +file actually does not exist---it is a typo in the memfd_create(2) man
81 +page.
82 +
83 +Cc: Marc-André Lureau <marcandre.lureau@××××××.com>
84 +Signed-off-by: Paolo Bonzini <pbonzini@××××××.com>
85 +---
86 + configure | 2 +-
87 + util/memfd.c | 4 +---
88 + 2 files changed, 2 insertions(+), 4 deletions(-)
89 +
90 +diff --git a/configure b/configure
91 +index 9c8aa5a98b..99ccc1725a 100755
92 +--- a/configure
93 ++++ b/configure
94 +@@ -3923,7 +3923,7 @@ fi
95 + # check if memfd is supported
96 + memfd=no
97 + cat > $TMPC << EOF
98 +-#include <sys/memfd.h>
99 ++#include <sys/mman.h>
100 +
101 + int main(void)
102 + {
103 +diff --git a/util/memfd.c b/util/memfd.c
104 +index 4571d1aba8..412e94a405 100644
105 +--- a/util/memfd.c
106 ++++ b/util/memfd.c
107 +@@ -31,9 +31,7 @@
108 +
109 + #include "qemu/memfd.h"
110 +
111 +-#ifdef CONFIG_MEMFD
112 +-#include <sys/memfd.h>
113 +-#elif defined CONFIG_LINUX
114 ++#if defined CONFIG_LINUX && !defined CONFIG_MEMFD
115 + #include <sys/syscall.h>
116 + #include <asm/unistd.h>
117 +
118 +--
119 +2.11.0
120
121 diff --git a/app-emulation/qemu/qemu-2.11.0.ebuild b/app-emulation/qemu/qemu-2.11.0.ebuild
122 new file mode 100644
123 index 00000000000..6a81020bf7e
124 --- /dev/null
125 +++ b/app-emulation/qemu/qemu-2.11.0.ebuild
126 @@ -0,0 +1,803 @@
127 +# Copyright 1999-2018 Gentoo Foundation
128 +# Distributed under the terms of the GNU General Public License v2
129 +
130 +EAPI="6"
131 +
132 +PYTHON_COMPAT=( python2_7 )
133 +PYTHON_REQ_USE="ncurses,readline"
134 +
135 +PLOCALES="bg de_DE fr_FR hu it tr zh_CN"
136 +
137 +FIRMWARE_ABI_VERSION="2.9.0-r52"
138 +
139 +inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
140 + user udev fcaps readme.gentoo-r1 pax-utils l10n
141 +
142 +if [[ ${PV} = *9999* ]]; then
143 + EGIT_REPO_URI="git://git.qemu.org/qemu.git"
144 + inherit git-r3
145 + SRC_URI=""
146 +else
147 + SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2"
148 + KEYWORDS="~amd64 ~arm64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
149 +
150 + # Gentoo specific patchsets:
151 + SRC_URI+=" https://dev.gentoo.org/~tamiko/distfiles/${P}-patches-r0.tar.xz"
152 +fi
153 +
154 +
155 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
156 +HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
157 +
158 +LICENSE="GPL-2 LGPL-2 BSD-2"
159 +SLOT="0"
160 +IUSE="accessibility +aio alsa bluetooth bzip2 +caps +curl debug +fdt
161 + glusterfs gnutls gtk gtk2 infiniband iscsi +jpeg kernel_linux
162 + kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs +png
163 + pulseaudio python rbd sasl +seccomp sdl sdl2 selinux smartcard snappy
164 + spice ssh static static-user systemtap tci test usb usbredir vde
165 + +vhost-net virgl virtfs +vnc vte xattr xen xfs"
166 +
167 +COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel
168 + mips mips64 mips64el mipsel nios2 or1k ppc ppc64 s390x sh4 sh4eb sparc
169 + sparc64 x86_64"
170 +IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS}
171 + lm32 moxie ppcemb tricore unicore32 xtensa xtensaeb"
172 +IUSE_USER_TARGETS="${COMMON_TARGETS}
173 + armeb hppa mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus tilegx"
174 +
175 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
176 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
177 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
178 +
179 +# Allow no targets to be built so that people can get a tools-only build.
180 +# Block USE flag configurations known to not work.
181 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
182 + gtk2? ( gtk )
183 + qemu_softmmu_targets_arm? ( fdt )
184 + qemu_softmmu_targets_microblaze? ( fdt )
185 + qemu_softmmu_targets_mips64el? ( fdt )
186 + qemu_softmmu_targets_ppc? ( fdt )
187 + qemu_softmmu_targets_ppc64? ( fdt )
188 + sdl2? ( sdl )
189 + static? ( static-user !alsa !bluetooth !gtk !gtk2 !opengl !pulseaudio )
190 + virtfs? ( xattr )
191 + vte? ( gtk )"
192 +
193 +# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
194 +# and user/softmmu targets (qemu-*, qemu-system-*).
195 +#
196 +# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
197 +#
198 +# The attr lib isn't always linked in (although the USE flag is always
199 +# respected). This is because qemu supports using the C library's API
200 +# when available rather than always using the extranl library.
201 +ALL_DEPEND="
202 + >=dev-libs/glib-2.0[static-libs(+)]
203 + sys-libs/zlib[static-libs(+)]
204 + python? ( ${PYTHON_DEPS} )
205 + systemtap? ( dev-util/systemtap )
206 + xattr? ( sys-apps/attr[static-libs(+)] )"
207 +
208 +# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
209 +# softmmu targets (qemu-system-*).
210 +SOFTMMU_TOOLS_DEPEND="
211 + >=x11-libs/pixman-0.28.0[static-libs(+)]
212 + accessibility? (
213 + app-accessibility/brltty[api]
214 + app-accessibility/brltty[static-libs(+)]
215 + )
216 + aio? ( dev-libs/libaio[static-libs(+)] )
217 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
218 + bluetooth? ( net-wireless/bluez )
219 + bzip2? ( app-arch/bzip2[static-libs(+)] )
220 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
221 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
222 + fdt? ( >=sys-apps/dtc-1.4.2[static-libs(+)] )
223 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
224 + gnutls? (
225 + dev-libs/nettle:=[static-libs(+)]
226 + >=net-libs/gnutls-3.0:=[static-libs(+)]
227 + )
228 + gtk? (
229 + gtk2? (
230 + x11-libs/gtk+:2
231 + vte? ( x11-libs/vte:0 )
232 + )
233 + !gtk2? (
234 + x11-libs/gtk+:3
235 + vte? ( x11-libs/vte:2.91 )
236 + )
237 + )
238 + infiniband? ( sys-fabric/librdmacm:=[static-libs(+)] )
239 + iscsi? ( net-libs/libiscsi )
240 + jpeg? ( virtual/jpeg:0=[static-libs(+)] )
241 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
242 + ncurses? (
243 + sys-libs/ncurses:0=[unicode]
244 + sys-libs/ncurses:0=[static-libs(+)]
245 + )
246 + nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
247 + numa? ( sys-process/numactl[static-libs(+)] )
248 + opengl? (
249 + virtual/opengl
250 + media-libs/libepoxy[static-libs(+)]
251 + media-libs/mesa[static-libs(+)]
252 + media-libs/mesa[egl,gbm]
253 + )
254 + png? ( media-libs/libpng:0=[static-libs(+)] )
255 + pulseaudio? ( media-sound/pulseaudio )
256 + rbd? ( sys-cluster/ceph[static-libs(+)] )
257 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
258 + sdl? (
259 + !sdl2? (
260 + media-libs/libsdl[X]
261 + >=media-libs/libsdl-1.2.11[static-libs(+)]
262 + )
263 + sdl2? (
264 + media-libs/libsdl2[X]
265 + media-libs/libsdl2[static-libs(+)]
266 + )
267 + )
268 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
269 + smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
270 + snappy? ( app-arch/snappy:=[static-libs(+)] )
271 + spice? (
272 + >=app-emulation/spice-protocol-0.12.3
273 + >=app-emulation/spice-0.12.0[static-libs(+)]
274 + )
275 + ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
276 + usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
277 + usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
278 + vde? ( net-misc/vde[static-libs(+)] )
279 + virgl? ( media-libs/virglrenderer[static-libs(+)] )
280 + virtfs? ( sys-libs/libcap )
281 + xen? ( app-emulation/xen-tools:= )
282 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
283 +
284 +X86_FIRMWARE_DEPEND="
285 + pin-upstream-blobs? (
286 + ~sys-firmware/edk2-ovmf-2017_pre20170505[binary]
287 + ~sys-firmware/ipxe-1.0.0_p20160620
288 + ~sys-firmware/seabios-1.10.2[binary,seavgabios]
289 + ~sys-firmware/sgabios-0.1_pre8
290 + )
291 + !pin-upstream-blobs? (
292 + sys-firmware/edk2-ovmf
293 + sys-firmware/ipxe
294 + >=sys-firmware/seabios-1.10.2[seavgabios]
295 + sys-firmware/sgabios
296 + )"
297 +PPC64_FIRMWARE_DEPEND="
298 + pin-upstream-blobs? (
299 + ~sys-firmware/seabios-1.10.2[binary,seavgabios]
300 + )
301 + !pin-upstream-blobs? (
302 + >=sys-firmware/seabios-1.10.2[seavgabios]
303 + )
304 +"
305 +
306 +CDEPEND="
307 + !static? (
308 + ${ALL_DEPEND//\[static-libs(+)]}
309 + ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
310 + )
311 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
312 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
313 + qemu_softmmu_targets_ppc64? ( ${PPC64_FIRMWARE_DEPEND} )
314 +"
315 +DEPEND="${CDEPEND}
316 + dev-lang/perl
317 + =dev-lang/python-2*
318 + sys-apps/texinfo
319 + virtual/pkgconfig
320 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
321 + gtk? ( nls? ( sys-devel/gettext ) )
322 + static? (
323 + ${ALL_DEPEND}
324 + ${SOFTMMU_TOOLS_DEPEND}
325 + )
326 + static-user? ( ${ALL_DEPEND} )
327 + test? (
328 + dev-libs/glib[utils]
329 + sys-devel/bc
330 + )"
331 +RDEPEND="${CDEPEND}
332 + selinux? ( sec-policy/selinux-qemu )"
333 +
334 +PATCHES=(
335 + "${FILESDIR}"/${PN}-2.5.0-cflags.patch
336 + "${FILESDIR}"/${PN}-2.5.0-sysmacros.patch
337 + "${FILESDIR}"/${PN}-2.11.0-glibc-2.27.patch
338 + "${WORKDIR}"/patches
339 +)
340 +
341 +STRIP_MASK="/usr/share/qemu/palcode-clipper"
342 +
343 +QA_PREBUILT="
344 + usr/share/qemu/openbios-ppc
345 + usr/share/qemu/openbios-sparc64
346 + usr/share/qemu/openbios-sparc32
347 + usr/share/qemu/palcode-clipper
348 + usr/share/qemu/s390-ccw.img
349 + usr/share/qemu/s390-netboot.img
350 + usr/share/qemu/u-boot.e500"
351 +
352 +QA_WX_LOAD="usr/bin/qemu-i386
353 + usr/bin/qemu-x86_64
354 + usr/bin/qemu-alpha
355 + usr/bin/qemu-arm
356 + usr/bin/qemu-cris
357 + usr/bin/qemu-m68k
358 + usr/bin/qemu-microblaze
359 + usr/bin/qemu-microblazeel
360 + usr/bin/qemu-mips
361 + usr/bin/qemu-mipsel
362 + usr/bin/qemu-or1k
363 + usr/bin/qemu-ppc
364 + usr/bin/qemu-ppc64
365 + usr/bin/qemu-ppc64abi32
366 + usr/bin/qemu-sh4
367 + usr/bin/qemu-sh4eb
368 + usr/bin/qemu-sparc
369 + usr/bin/qemu-sparc64
370 + usr/bin/qemu-armeb
371 + usr/bin/qemu-sparc32plus
372 + usr/bin/qemu-s390x
373 + usr/bin/qemu-unicore32"
374 +
375 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
376 +kernel module loaded before running kvm. The easiest way to ensure that the
377 +kernel module is loaded is to load it on boot.
378 + For AMD CPUs the module is called 'kvm-amd'.
379 + For Intel CPUs the module is called 'kvm-intel'.
380 +Please review /etc/conf.d/modules for how to load these.
381 +
382 +Make sure your user is in the 'kvm' group. Just run
383 + $ gpasswd -a <USER> kvm
384 +then have <USER> re-login.
385 +
386 +For brand new installs, the default permissions on /dev/kvm might not let
387 +you access it. You can tell udev to reset ownership/perms:
388 + $ udevadm trigger -c add /dev/kvm
389 +
390 +If you want to register binfmt handlers for qemu user targets:
391 +For openrc:
392 + # rc-update add qemu-binfmt
393 +For systemd:
394 + # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
395 +
396 +pkg_pretend() {
397 + if use kernel_linux && kernel_is lt 2 6 25; then
398 + eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
399 + elif use kernel_linux; then
400 + if ! linux_config_exists; then
401 + eerror "Unable to check your kernel for KVM support"
402 + else
403 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
404 + ERROR_KVM="You must enable KVM in your kernel to continue"
405 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
406 + ERROR_KVM_AMD+=" your kernel configuration."
407 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
408 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
409 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
410 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
411 + ERROR_TUN+=" virtual network device if using -net tap."
412 + ERROR_BRIDGE="You will also need support for 802.1d"
413 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
414 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
415 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
416 + ERROR_VHOST_NET+=" support"
417 +
418 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
419 + if grep -q AuthenticAMD /proc/cpuinfo; then
420 + CONFIG_CHECK+=" ~KVM_AMD"
421 + elif grep -q GenuineIntel /proc/cpuinfo; then
422 + CONFIG_CHECK+=" ~KVM_INTEL"
423 + fi
424 + fi
425 +
426 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
427 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
428 +
429 + # Now do the actual checks setup above
430 + check_extra_config
431 + fi
432 + fi
433 +
434 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
435 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
436 + eerror "instances are still pointing to it. Please update your"
437 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
438 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
439 + die "update your virt configs to not use qemu-kvm"
440 + fi
441 +}
442 +
443 +pkg_setup() {
444 + enewgroup kvm 78
445 +}
446 +
447 +# Sanity check to make sure target lists are kept up-to-date.
448 +check_targets() {
449 + local var=$1 mak=$2
450 + local detected sorted
451 +
452 + pushd "${S}"/default-configs >/dev/null || die
453 +
454 + # Force C locale until glibc is updated. #564936
455 + detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
456 + sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
457 + if [[ ${sorted} != "${detected}" ]] ; then
458 + eerror "The ebuild needs to be kept in sync."
459 + eerror "${var}: ${sorted}"
460 + eerror "$(printf '%-*s' ${#var} configure): ${detected}"
461 + die "sync ${var} to the list of targets"
462 + fi
463 +
464 + popd >/dev/null
465 +}
466 +
467 +handle_locales() {
468 + # Make sure locale list is kept up-to-date.
469 + local detected sorted
470 + detected=$(echo $(cd po && printf '%s\n' *.po | grep -v messages.po | sed 's:.po$::' | sort -u))
471 + sorted=$(echo $(printf '%s\n' ${PLOCALES} | sort -u))
472 + if [[ ${sorted} != "${detected}" ]] ; then
473 + eerror "The ebuild needs to be kept in sync."
474 + eerror "PLOCALES: ${sorted}"
475 + eerror " po/*.po: ${detected}"
476 + die "sync PLOCALES"
477 + fi
478 +
479 + # Deal with selective install of locales.
480 + if use nls ; then
481 + # Delete locales the user does not want. #577814
482 + rm_loc() { rm po/$1.po || die; }
483 + l10n_for_each_disabled_locale_do rm_loc
484 + else
485 + # Cheap hack to disable gettext .mo generation.
486 + rm -f po/*.po
487 + fi
488 +}
489 +
490 +src_prepare() {
491 + check_targets IUSE_SOFTMMU_TARGETS softmmu
492 + check_targets IUSE_USER_TARGETS linux-user
493 +
494 + # Alter target makefiles to accept CFLAGS set via flag-o
495 + sed -i -r \
496 + -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
497 + Makefile Makefile.target || die
498 +
499 + default
500 +
501 + # Fix ld and objcopy being called directly
502 + tc-export AR LD OBJCOPY
503 +
504 + # Verbose builds
505 + MAKEOPTS+=" V=1"
506 +
507 + # Run after we've applied all patches.
508 + handle_locales
509 +
510 + # Remove bundled copy of libfdt
511 + rm -r dtc || die
512 +}
513 +
514 +##
515 +# configures qemu based on the build directory and the build type
516 +# we are using.
517 +#
518 +qemu_src_configure() {
519 + debug-print-function ${FUNCNAME} "$@"
520 +
521 + local buildtype=$1
522 + local builddir="${S}/${buildtype}-build"
523 +
524 + mkdir "${builddir}"
525 +
526 + local conf_opts=(
527 + --prefix=/usr
528 + --sysconfdir=/etc
529 + --libdir=/usr/$(get_libdir)
530 + --docdir=/usr/share/doc/${PF}/html
531 + --disable-bsd-user
532 + --disable-guest-agent
533 + --disable-strip
534 + --disable-werror
535 + # We support gnutls/nettle for crypto operations. It is possible
536 + # to use gcrypt when gnutls/nettle are disabled (but not when they
537 + # are enabled), but it's not really worth the hassle. Disable it
538 + # all the time to avoid automatically detecting it. #568856
539 + --disable-gcrypt
540 + --python="${PYTHON}"
541 + --cc="$(tc-getCC)"
542 + --cxx="$(tc-getCXX)"
543 + --host-cc="$(tc-getBUILD_CC)"
544 + $(use_enable debug debug-info)
545 + $(use_enable debug debug-tcg)
546 + --enable-docs
547 + $(use_enable tci tcg-interpreter)
548 + $(use_enable xattr attr)
549 + )
550 +
551 + # Disable options not used by user targets. This simplifies building
552 + # static user targets (USE=static-user) considerably.
553 + conf_notuser() {
554 + if [[ ${buildtype} == "user" ]] ; then
555 + echo "--disable-${2:-$1}"
556 + else
557 + use_enable "$@"
558 + fi
559 + }
560 + conf_opts+=(
561 + $(conf_notuser accessibility brlapi)
562 + $(conf_notuser aio linux-aio)
563 + $(conf_notuser bzip2)
564 + $(conf_notuser bluetooth bluez)
565 + $(conf_notuser caps cap-ng)
566 + $(conf_notuser curl)
567 + $(conf_notuser fdt)
568 + $(conf_notuser glusterfs)
569 + $(conf_notuser gnutls)
570 + $(conf_notuser gnutls nettle)
571 + $(conf_notuser gtk)
572 + $(conf_notuser infiniband rdma)
573 + $(conf_notuser iscsi libiscsi)
574 + $(conf_notuser jpeg vnc-jpeg)
575 + $(conf_notuser kernel_linux kvm)
576 + $(conf_notuser lzo)
577 + $(conf_notuser ncurses curses)
578 + $(conf_notuser nfs libnfs)
579 + $(conf_notuser numa)
580 + $(conf_notuser opengl)
581 + $(conf_notuser png vnc-png)
582 + $(conf_notuser rbd)
583 + $(conf_notuser sasl vnc-sasl)
584 + $(conf_notuser sdl)
585 + $(conf_notuser seccomp)
586 + $(conf_notuser smartcard)
587 + $(conf_notuser snappy)
588 + $(conf_notuser spice)
589 + $(conf_notuser ssh libssh2)
590 + $(conf_notuser usb libusb)
591 + $(conf_notuser usbredir usb-redir)
592 + $(conf_notuser vde)
593 + $(conf_notuser vhost-net)
594 + $(conf_notuser virgl virglrenderer)
595 + $(conf_notuser virtfs)
596 + $(conf_notuser vnc)
597 + $(conf_notuser vte)
598 + $(conf_notuser xen)
599 + $(conf_notuser xen xen-pci-passthrough)
600 + $(conf_notuser xfs xfsctl)
601 + )
602 +
603 + if [[ ! ${buildtype} == "user" ]] ; then
604 + # audio options
605 + local audio_opts="oss"
606 + use alsa && audio_opts="alsa,${audio_opts}"
607 + use sdl && audio_opts="sdl,${audio_opts}"
608 + use pulseaudio && audio_opts="pa,${audio_opts}"
609 + conf_opts+=(
610 + --audio-drv-list="${audio_opts}"
611 + )
612 + use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
613 + use sdl && conf_opts+=( --with-sdlabi=$(usex sdl2 2.0 1.2) )
614 + fi
615 +
616 + case ${buildtype} in
617 + user)
618 + conf_opts+=(
619 + --enable-linux-user
620 + --disable-system
621 + --disable-blobs
622 + --disable-tools
623 + )
624 + local static_flag="static-user"
625 + ;;
626 + softmmu)
627 + conf_opts+=(
628 + --disable-linux-user
629 + --enable-system
630 + --disable-tools
631 + )
632 + local static_flag="static"
633 + ;;
634 + tools)
635 + conf_opts+=(
636 + --disable-linux-user
637 + --disable-system
638 + --disable-blobs
639 + --enable-tools
640 + )
641 + local static_flag="static"
642 + ;;
643 + esac
644 +
645 + local targets="${buildtype}_targets"
646 + [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
647 +
648 + # Add support for SystemTAP
649 + use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
650 +
651 + # We always want to attempt to build with PIE support as it results
652 + # in a more secure binary. But it doesn't work with static or if
653 + # the current GCC doesn't have PIE support.
654 + if use ${static_flag}; then
655 + conf_opts+=( --static --disable-pie )
656 + else
657 + tc-enables-pie && conf_opts+=( --enable-pie )
658 + fi
659 +
660 + echo "../configure ${conf_opts[*]}"
661 + cd "${builddir}"
662 + ../configure "${conf_opts[@]}" || die "configure failed"
663 +
664 + # FreeBSD's kernel does not support QEMU assigning/grabbing
665 + # host USB devices yet
666 + use kernel_FreeBSD && \
667 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
668 +}
669 +
670 +src_configure() {
671 + local target
672 +
673 + python_setup
674 +
675 + softmmu_targets= softmmu_bins=()
676 + user_targets= user_bins=()
677 +
678 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
679 + if use "qemu_softmmu_targets_${target}"; then
680 + softmmu_targets+=",${target}-softmmu"
681 + softmmu_bins+=( "qemu-system-${target}" )
682 + fi
683 + done
684 +
685 + for target in ${IUSE_USER_TARGETS} ; do
686 + if use "qemu_user_targets_${target}"; then
687 + user_targets+=",${target}-linux-user"
688 + user_bins+=( "qemu-${target}" )
689 + fi
690 + done
691 +
692 + softmmu_targets=${softmmu_targets#,}
693 + user_targets=${user_targets#,}
694 +
695 + [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
696 + [[ -n ${user_targets} ]] && qemu_src_configure "user"
697 + qemu_src_configure "tools"
698 +}
699 +
700 +src_compile() {
701 + if [[ -n ${user_targets} ]]; then
702 + cd "${S}/user-build"
703 + default
704 + fi
705 +
706 + if [[ -n ${softmmu_targets} ]]; then
707 + cd "${S}/softmmu-build"
708 + default
709 + fi
710 +
711 + cd "${S}/tools-build"
712 + default
713 +}
714 +
715 +src_test() {
716 + if [[ -n ${softmmu_targets} ]]; then
717 + cd "${S}/softmmu-build"
718 + pax-mark m */qemu-system-* #515550
719 + emake -j1 check
720 + emake -j1 check-report.html
721 + fi
722 +}
723 +
724 +qemu_python_install() {
725 + python_domodule "${S}/scripts/qmp/qmp.py"
726 +
727 + python_doscript "${S}/scripts/kvm/vmxcap"
728 + python_doscript "${S}/scripts/qmp/qmp-shell"
729 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
730 +}
731 +
732 +# Generate binfmt support files.
733 +# - /etc/init.d/qemu-binfmt script which registers the user handlers (openrc)
734 +# - /usr/share/qemu/binfmt.d/qemu.conf (for use with systemd-binfmt)
735 +generate_initd() {
736 + local out="${T}/qemu-binfmt"
737 + local out_systemd="${T}/qemu.conf"
738 + local d="${T}/binfmt.d"
739 +
740 + einfo "Generating qemu binfmt scripts and configuration files"
741 +
742 + # Generate the debian fragments first.
743 + mkdir -p "${d}"
744 + "${S}"/scripts/qemu-binfmt-conf.sh \
745 + --debian \
746 + --exportdir "${d}" \
747 + --qemu-path "${EPREFIX}/usr/bin" \
748 + || die
749 + # Then turn the fragments into a shell script we can source.
750 + sed -E -i \
751 + -e 's:^([^ ]+) (.*)$:\1="\2":' \
752 + "${d}"/* || die
753 +
754 + # Generate the init.d script by assembling the fragments from above.
755 + local f qcpu package interpreter magic mask
756 + cat "${FILESDIR}"/qemu-binfmt.initd.head >"${out}" || die
757 + for f in "${d}"/qemu-* ; do
758 + source "${f}"
759 +
760 + # Normalize the cpu logic like we do in the init.d for the native cpu.
761 + qcpu=${package#qemu-}
762 + case ${qcpu} in
763 + arm*) qcpu="arm";;
764 + mips*) qcpu="mips";;
765 + ppc*) qcpu="ppc";;
766 + s390*) qcpu="s390";;
767 + sh*) qcpu="sh";;
768 + sparc*) qcpu="sparc";;
769 + esac
770 +
771 + cat <<EOF >>"${out}"
772 + if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
773 + echo ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
774 + fi
775 +EOF
776 +
777 + echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >>"${out_systemd}"
778 +
779 + done
780 + cat "${FILESDIR}"/qemu-binfmt.initd.tail >>"${out}" || die
781 +}
782 +
783 +src_install() {
784 + if [[ -n ${user_targets} ]]; then
785 + cd "${S}/user-build"
786 + emake DESTDIR="${ED}" install
787 +
788 + # Install binfmt handler init script for user targets.
789 + generate_initd
790 + doinitd "${T}/qemu-binfmt"
791 +
792 + # Install binfmt/qemu.conf.
793 + insinto "/usr/share/qemu/binfmt.d"
794 + doins "${T}/qemu.conf"
795 + fi
796 +
797 + if [[ -n ${softmmu_targets} ]]; then
798 + cd "${S}/softmmu-build"
799 + emake DESTDIR="${ED}" install
800 +
801 + # This might not exist if the test failed. #512010
802 + [[ -e check-report.html ]] && dohtml check-report.html
803 +
804 + if use kernel_linux; then
805 + udev_newrules "${FILESDIR}"/65-kvm.rules-r1 65-kvm.rules
806 + fi
807 +
808 + if use python; then
809 + python_foreach_impl qemu_python_install
810 + fi
811 + fi
812 +
813 + cd "${S}/tools-build"
814 + emake DESTDIR="${ED}" install
815 +
816 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
817 + pushd "${ED}"/usr/bin >/dev/null
818 + pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
819 + popd >/dev/null
820 +
821 + # Install config file example for qemu-bridge-helper
822 + insinto "/etc/qemu"
823 + doins "${FILESDIR}/bridge.conf"
824 +
825 + cd "${S}"
826 + dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
827 + newdoc pc-bios/README README.pc-bios
828 +
829 + if [[ -n ${softmmu_targets} ]]; then
830 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
831 + rm "${ED}/usr/share/qemu/bios.bin"
832 + rm "${ED}/usr/share/qemu/bios-256k.bin"
833 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
834 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
835 + dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
836 + fi
837 +
838 + # Remove vgabios since we're using the seavgabios packaged one
839 + rm "${ED}/usr/share/qemu/vgabios.bin"
840 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
841 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
842 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
843 + rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
844 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
845 + # PPC64 loads vgabios-stdvga
846 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc64; then
847 + dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
848 + dosym ../seavgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
849 + dosym ../seavgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
850 + dosym ../seavgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
851 + dosym ../seavgabios/vgabios-virtio.bin /usr/share/qemu/vgabios-virtio.bin
852 + dosym ../seavgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
853 + fi
854 +
855 + # Remove sgabios since we're using the sgabios packaged one
856 + rm "${ED}/usr/share/qemu/sgabios.bin"
857 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
858 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
859 + fi
860 +
861 + # Remove iPXE since we're using the iPXE packaged one
862 + rm "${ED}"/usr/share/qemu/pxe-*.rom
863 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
864 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
865 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
866 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
867 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
868 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
869 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
870 + fi
871 + fi
872 +
873 + DISABLE_AUTOFORMATTING=true
874 + readme.gentoo_create_doc
875 +}
876 +
877 +firmware_abi_change() {
878 + local pv
879 + for pv in ${REPLACING_VERSIONS}; do
880 + if ! version_is_at_least ${FIRMWARE_ABI_VERSION} ${pv}; then
881 + return 0
882 + fi
883 + done
884 + return 1
885 +}
886 +
887 +pkg_postinst() {
888 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
889 + udev_reload
890 + fi
891 +
892 + fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
893 +
894 + DISABLE_AUTOFORMATTING=true
895 + readme.gentoo_print_elog
896 +
897 + if use pin-upstream-blobs && firmware_abi_change; then
898 + ewarn "This version of qemu pins new versions of firmware blobs:"
899 + ewarn " $(best_version sys-firmware/edk2-ovmf)"
900 + ewarn " $(best_version sys-firmware/ipxe)"
901 + ewarn " $(best_version sys-firmware/seabios)"
902 + ewarn " $(best_version sys-firmware/sgabios)"
903 + ewarn "This might break resume of hibernated guests (started with a different"
904 + ewarn "firmware version) and live migration to/from qemu versions with different"
905 + ewarn "firmware. Please (cold) restart all running guests. For functional"
906 + ewarn "guest migration ensure that all"
907 + ewarn "hosts run at least"
908 + ewarn " app-emulation/qemu-${FIRMWARE_ABI_VERSION}."
909 + fi
910 +}
911 +
912 +pkg_info() {
913 + echo "Using:"
914 + echo " $(best_version app-emulation/spice-protocol)"
915 + echo " $(best_version sys-firmware/edk2-ovmf)"
916 + if has_version 'sys-firmware/edk2-ovmf[binary]'; then
917 + echo " USE=binary"
918 + else
919 + echo " USE=''"
920 + fi
921 + echo " $(best_version sys-firmware/ipxe)"
922 + echo " $(best_version sys-firmware/seabios)"
923 + if has_version 'sys-firmware/seabios[binary]'; then
924 + echo " USE=binary"
925 + else
926 + echo " USE=''"
927 + fi
928 + echo " $(best_version sys-firmware/sgabios)"
929 +}