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