Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/files/, app-emulation/qemu/
Date: Thu, 29 Dec 2016 18:47:34
Message-Id: 1483037233.cccbca44a3b25022fd715ea6112adffbb7293483.vapier@gentoo
1 commit: cccbca44a3b25022fd715ea6112adffbb7293483
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 29 18:19:47 2016 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 29 18:47:13 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cccbca44
7
8 app-emulation/qemu: version bump to 2.7.1
9
10 Update the 7422 patch to match the version upstream merged.
11 Update the 8669-1 patch to include upstream references since it is
12 still not merged/fixed.
13
14 app-emulation/qemu/Manifest | 1 +
15 .../qemu/files/qemu-2.7.0-CVE-2016-7422.patch | 47 +-
16 .../qemu/files/qemu-2.7.0-CVE-2016-8669-1.patch | 3 +
17 app-emulation/qemu/qemu-2.7.1.ebuild | 699 +++++++++++++++++++++
18 4 files changed, 726 insertions(+), 24 deletions(-)
19
20 diff --git a/app-emulation/qemu/Manifest b/app-emulation/qemu/Manifest
21 index 5e3e9b5..5d40bbd 100644
22 --- a/app-emulation/qemu/Manifest
23 +++ b/app-emulation/qemu/Manifest
24 @@ -1 +1,2 @@
25 DIST qemu-2.7.0.tar.bz2 26867760 SHA256 326e739506ba690daf69fc17bd3913a6c313d9928d743bd8eddb82f403f81e53 SHA512 654acaa7b3724a288e5d7e2a26ab780d9c9ed9f647fba00a906cbaffbe9d58fd666f2d962514aa2c5b391b4c53811ac3170d2eb51727f090bd19dfe45ca9a9db WHIRLPOOL dcb3e5f7da89dd8e14d636d7ebd476e076e0043880bb9ea3fb1c03cb4bcd4e5c7d3c4719da26c3ce521e3a3db5ae671e86f198ac1bc3474e774d75504fef8b8d
26 +DIST qemu-2.7.1.tar.bz2 26868403 SHA256 68636788eb69bcb0b44ba220b32b50495d6bd5712a934c282217831c4822958f SHA512 16a83946e9064733254c82c961749bf9c56a0a2a8ee46145b4a78e1452ac0e2548d888963d18c80e28f65202890fd643b0011951b5b1c66ef16234767ed91898 WHIRLPOOL ae3d3c2b2a3700613733659847de6187755631cb09e8c3548ea30cd994357c9ff128646edce88dfe4dce53e6c1c0f37f8de3688ee7e22262033b40f3fc706efa
27
28 diff --git a/app-emulation/qemu/files/qemu-2.7.0-CVE-2016-7422.patch b/app-emulation/qemu/files/qemu-2.7.0-CVE-2016-7422.patch
29 index 6368e7f..cc60581 100644
30 --- a/app-emulation/qemu/files/qemu-2.7.0-CVE-2016-7422.patch
31 +++ b/app-emulation/qemu/files/qemu-2.7.0-CVE-2016-7422.patch
32 @@ -1,38 +1,37 @@
33 -From: Prasad J Pandit <address@hidden>
34 +From 973e7170dddefb491a48df5cba33b2ae151013a0 Mon Sep 17 00:00:00 2001
35 +From: Prasad J Pandit <pjp@×××××××××××××.org>
36 +Date: Mon, 19 Sep 2016 23:55:45 +0530
37 +Subject: [PATCH] virtio: add check for descriptor's mapped address
38
39 virtio back end uses set of buffers to facilitate I/O operations.
40 If its size is too large, 'cpu_physical_memory_map' could return
41 -a null address. This would result in a null dereference
42 -while un-mapping descriptors. Add check to avoid it.
43 +a null address. This would result in a null dereference while
44 +un-mapping descriptors. Add check to avoid it.
45
46 -Reported-by: Qinghao Tang <address@hidden>
47 -Signed-off-by: Prasad J Pandit <address@hidden>
48 +Reported-by: Qinghao Tang <luodalongde@×××××.com>
49 +Signed-off-by: Prasad J Pandit <pjp@×××××××××××××.org>
50 +Reviewed-by: Michael S. Tsirkin <mst@××××××.com>
51 +Signed-off-by: Michael S. Tsirkin <mst@××××××.com>
52 +Reviewed-by: Laszlo Ersek <lersek@××××××.com>
53 ---
54 - hw/virtio/virtio.c | 10 ++++++----
55 - 1 file changed, 6 insertions(+), 4 deletions(-)
56 + hw/virtio/virtio.c | 5 +++++
57 + 1 file changed, 5 insertions(+)
58
59 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
60 -index 15ee3a7..0a4c5b6 100644
61 +index fcf3358d6c0d..bb656b1ccff0 100644
62 --- a/hw/virtio/virtio.c
63 +++ b/hw/virtio/virtio.c
64 -@@ -472,12 +472,14 @@ static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iove
65 +@@ -495,6 +495,11 @@ static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iove
66 }
67
68 iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write);
69 -- iov[num_sg].iov_len = len;
70 -- addr[num_sg] = pa;
71 -+ if (iov[num_sg].iov_base) {
72 -+ iov[num_sg].iov_len = len;
73 -+ addr[num_sg] = pa;
74 -
75 -+ pa += len;
76 -+ num_sg++;
77 ++ if (!iov[num_sg].iov_base) {
78 ++ error_report("virtio: bogus descriptor or out of resources");
79 ++ exit(1);
80 + }
81 - sz -= len;
82 -- pa += len;
83 -- num_sg++;
84 - }
85 - *p_num_sg = num_sg;
86 - }
87 ++
88 + iov[num_sg].iov_len = len;
89 + addr[num_sg] = pa;
90 +
91 --
92 -2.5.5
93 +2.11.0
94
95 diff --git a/app-emulation/qemu/files/qemu-2.7.0-CVE-2016-8669-1.patch b/app-emulation/qemu/files/qemu-2.7.0-CVE-2016-8669-1.patch
96 index 457f022..cea8efc 100644
97 --- a/app-emulation/qemu/files/qemu-2.7.0-CVE-2016-8669-1.patch
98 +++ b/app-emulation/qemu/files/qemu-2.7.0-CVE-2016-8669-1.patch
99 @@ -1,3 +1,6 @@
100 +http://bugs.gentoo.org/597108
101 +https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg02577.html
102 +
103 From: Prasad J Pandit <address@hidden>
104
105 The JAZZ RC4030 chipset emulator has a periodic timer and
106
107 diff --git a/app-emulation/qemu/qemu-2.7.1.ebuild b/app-emulation/qemu/qemu-2.7.1.ebuild
108 new file mode 100644
109 index 00000000..12eea6f
110 --- /dev/null
111 +++ b/app-emulation/qemu/qemu-2.7.1.ebuild
112 @@ -0,0 +1,699 @@
113 +# Copyright 1999-2016 Gentoo Foundation
114 +# Distributed under the terms of the GNU General Public License v2
115 +
116 +EAPI="5"
117 +
118 +PYTHON_COMPAT=( python2_7 )
119 +PYTHON_REQ_USE="ncurses,readline"
120 +
121 +PLOCALES="bg de_DE fr_FR hu it tr zh_CN"
122 +
123 +inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
124 + user udev fcaps readme.gentoo-r1 pax-utils l10n
125 +
126 +if [[ ${PV} = *9999* ]]; then
127 + EGIT_REPO_URI="git://git.qemu.org/qemu.git"
128 + inherit git-2
129 + SRC_URI=""
130 +else
131 + SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2"
132 + KEYWORDS="~amd64 ~arm64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
133 +fi
134 +
135 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
136 +HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
137 +
138 +LICENSE="GPL-2 LGPL-2 BSD-2"
139 +SLOT="0"
140 +IUSE="accessibility +aio alsa bluetooth bzip2 +caps +curl debug +fdt glusterfs \
141 +gnutls gtk gtk2 infiniband iscsi +jpeg \
142 +kernel_linux kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs
143 ++png pulseaudio python \
144 +rbd sasl +seccomp sdl sdl2 selinux smartcard snappy spice ssh static static-softmmu
145 +static-user systemtap tci test +threads usb usbredir +uuid vde +vhost-net \
146 +virgl virtfs +vnc vte xattr xen xfs"
147 +
148 +COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel mips
149 +mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc sparc64 unicore32
150 +x86_64"
151 +IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 moxie ppcemb tricore xtensa xtensaeb"
152 +IUSE_USER_TARGETS="${COMMON_TARGETS} armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus tilegx"
153 +
154 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
155 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
156 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
157 +
158 +# Allow no targets to be built so that people can get a tools-only build.
159 +# Block USE flag configurations known to not work.
160 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
161 + gtk2? ( gtk )
162 + qemu_softmmu_targets_arm? ( fdt )
163 + qemu_softmmu_targets_microblaze? ( fdt )
164 + qemu_softmmu_targets_ppc? ( fdt )
165 + qemu_softmmu_targets_ppc64? ( fdt )
166 + sdl2? ( sdl )
167 + static? ( static-softmmu static-user )
168 + static-softmmu? ( !alsa !pulseaudio !bluetooth !opengl !gtk !gtk2 )
169 + virtfs? ( xattr )
170 + vte? ( gtk )"
171 +
172 +# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
173 +#
174 +# The attr lib isn't always linked in (although the USE flag is always
175 +# respected). This is because qemu supports using the C library's API
176 +# when available rather than always using the extranl library.
177 +#
178 +# Older versions of gnutls are supported, but it's simpler to just require
179 +# the latest versions. This is also why we require nettle.
180 +#
181 +# TODO: Split out tools deps into another var. e.g. bzip2 is only used by
182 +# system binaries and tools, not user binaries.
183 +COMMON_LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
184 + sys-libs/zlib[static-libs(+)]
185 + bzip2? ( app-arch/bzip2[static-libs(+)] )
186 + xattr? ( sys-apps/attr[static-libs(+)] )"
187 +SOFTMMU_LIB_DEPEND="${COMMON_LIB_DEPEND}
188 + >=x11-libs/pixman-0.28.0[static-libs(+)]
189 + accessibility? ( app-accessibility/brltty[static-libs(+)] )
190 + aio? ( dev-libs/libaio[static-libs(+)] )
191 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
192 + bluetooth? ( net-wireless/bluez )
193 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
194 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
195 + fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] )
196 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
197 + gnutls? (
198 + dev-libs/nettle:=[static-libs(+)]
199 + >=net-libs/gnutls-3.0:=[static-libs(+)]
200 + )
201 + gtk? (
202 + gtk2? (
203 + x11-libs/gtk+:2
204 + vte? ( x11-libs/vte:0 )
205 + )
206 + !gtk2? (
207 + x11-libs/gtk+:3
208 + vte? ( x11-libs/vte:2.91 )
209 + )
210 + )
211 + infiniband? ( sys-fabric/librdmacm:=[static-libs(+)] )
212 + iscsi? ( net-libs/libiscsi )
213 + jpeg? ( virtual/jpeg:0=[static-libs(+)] )
214 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
215 + ncurses? ( sys-libs/ncurses:0=[static-libs(+)] )
216 + nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] )
217 + numa? ( sys-process/numactl[static-libs(+)] )
218 + opengl? (
219 + virtual/opengl
220 + media-libs/libepoxy[static-libs(+)]
221 + media-libs/mesa[static-libs(+)]
222 + media-libs/mesa[egl,gles2,gbm]
223 + )
224 + png? ( media-libs/libpng:0=[static-libs(+)] )
225 + pulseaudio? ( media-sound/pulseaudio )
226 + rbd? ( sys-cluster/ceph[static-libs(+)] )
227 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
228 + sdl? (
229 + !sdl2? (
230 + media-libs/libsdl[X]
231 + >=media-libs/libsdl-1.2.11[static-libs(+)]
232 + )
233 + sdl2? (
234 + media-libs/libsdl2[X]
235 + media-libs/libsdl2[static-libs(+)]
236 + )
237 + )
238 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
239 + smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
240 + snappy? ( app-arch/snappy[static-libs(+)] )
241 + spice? (
242 + >=app-emulation/spice-protocol-0.12.3
243 + >=app-emulation/spice-0.12.0[static-libs(+)]
244 + )
245 + ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
246 + usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
247 + usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
248 + uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
249 + vde? ( net-misc/vde[static-libs(+)] )
250 + virgl? ( media-libs/virglrenderer[static-libs(+)] )
251 + virtfs? ( sys-libs/libcap )
252 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
253 +USER_LIB_DEPEND="${COMMON_LIB_DEPEND}"
254 +X86_FIRMWARE_DEPEND="
255 + >=sys-firmware/ipxe-1.0.0_p20130624
256 + pin-upstream-blobs? (
257 + ~sys-firmware/seabios-1.8.2
258 + ~sys-firmware/sgabios-0.1_pre8
259 + ~sys-firmware/vgabios-0.7a
260 + )
261 + !pin-upstream-blobs? (
262 + sys-firmware/seabios
263 + sys-firmware/sgabios
264 + sys-firmware/vgabios
265 + )"
266 +CDEPEND="
267 + !static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND//\[static-libs(+)]} ) " ${use_softmmu_targets}) )
268 + !static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND//\[static-libs(+)]} ) " ${use_user_targets}) )
269 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
270 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
271 + python? ( ${PYTHON_DEPS} )
272 + systemtap? ( dev-util/systemtap )
273 + xen? ( app-emulation/xen-tools:= )"
274 +DEPEND="${CDEPEND}
275 + dev-lang/perl
276 + =dev-lang/python-2*
277 + sys-apps/texinfo
278 + virtual/pkgconfig
279 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
280 + gtk? ( nls? ( sys-devel/gettext ) )
281 + static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND} ) " ${use_softmmu_targets}) )
282 + static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND} ) " ${use_user_targets}) )
283 + test? (
284 + dev-libs/glib[utils]
285 + sys-devel/bc
286 + )"
287 +RDEPEND="${CDEPEND}
288 + selinux? ( sec-policy/selinux-qemu )
289 +"
290 +
291 +STRIP_MASK="/usr/share/qemu/palcode-clipper"
292 +
293 +QA_PREBUILT="
294 + usr/share/qemu/openbios-ppc
295 + usr/share/qemu/openbios-sparc64
296 + usr/share/qemu/openbios-sparc32
297 + usr/share/qemu/palcode-clipper
298 + usr/share/qemu/s390-ccw.img
299 + usr/share/qemu/u-boot.e500
300 +"
301 +
302 +QA_WX_LOAD="usr/bin/qemu-i386
303 + usr/bin/qemu-x86_64
304 + usr/bin/qemu-alpha
305 + usr/bin/qemu-arm
306 + usr/bin/qemu-cris
307 + usr/bin/qemu-m68k
308 + usr/bin/qemu-microblaze
309 + usr/bin/qemu-microblazeel
310 + usr/bin/qemu-mips
311 + usr/bin/qemu-mipsel
312 + usr/bin/qemu-or32
313 + usr/bin/qemu-ppc
314 + usr/bin/qemu-ppc64
315 + usr/bin/qemu-ppc64abi32
316 + usr/bin/qemu-sh4
317 + usr/bin/qemu-sh4eb
318 + usr/bin/qemu-sparc
319 + usr/bin/qemu-sparc64
320 + usr/bin/qemu-armeb
321 + usr/bin/qemu-sparc32plus
322 + usr/bin/qemu-s390x
323 + usr/bin/qemu-unicore32"
324 +
325 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure
326 +you have the kernel module loaded before running kvm. The easiest way to
327 +ensure that the kernel module is loaded is to load it on boot.\n
328 +For AMD CPUs the module is called 'kvm-amd'.\n
329 +For Intel CPUs the module is called 'kvm-intel'.\n
330 +Please review /etc/conf.d/modules for how to load these.\n\n
331 +Make sure your user is in the 'kvm' group\n
332 +Just run 'gpasswd -a <USER> kvm', then have <USER> re-login.\n\n
333 +For brand new installs, the default permissions on /dev/kvm might not let you
334 +access it. You can tell udev to reset ownership/perms:\n
335 +udevadm trigger -c add /dev/kvm"
336 +
337 +qemu_support_kvm() {
338 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 \
339 + use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64 \
340 + use qemu_softmmu_targets_s390x; then
341 + return 0
342 + fi
343 +
344 + return 1
345 +}
346 +
347 +pkg_pretend() {
348 + if use kernel_linux && kernel_is lt 2 6 25; then
349 + eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
350 + elif use kernel_linux; then
351 + if ! linux_config_exists; then
352 + eerror "Unable to check your kernel for KVM support"
353 + else
354 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
355 + ERROR_KVM="You must enable KVM in your kernel to continue"
356 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
357 + ERROR_KVM_AMD+=" your kernel configuration."
358 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
359 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
360 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
361 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
362 + ERROR_TUN+=" virtual network device if using -net tap."
363 + ERROR_BRIDGE="You will also need support for 802.1d"
364 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
365 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
366 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
367 + ERROR_VHOST_NET+=" support"
368 +
369 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
370 + CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL"
371 + fi
372 +
373 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
374 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
375 +
376 + # Now do the actual checks setup above
377 + check_extra_config
378 + fi
379 + fi
380 +
381 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
382 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
383 + eerror "instances are still pointing to it. Please update your"
384 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
385 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
386 + die "update your virt configs to not use qemu-kvm"
387 + fi
388 +}
389 +
390 +pkg_setup() {
391 + enewgroup kvm 78
392 +}
393 +
394 +# Sanity check to make sure target lists are kept up-to-date.
395 +check_targets() {
396 + local var=$1 mak=$2
397 + local detected sorted
398 +
399 + pushd "${S}"/default-configs >/dev/null || die
400 +
401 + # Force C locale until glibc is updated. #564936
402 + detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
403 + sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
404 + if [[ ${sorted} != "${detected}" ]] ; then
405 + eerror "The ebuild needs to be kept in sync."
406 + eerror "${var}: ${sorted}"
407 + eerror "$(printf '%-*s' ${#var} configure): ${detected}"
408 + die "sync ${var} to the list of targets"
409 + fi
410 +
411 + popd >/dev/null
412 +}
413 +
414 +handle_locales() {
415 + # Make sure locale list is kept up-to-date.
416 + local detected sorted
417 + detected=$(echo $(cd po && printf '%s\n' *.po | grep -v messages.po | sed 's:.po$::' | sort -u))
418 + sorted=$(echo $(printf '%s\n' ${PLOCALES} | sort -u))
419 + if [[ ${sorted} != "${detected}" ]] ; then
420 + eerror "The ebuild needs to be kept in sync."
421 + eerror "PLOCALES: ${sorted}"
422 + eerror " po/*.po: ${detected}"
423 + die "sync PLOCALES"
424 + fi
425 +
426 + # Deal with selective install of locales.
427 + if use nls ; then
428 + # Delete locales the user does not want. #577814
429 + rm_loc() { rm po/$1.po || die; }
430 + l10n_for_each_disabled_locale_do rm_loc
431 + else
432 + # Cheap hack to disable gettext .mo generation.
433 + rm -f po/*.po
434 + fi
435 +}
436 +
437 +src_prepare() {
438 + check_targets IUSE_SOFTMMU_TARGETS softmmu
439 + check_targets IUSE_USER_TARGETS linux-user
440 +
441 + # Alter target makefiles to accept CFLAGS set via flag-o
442 + sed -i -r \
443 + -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
444 + Makefile Makefile.target || die
445 +
446 + epatch "${FILESDIR}"/${PN}-2.5.0-cflags.patch
447 + epatch "${FILESDIR}"/${PN}-2.5.0-sysmacros.patch
448 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-6836.patch #591242
449 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7156.patch #593036
450 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7170.patch #593284
451 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7422.patch #593956
452 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7466.patch #594520
453 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7907.patch #596048
454 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7908.patch #596049
455 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7909.patch #596048
456 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7994-1.patch #596738
457 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-7994-2.patch #596738
458 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-8576.patch #596752
459 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-8577.patch #596776
460 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-8578.patch #596774
461 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-8668.patch #597110
462 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-8669-1.patch #597108
463 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-8669-2.patch #597108
464 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-8909.patch #598044
465 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-9102.patch #598328
466 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-9103.patch #598328
467 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-9104.patch #598328
468 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-9105.patch #598328
469 + epatch "${FILESDIR}"/${PN}-2.7.0-CVE-2016-9106.patch #598772
470 +
471 + # Fix ld and objcopy being called directly
472 + tc-export AR LD OBJCOPY
473 +
474 + # Verbose builds
475 + MAKEOPTS+=" V=1"
476 +
477 + epatch_user
478 +
479 + # Run after we've applied all patches.
480 + handle_locales
481 +}
482 +
483 +##
484 +# configures qemu based on the build directory and the build type
485 +# we are using.
486 +#
487 +qemu_src_configure() {
488 + debug-print-function ${FUNCNAME} "$@"
489 +
490 + local buildtype=$1
491 + local builddir="${S}/${buildtype}-build"
492 + local static_flag="static-${buildtype}"
493 +
494 + mkdir "${builddir}"
495 +
496 + local conf_opts=(
497 + --prefix=/usr
498 + --sysconfdir=/etc
499 + --libdir=/usr/$(get_libdir)
500 + --docdir=/usr/share/doc/${PF}/html
501 + --disable-bsd-user
502 + --disable-guest-agent
503 + --disable-strip
504 + --disable-werror
505 + # We support gnutls/nettle for crypto operations. It is possible
506 + # to use gcrypt when gnutls/nettle are disabled (but not when they
507 + # are enabled), but it's not really worth the hassle. Disable it
508 + # all the time to avoid automatically detecting it. #568856
509 + --disable-gcrypt
510 + --python="${PYTHON}"
511 + --cc="$(tc-getCC)"
512 + --cxx="$(tc-getCXX)"
513 + --host-cc="$(tc-getBUILD_CC)"
514 + $(use_enable debug debug-info)
515 + $(use_enable debug debug-tcg)
516 + --enable-docs
517 + $(use_enable tci tcg-interpreter)
518 + $(use_enable xattr attr)
519 + )
520 +
521 + # Disable options not used by user targets as the default configure
522 + # options will autoprobe and try to link in a bunch of unused junk.
523 + conf_softmmu() {
524 + if [[ ${buildtype} == "user" ]] ; then
525 + echo "--disable-${2:-$1}"
526 + else
527 + use_enable "$@"
528 + fi
529 + }
530 + conf_opts+=(
531 + $(conf_softmmu accessibility brlapi)
532 + $(conf_softmmu aio linux-aio)
533 + $(conf_softmmu bzip2)
534 + $(conf_softmmu bluetooth bluez)
535 + $(conf_softmmu caps cap-ng)
536 + $(conf_softmmu curl)
537 + $(conf_softmmu fdt)
538 + $(conf_softmmu glusterfs)
539 + $(conf_softmmu gnutls)
540 + $(conf_softmmu gnutls nettle)
541 + $(conf_softmmu gtk)
542 + $(conf_softmmu infiniband rdma)
543 + $(conf_softmmu iscsi libiscsi)
544 + $(conf_softmmu jpeg vnc-jpeg)
545 + $(conf_softmmu kernel_linux kvm)
546 + $(conf_softmmu lzo)
547 + $(conf_softmmu ncurses curses)
548 + $(conf_softmmu nfs libnfs)
549 + $(conf_softmmu numa)
550 + $(conf_softmmu opengl)
551 + $(conf_softmmu png vnc-png)
552 + $(conf_softmmu rbd)
553 + $(conf_softmmu sasl vnc-sasl)
554 + $(conf_softmmu sdl)
555 + $(conf_softmmu seccomp)
556 + $(conf_softmmu smartcard)
557 + $(conf_softmmu snappy)
558 + $(conf_softmmu spice)
559 + $(conf_softmmu ssh libssh2)
560 + $(conf_softmmu usb libusb)
561 + $(conf_softmmu usbredir usb-redir)
562 + $(conf_softmmu uuid)
563 + $(conf_softmmu vde)
564 + $(conf_softmmu vhost-net)
565 + $(conf_softmmu virgl virglrenderer)
566 + $(conf_softmmu virtfs)
567 + $(conf_softmmu vnc)
568 + $(conf_softmmu vte)
569 + $(conf_softmmu xen)
570 + $(conf_softmmu xen xen-pci-passthrough)
571 + $(conf_softmmu xfs xfsctl)
572 + )
573 +
574 + case ${buildtype} in
575 + user)
576 + conf_opts+=(
577 + --enable-linux-user
578 + --disable-system
579 + --disable-blobs
580 + --disable-tools
581 + )
582 + ;;
583 + softmmu)
584 + # audio options
585 + local audio_opts="oss"
586 + use alsa && audio_opts="alsa,${audio_opts}"
587 + use sdl && audio_opts="sdl,${audio_opts}"
588 + use pulseaudio && audio_opts="pa,${audio_opts}"
589 +
590 + conf_opts+=(
591 + --disable-linux-user
592 + --enable-system
593 + --with-system-pixman
594 + --audio-drv-list="${audio_opts}"
595 + )
596 + use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
597 + use sdl && conf_opts+=( --with-sdlabi=$(usex sdl2 2.0 1.2) )
598 + ;;
599 + tools)
600 + conf_opts+=(
601 + --disable-linux-user
602 + --disable-system
603 + --disable-blobs
604 + $(use_enable bzip2)
605 + )
606 + static_flag="static"
607 + ;;
608 + esac
609 +
610 + local targets="${buildtype}_targets"
611 + [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
612 +
613 + # Add support for SystemTAP
614 + use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
615 +
616 + # We always want to attempt to build with PIE support as it results
617 + # in a more secure binary. But it doesn't work with static or if
618 + # the current GCC doesn't have PIE support.
619 + if use ${static_flag}; then
620 + conf_opts+=( --static --disable-pie )
621 + else
622 + gcc-specs-pie && conf_opts+=( --enable-pie )
623 + fi
624 +
625 + echo "../configure ${conf_opts[*]}"
626 + cd "${builddir}"
627 + ../configure "${conf_opts[@]}" || die "configure failed"
628 +
629 + # FreeBSD's kernel does not support QEMU assigning/grabbing
630 + # host USB devices yet
631 + use kernel_FreeBSD && \
632 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
633 +}
634 +
635 +src_configure() {
636 + local target
637 +
638 + python_setup
639 +
640 + softmmu_targets= softmmu_bins=()
641 + user_targets= user_bins=()
642 +
643 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
644 + if use "qemu_softmmu_targets_${target}"; then
645 + softmmu_targets+=",${target}-softmmu"
646 + softmmu_bins+=( "qemu-system-${target}" )
647 + fi
648 + done
649 +
650 + for target in ${IUSE_USER_TARGETS} ; do
651 + if use "qemu_user_targets_${target}"; then
652 + user_targets+=",${target}-linux-user"
653 + user_bins+=( "qemu-${target}" )
654 + fi
655 + done
656 +
657 + softmmu_targets=${softmmu_targets#,}
658 + user_targets=${user_targets#,}
659 +
660 + [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
661 + [[ -n ${user_targets} ]] && qemu_src_configure "user"
662 + [[ -z ${softmmu_targets}${user_targets} ]] && qemu_src_configure "tools"
663 +}
664 +
665 +src_compile() {
666 + if [[ -n ${user_targets} ]]; then
667 + cd "${S}/user-build"
668 + default
669 + fi
670 +
671 + if [[ -n ${softmmu_targets} ]]; then
672 + cd "${S}/softmmu-build"
673 + default
674 + fi
675 +
676 + if [[ -z ${softmmu_targets}${user_targets} ]]; then
677 + cd "${S}/tools-build"
678 + default
679 + fi
680 +}
681 +
682 +src_test() {
683 + if [[ -n ${softmmu_targets} ]]; then
684 + cd "${S}/softmmu-build"
685 + pax-mark m */qemu-system-* #515550
686 + emake -j1 check
687 + emake -j1 check-report.html
688 + fi
689 +}
690 +
691 +qemu_python_install() {
692 + python_domodule "${S}/scripts/qmp/qmp.py"
693 +
694 + python_doscript "${S}/scripts/kvm/vmxcap"
695 + python_doscript "${S}/scripts/qmp/qmp-shell"
696 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
697 +}
698 +
699 +src_install() {
700 + if [[ -n ${user_targets} ]]; then
701 + cd "${S}/user-build"
702 + emake DESTDIR="${ED}" install
703 +
704 + # Install binfmt handler init script for user targets
705 + newinitd "${FILESDIR}/qemu-binfmt.initd-r1" qemu-binfmt
706 + fi
707 +
708 + if [[ -n ${softmmu_targets} ]]; then
709 + cd "${S}/softmmu-build"
710 + emake DESTDIR="${ED}" install
711 +
712 + # This might not exist if the test failed. #512010
713 + [[ -e check-report.html ]] && dohtml check-report.html
714 +
715 + if use kernel_linux; then
716 + udev_dorules "${FILESDIR}"/65-kvm.rules
717 + fi
718 +
719 + if use python; then
720 + python_foreach_impl qemu_python_install
721 + fi
722 + fi
723 +
724 + if [[ -z ${softmmu_targets}${user_targets} ]]; then
725 + cd "${S}/tools-build"
726 + emake DESTDIR="${ED}" install
727 + fi
728 +
729 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
730 + pushd "${ED}"/usr/bin >/dev/null
731 + pax-mark m "${softmmu_bins[@]}" "${user_bins[@]}"
732 + popd >/dev/null
733 +
734 + # Install config file example for qemu-bridge-helper
735 + insinto "/etc/qemu"
736 + doins "${FILESDIR}/bridge.conf"
737 +
738 + # Remove the docdir placed qmp-commands.txt
739 + mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/" || die
740 +
741 + cd "${S}"
742 + dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
743 + newdoc pc-bios/README README.pc-bios
744 + dodoc docs/qmp-*.txt
745 +
746 + if [[ -n ${softmmu_targets} ]]; then
747 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
748 + rm "${ED}/usr/share/qemu/bios.bin"
749 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
750 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
751 + fi
752 +
753 + # Remove vgabios since we're using the vgabios packaged one
754 + rm "${ED}/usr/share/qemu/vgabios.bin"
755 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
756 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
757 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
758 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
759 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
760 + dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
761 + dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
762 + dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
763 + dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
764 + dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
765 + fi
766 +
767 + # Remove sgabios since we're using the sgabios packaged one
768 + rm "${ED}/usr/share/qemu/sgabios.bin"
769 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
770 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
771 + fi
772 +
773 + # Remove iPXE since we're using the iPXE packaged one
774 + rm "${ED}"/usr/share/qemu/pxe-*.rom
775 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
776 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
777 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
778 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
779 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
780 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
781 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
782 + fi
783 + fi
784 +
785 + qemu_support_kvm && readme.gentoo_create_doc
786 +}
787 +
788 +pkg_postinst() {
789 + if qemu_support_kvm; then
790 + readme.gentoo_print_elog
791 + fi
792 +
793 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
794 + udev_reload
795 + fi
796 +
797 + fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
798 +}
799 +
800 +pkg_info() {
801 + echo "Using:"
802 + echo " $(best_version app-emulation/spice-protocol)"
803 + echo " $(best_version sys-firmware/ipxe)"
804 + echo " $(best_version sys-firmware/seabios)"
805 + if has_version 'sys-firmware/seabios[binary]'; then
806 + echo " USE=binary"
807 + else
808 + echo " USE=''"
809 + fi
810 + echo " $(best_version sys-firmware/vgabios)"
811 +}