Gentoo Archives: gentoo-commits

From: John Helmert III <ajak@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/qemu/
Date: Sat, 01 Jan 2022 09:42:52
Message-Id: 1641030105.67d882138d22d9d4396df7f3255e2d4a24ed0d4d.ajak@gentoo
1 commit: 67d882138d22d9d4396df7f3255e2d4a24ed0d4d
2 Author: John Helmert III <ajak <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jan 1 09:39:27 2022 +0000
4 Commit: John Helmert III <ajak <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 1 09:41:45 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=67d88213
7
8 app-emulation/qemu: update EAPI 7 -> 8, fix libselinux automagic
9
10 Signed-off-by: John Helmert III <ajak <AT> gentoo.org>
11
12 app-emulation/qemu/qemu-6.2.0-r2.ebuild | 927 ++++++++++++++++++++++++++++++++
13 1 file changed, 927 insertions(+)
14
15 diff --git a/app-emulation/qemu/qemu-6.2.0-r2.ebuild b/app-emulation/qemu/qemu-6.2.0-r2.ebuild
16 new file mode 100644
17 index 000000000000..9bad836fb39e
18 --- /dev/null
19 +++ b/app-emulation/qemu/qemu-6.2.0-r2.ebuild
20 @@ -0,0 +1,927 @@
21 +# Copyright 1999-2022 Gentoo Authors
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +EAPI=8
25 +
26 +PYTHON_COMPAT=( python3_{8,9,10} )
27 +PYTHON_REQ_USE="ncurses,readline"
28 +
29 +FIRMWARE_ABI_VERSION="6.2.0"
30 +
31 +inherit linux-info toolchain-funcs python-r1 udev fcaps readme.gentoo-r1 \
32 + pax-utils xdg-utils
33 +
34 +if [[ ${PV} = *9999* ]]; then
35 + EGIT_REPO_URI="https://git.qemu.org/git/qemu.git"
36 + EGIT_SUBMODULES=(
37 + meson
38 + tests/fp/berkeley-softfloat-3
39 + tests/fp/berkeley-testfloat-3
40 + ui/keycodemapdb
41 + )
42 + inherit git-r3
43 + SRC_URI=""
44 +else
45 + SRC_URI="https://download.qemu.org/${P}.tar.xz"
46 + KEYWORDS="~amd64 ~arm64 ~ppc ~ppc64 ~x86"
47 +fi
48 +
49 +DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
50 +HOMEPAGE="https://www.qemu.org https://www.linux-kvm.org"
51 +
52 +LICENSE="GPL-2 LGPL-2 BSD-2"
53 +SLOT="0"
54 +
55 +IUSE="accessibility +aio alsa bpf bzip2 capstone +caps +curl debug +doc
56 + +fdt fuse glusterfs gnutls gtk infiniband iscsi io-uring
57 + jack jemalloc +jpeg kernel_linux
58 + kernel_FreeBSD lzo multipath
59 + ncurses nfs nls numa opengl +oss pam +pin-upstream-blobs
60 + plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
61 + +slirp
62 + smartcard snappy spice ssh static static-user systemtap test udev usb
63 + usbredir vde +vhost-net vhost-user-fs virgl virtfs +vnc vte xattr xen
64 + xfs zstd"
65 +
66 +COMMON_TARGETS="
67 + aarch64
68 + alpha
69 + arm
70 + cris
71 + hppa
72 + i386
73 + m68k
74 + microblaze
75 + microblazeel
76 + mips
77 + mips64
78 + mips64el
79 + mipsel
80 + nios2
81 + or1k
82 + ppc
83 + ppc64
84 + riscv32
85 + riscv64
86 + s390x
87 + sh4
88 + sh4eb
89 + sparc
90 + sparc64
91 + x86_64
92 + xtensa
93 + xtensaeb
94 +"
95 +IUSE_SOFTMMU_TARGETS="
96 + ${COMMON_TARGETS}
97 + avr
98 + rx
99 + tricore
100 +"
101 +IUSE_USER_TARGETS="
102 + ${COMMON_TARGETS}
103 + aarch64_be
104 + armeb
105 + hexagon
106 + mipsn32
107 + mipsn32el
108 + ppc64abi32
109 + ppc64le
110 + sparc32plus
111 +"
112 +
113 +use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
114 +use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
115 +IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
116 +
117 +RESTRICT="!test? ( test )"
118 +# Allow no targets to be built so that people can get a tools-only build.
119 +# Block USE flag configurations known to not work.
120 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
121 + qemu_softmmu_targets_arm? ( fdt )
122 + qemu_softmmu_targets_microblaze? ( fdt )
123 + qemu_softmmu_targets_mips64el? ( fdt )
124 + qemu_softmmu_targets_ppc64? ( fdt )
125 + qemu_softmmu_targets_ppc? ( fdt )
126 + qemu_softmmu_targets_riscv32? ( fdt )
127 + qemu_softmmu_targets_riscv64? ( fdt )
128 + qemu_softmmu_targets_x86_64? ( fdt )
129 + sdl-image? ( sdl )
130 + static? ( static-user !alsa !gtk !jack !opengl !pulseaudio !plugins !rbd !snappy !udev )
131 + static-user? ( !plugins )
132 + vhost-user-fs? ( caps seccomp )
133 + virgl? ( opengl )
134 + virtfs? ( caps xattr )
135 + vte? ( gtk )
136 + multipath? ( udev )
137 + plugins? ( !static !static-user )
138 +"
139 +
140 +# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
141 +# and user/softmmu targets (qemu-*, qemu-system-*).
142 +#
143 +# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
144 +#
145 +# The attr lib isn't always linked in (although the USE flag is always
146 +# respected). This is because qemu supports using the C library's API
147 +# when available rather than always using the external library.
148 +ALL_DEPEND="
149 + >=dev-libs/glib-2.0[static-libs(+)]
150 + sys-libs/zlib[static-libs(+)]
151 + python? ( ${PYTHON_DEPS} )
152 + systemtap? ( dev-util/systemtap )
153 + xattr? ( sys-apps/attr[static-libs(+)] )"
154 +
155 +# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
156 +# softmmu targets (qemu-system-*).
157 +SOFTMMU_TOOLS_DEPEND="
158 + dev-libs/libxml2[static-libs(+)]
159 + >=x11-libs/pixman-0.28.0[static-libs(+)]
160 + accessibility? (
161 + app-accessibility/brltty[api]
162 + app-accessibility/brltty[static-libs(+)]
163 + )
164 + aio? ( dev-libs/libaio[static-libs(+)] )
165 + alsa? ( >=media-libs/alsa-lib-1.0.13 )
166 + bpf? ( dev-libs/libbpf:= )
167 + bzip2? ( app-arch/bzip2[static-libs(+)] )
168 + capstone? ( dev-libs/capstone:= )
169 + caps? ( sys-libs/libcap-ng[static-libs(+)] )
170 + curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
171 + fdt? ( >=sys-apps/dtc-1.5.0[static-libs(+)] )
172 + fuse? ( >=sys-fs/fuse-3.1:3[static-libs(+)] )
173 + glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
174 + gnutls? (
175 + dev-libs/nettle:=[static-libs(+)]
176 + >=net-libs/gnutls-3.0:=[static-libs(+)]
177 + )
178 + gtk? (
179 + x11-libs/gtk+:3
180 + vte? ( x11-libs/vte:2.91 )
181 + )
182 + infiniband? ( sys-cluster/rdma-core[static-libs(+)] )
183 + iscsi? ( net-libs/libiscsi )
184 + io-uring? ( sys-libs/liburing:=[static-libs(+)] )
185 + jack? ( virtual/jack )
186 + jemalloc? ( dev-libs/jemalloc )
187 + jpeg? ( virtual/jpeg:0=[static-libs(+)] )
188 + lzo? ( dev-libs/lzo:2[static-libs(+)] )
189 + multipath? ( sys-fs/multipath-tools )
190 + ncurses? (
191 + sys-libs/ncurses:=[unicode(+)]
192 + sys-libs/ncurses:=[static-libs(+)]
193 + )
194 + nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
195 + numa? ( sys-process/numactl[static-libs(+)] )
196 + opengl? (
197 + virtual/opengl
198 + media-libs/libepoxy[static-libs(+)]
199 + media-libs/mesa[static-libs(+)]
200 + media-libs/mesa[egl(+),gbm(+)]
201 + )
202 + pam? ( sys-libs/pam )
203 + png? ( media-libs/libpng:0=[static-libs(+)] )
204 + pulseaudio? ( media-sound/pulseaudio )
205 + rbd? ( sys-cluster/ceph )
206 + sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
207 + sdl? (
208 + media-libs/libsdl2[video]
209 + media-libs/libsdl2[static-libs(+)]
210 + )
211 + sdl-image? ( media-libs/sdl2-image[static-libs(+)] )
212 + seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
213 + slirp? ( net-libs/libslirp[static-libs(+)] )
214 + smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
215 + snappy? ( app-arch/snappy:= )
216 + spice? (
217 + >=app-emulation/spice-protocol-0.12.3
218 + >=app-emulation/spice-0.12.0[static-libs(+)]
219 + )
220 + ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
221 + udev? ( virtual/libudev:= )
222 + usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
223 + usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
224 + vde? ( net-misc/vde[static-libs(+)] )
225 + virgl? ( media-libs/virglrenderer[static-libs(+)] )
226 + virtfs? ( sys-libs/libcap )
227 + xen? ( app-emulation/xen-tools:= )
228 + xfs? ( sys-fs/xfsprogs[static-libs(+)] )
229 + zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
230 +"
231 +
232 +EDK2_OVMF_VERSION="202105"
233 +SEABIOS_VERSION="1.14.0"
234 +
235 +X86_FIRMWARE_DEPEND="
236 + pin-upstream-blobs? (
237 + ~sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}[binary]
238 + ~sys-firmware/ipxe-1.21.1[binary,qemu]
239 + ~sys-firmware/seabios-${SEABIOS_VERSION}[binary,seavgabios]
240 + ~sys-firmware/sgabios-0.1_pre10[binary]
241 + )
242 + !pin-upstream-blobs? (
243 + >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
244 + sys-firmware/ipxe[qemu]
245 + >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
246 + sys-firmware/sgabios
247 + )"
248 +PPC_FIRMWARE_DEPEND="
249 + pin-upstream-blobs? (
250 + ~sys-firmware/seabios-${SEABIOS_VERSION}[binary,seavgabios]
251 + )
252 + !pin-upstream-blobs? (
253 + >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
254 + )
255 +"
256 +
257 +BDEPEND="
258 + $(python_gen_impl_dep)
259 + dev-lang/perl
260 + sys-apps/texinfo
261 + virtual/pkgconfig
262 + doc? (
263 + dev-python/sphinx[${PYTHON_USEDEP}]
264 + dev-python/sphinx_rtd_theme[${PYTHON_USEDEP}]
265 + )
266 + gtk? ( nls? ( sys-devel/gettext ) )
267 + test? (
268 + dev-libs/glib[utils]
269 + sys-devel/bc
270 + )
271 +"
272 +CDEPEND="
273 + !static? (
274 + ${ALL_DEPEND//\[static-libs(+)]}
275 + ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
276 + )
277 + qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
278 + qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
279 + qemu_softmmu_targets_ppc? ( ${PPC_FIRMWARE_DEPEND} )
280 + qemu_softmmu_targets_ppc64? ( ${PPC_FIRMWARE_DEPEND} )
281 +"
282 +DEPEND="${CDEPEND}
283 + kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
284 + static? (
285 + ${ALL_DEPEND}
286 + ${SOFTMMU_TOOLS_DEPEND}
287 + )
288 + static-user? ( ${ALL_DEPEND} )"
289 +RDEPEND="${CDEPEND}
290 + acct-group/kvm
291 + selinux? (
292 + sec-policy/selinux-qemu
293 + sys-libs/libselinux
294 + )"
295 +
296 +PATCHES=(
297 + "${FILESDIR}"/${PN}-2.11.1-capstone_include_path.patch
298 + "${FILESDIR}"/${PN}-5.2.0-disable-keymap.patch
299 + "${FILESDIR}"/${PN}-6.0.0-make.patch
300 + "${FILESDIR}"/${PN}-6.1.0-strings.patch
301 + "${FILESDIR}"/${PN}-6.2.0-user-SLIC-crash.patch
302 +)
303 +
304 +QA_PREBUILT="
305 + usr/share/qemu/hppa-firmware.img
306 + usr/share/qemu/openbios-ppc
307 + usr/share/qemu/openbios-sparc64
308 + usr/share/qemu/openbios-sparc32
309 + usr/share/qemu/opensbi-riscv64-generic-fw_dynamic.elf
310 + usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.elf
311 + usr/share/qemu/palcode-clipper
312 + usr/share/qemu/s390-ccw.img
313 + usr/share/qemu/s390-netboot.img
314 + usr/share/qemu/u-boot.e500
315 +"
316 +
317 +QA_WX_LOAD="usr/bin/qemu-i386
318 + usr/bin/qemu-x86_64
319 + usr/bin/qemu-alpha
320 + usr/bin/qemu-arm
321 + usr/bin/qemu-cris
322 + usr/bin/qemu-m68k
323 + usr/bin/qemu-microblaze
324 + usr/bin/qemu-microblazeel
325 + usr/bin/qemu-mips
326 + usr/bin/qemu-mipsel
327 + usr/bin/qemu-or1k
328 + usr/bin/qemu-ppc
329 + usr/bin/qemu-ppc64
330 + usr/bin/qemu-ppc64abi32
331 + usr/bin/qemu-sh4
332 + usr/bin/qemu-sh4eb
333 + usr/bin/qemu-sparc
334 + usr/bin/qemu-sparc64
335 + usr/bin/qemu-armeb
336 + usr/bin/qemu-sparc32plus
337 + usr/bin/qemu-s390x
338 + usr/bin/qemu-unicore32
339 +"
340 +
341 +DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
342 +kernel module loaded before running kvm. The easiest way to ensure that the
343 +kernel module is loaded is to load it on boot.
344 + For AMD CPUs the module is called 'kvm-amd'.
345 + For Intel CPUs the module is called 'kvm-intel'.
346 +Please review /etc/conf.d/modules for how to load these.
347 +
348 +Make sure your user is in the 'kvm' group. Just run
349 + $ gpasswd -a <USER> kvm
350 +then have <USER> re-login.
351 +
352 +For brand new installs, the default permissions on /dev/kvm might not let
353 +you access it. You can tell udev to reset ownership/perms:
354 + $ udevadm trigger -c add /dev/kvm
355 +
356 +If you want to register binfmt handlers for qemu user targets:
357 +For openrc:
358 + # rc-update add qemu-binfmt
359 +For systemd:
360 + # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
361 +
362 +pkg_pretend() {
363 + if use kernel_linux && kernel_is lt 2 6 25; then
364 + eerror "This version of KVM requires a host kernel of 2.6.25 or higher."
365 + elif use kernel_linux; then
366 + if ! linux_config_exists; then
367 + eerror "Unable to check your kernel for KVM support"
368 + else
369 + CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
370 + ERROR_KVM="You must enable KVM in your kernel to continue"
371 + ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
372 + ERROR_KVM_AMD+=" your kernel configuration."
373 + ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
374 + ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
375 + ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
376 + ERROR_TUN+=" into your kernel or loaded as a module to use the"
377 + ERROR_TUN+=" virtual network device if using -net tap."
378 + ERROR_BRIDGE="You will also need support for 802.1d"
379 + ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
380 + use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
381 + ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
382 + ERROR_VHOST_NET+=" support"
383 +
384 + if use amd64 || use x86 || use amd64-linux || use x86-linux; then
385 + if grep -q AuthenticAMD /proc/cpuinfo; then
386 + CONFIG_CHECK+=" ~KVM_AMD"
387 + elif grep -q GenuineIntel /proc/cpuinfo; then
388 + CONFIG_CHECK+=" ~KVM_INTEL"
389 + fi
390 + fi
391 +
392 + use python && CONFIG_CHECK+=" ~DEBUG_FS"
393 + ERROR_DEBUG_FS="debugFS support required for kvm_stat"
394 +
395 + # Now do the actual checks setup above
396 + check_extra_config
397 + fi
398 + fi
399 +
400 + if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
401 + eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
402 + eerror "instances are still pointing to it. Please update your"
403 + eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
404 + eerror "and the right system binary (e.g. qemu-system-x86_64)."
405 + die "update your virt configs to not use qemu-kvm"
406 + fi
407 +}
408 +
409 +# Sanity check to make sure target lists are kept up-to-date.
410 +check_targets() {
411 + local var=$1 mak=$2
412 + local detected sorted
413 +
414 + pushd "${S}"/configs/targets/ >/dev/null || die
415 +
416 + # Force C locale until glibc is updated. #564936
417 + detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
418 + sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
419 + if [[ ${sorted} != "${detected}" ]] ; then
420 + eerror "The ebuild needs to be kept in sync."
421 + eerror "${var}: ${sorted}"
422 + eerror "$(printf '%-*s' ${#var} configure): ${detected}"
423 + die "sync ${var} to the list of targets"
424 + fi
425 +
426 + popd >/dev/null
427 +}
428 +
429 +src_prepare() {
430 + check_targets IUSE_SOFTMMU_TARGETS softmmu
431 + check_targets IUSE_USER_TARGETS linux-user
432 +
433 + default
434 +
435 + # Use correct toolchain to fix cross-compiling
436 + tc-export AR AS LD NM OBJCOPY PKG_CONFIG RANLIB STRINGS
437 + export WINDRES=${CHOST}-windres
438 +
439 + # Verbose builds
440 + MAKEOPTS+=" V=1"
441 +
442 + # Remove bundled copy of libfdt
443 + rm -r dtc || die
444 +}
445 +
446 +##
447 +# configures qemu based on the build directory and the build type
448 +# we are using.
449 +#
450 +qemu_src_configure() {
451 + debug-print-function ${FUNCNAME} "$@"
452 +
453 + local buildtype=$1
454 + local builddir="${S}/${buildtype}-build"
455 +
456 + mkdir "${builddir}"
457 +
458 + local conf_opts=(
459 + --prefix=/usr
460 + --sysconfdir=/etc
461 + --bindir=/usr/bin
462 + --libdir=/usr/$(get_libdir)
463 + --datadir=/usr/share
464 + --docdir=/usr/share/doc/${PF}/html
465 + --mandir=/usr/share/man
466 + --localstatedir=/var
467 + --disable-bsd-user
468 + --disable-containers # bug #732972
469 + --disable-guest-agent
470 + --disable-strip
471 + --with-git-submodules=ignore
472 +
473 + # bug #746752: TCG interpreter has a few limitations:
474 + # - it does not support FPU
475 + # - it's generally slower on non-self-modifying code
476 + # It's advantage is support for host architectures
477 + # where native codegeneration is not implemented.
478 + # Gentoo has qemu keyworded only on targets with
479 + # native code generation available. Avoid the interpreter.
480 + --disable-tcg-interpreter
481 +
482 + --disable-werror
483 + # We support gnutls/nettle for crypto operations. It is possible
484 + # to use gcrypt when gnutls/nettle are disabled (but not when they
485 + # are enabled), but it's not really worth the hassle. Disable it
486 + # all the time to avoid automatically detecting it. #568856
487 + --disable-gcrypt
488 + --python="${PYTHON}"
489 + --cc="$(tc-getCC)"
490 + --cxx="$(tc-getCXX)"
491 + --host-cc="$(tc-getBUILD_CC)"
492 + $(use_enable alsa)
493 + $(use_enable debug debug-info)
494 + $(use_enable debug debug-tcg)
495 + $(use_enable doc docs)
496 + $(use_enable jack)
497 + $(use_enable nls gettext)
498 + $(use_enable oss)
499 + $(use_enable pam auth-pam)
500 + $(use_enable plugins)
501 + $(use_enable pulseaudio pa)
502 + $(use_enable selinux)
503 + $(use_enable xattr attr)
504 + )
505 +
506 + # Disable options not used by user targets. This simplifies building
507 + # static user targets (USE=static-user) considerably.
508 + conf_notuser() {
509 + if [[ ${buildtype} == "user" ]] ; then
510 + echo "--disable-${2:-$1}"
511 + else
512 + use_enable "$@"
513 + fi
514 + }
515 + # Enable option only for softmmu build, but not 'user' or 'tools'
516 + conf_softmmu() {
517 + if [[ ${buildtype} == "softmmu" ]] ; then
518 + use_enable "$@"
519 + else
520 + echo "--disable-${2:-$1}"
521 + fi
522 + }
523 + # Enable option only for tools build, but not 'user' or 'softmmu'
524 + conf_tools() {
525 + if [[ ${buildtype} == "tools" ]] ; then
526 + use_enable "$@"
527 + else
528 + echo "--disable-${2:-$1}"
529 + fi
530 + }
531 + # Special case for the malloc flag, because the --disable flag does
532 + # not exist and trying like above will break configuring.
533 + conf_malloc() {
534 + if [[ ! ${buildtype} == "user" ]] ; then
535 + usex "${1}" "--enable-malloc=${1}" ""
536 + fi
537 + }
538 + conf_opts+=(
539 + $(conf_notuser accessibility brlapi)
540 + $(conf_notuser aio linux-aio)
541 + $(conf_softmmu bpf)
542 + $(conf_notuser bzip2)
543 + $(conf_notuser capstone)
544 + $(conf_notuser caps cap-ng)
545 + $(conf_notuser curl)
546 + $(conf_notuser fdt)
547 + $(conf_notuser fuse)
548 + $(conf_notuser glusterfs)
549 + $(conf_notuser gnutls)
550 + $(conf_notuser gnutls nettle)
551 + $(conf_notuser gtk)
552 + $(conf_notuser infiniband rdma)
553 + $(conf_notuser iscsi libiscsi)
554 + $(conf_notuser io-uring linux-io-uring)
555 + $(conf_malloc jemalloc)
556 + $(conf_notuser jpeg vnc-jpeg)
557 + $(conf_notuser kernel_linux kvm)
558 + $(conf_notuser lzo)
559 + $(conf_notuser multipath mpath)
560 + $(conf_notuser ncurses curses)
561 + $(conf_notuser nfs libnfs)
562 + $(conf_notuser numa)
563 + $(conf_notuser opengl)
564 + $(conf_notuser png vnc-png)
565 + $(conf_notuser rbd)
566 + $(conf_notuser sasl vnc-sasl)
567 + $(conf_notuser sdl)
568 + $(conf_softmmu sdl-image)
569 + $(conf_notuser seccomp)
570 + $(conf_notuser slirp slirp system)
571 + $(conf_notuser smartcard)
572 + $(conf_notuser snappy)
573 + $(conf_notuser spice)
574 + $(conf_notuser ssh libssh)
575 + $(conf_notuser udev libudev)
576 + $(conf_notuser usb libusb)
577 + $(conf_notuser usbredir usb-redir)
578 + $(conf_notuser vde)
579 + $(conf_notuser vhost-net)
580 + $(conf_notuser vhost-user-fs)
581 + $(conf_tools vhost-user-fs virtiofsd)
582 + $(conf_notuser virgl virglrenderer)
583 + $(conf_softmmu virtfs)
584 + $(conf_notuser vnc)
585 + $(conf_notuser vte)
586 + $(conf_notuser xen)
587 + $(conf_notuser xen xen-pci-passthrough)
588 + $(conf_notuser xfs xfsctl)
589 + # use prebuilt keymaps, bug #759604
590 + --disable-xkbcommon
591 + $(conf_notuser zstd)
592 + )
593 +
594 + if [[ ${buildtype} == "user" ]] ; then
595 + conf_opts+=( --disable-libxml2 )
596 + else
597 + conf_opts+=( --enable-libxml2 )
598 + fi
599 +
600 + if [[ ! ${buildtype} == "user" ]] ; then
601 + # audio options
602 + local audio_opts=(
603 + # Note: backend order matters here: #716202
604 + # We iterate from higher-level to lower level.
605 + $(usex pulseaudio pa "")
606 + $(usev jack)
607 + $(usev sdl)
608 + $(usev alsa)
609 + $(usev oss)
610 + )
611 + conf_opts+=(
612 + --audio-drv-list=$(IFS=,; echo "${audio_opts[*]}")
613 + )
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 + # Meson will not use a cross-file unless cross_prefix is set.
661 + tc-is-cross-compiler && conf_opts+=( --cross-prefix="${CHOST}-" )
662 +
663 + # Plumb through equivalent of EXTRA_ECONF to allow experiments
664 + # like bug #747928.
665 + conf_opts+=( ${EXTRA_CONF_QEMU} )
666 +
667 + echo "../configure ${conf_opts[*]}"
668 + cd "${builddir}"
669 + ../configure "${conf_opts[@]}" || die "configure failed"
670 +
671 + # FreeBSD's kernel does not support QEMU assigning/grabbing
672 + # host USB devices yet
673 + use kernel_FreeBSD && \
674 + sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
675 +}
676 +
677 +src_configure() {
678 + local target
679 +
680 + python_setup
681 +
682 + softmmu_targets= softmmu_bins=()
683 + user_targets= user_bins=()
684 +
685 + for target in ${IUSE_SOFTMMU_TARGETS} ; do
686 + if use "qemu_softmmu_targets_${target}"; then
687 + softmmu_targets+=",${target}-softmmu"
688 + softmmu_bins+=( "qemu-system-${target}" )
689 + fi
690 + done
691 +
692 + for target in ${IUSE_USER_TARGETS} ; do
693 + if use "qemu_user_targets_${target}"; then
694 + user_targets+=",${target}-linux-user"
695 + user_bins+=( "qemu-${target}" )
696 + fi
697 + done
698 +
699 + softmmu_targets=${softmmu_targets#,}
700 + user_targets=${user_targets#,}
701 +
702 + [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
703 + [[ -n ${user_targets} ]] && qemu_src_configure "user"
704 + qemu_src_configure "tools"
705 +}
706 +
707 +src_compile() {
708 + if [[ -n ${user_targets} ]]; then
709 + cd "${S}/user-build"
710 + default
711 + fi
712 +
713 + if [[ -n ${softmmu_targets} ]]; then
714 + cd "${S}/softmmu-build"
715 + default
716 + fi
717 +
718 + cd "${S}/tools-build"
719 + default
720 +}
721 +
722 +src_test() {
723 + if [[ -n ${softmmu_targets} ]]; then
724 + cd "${S}/softmmu-build"
725 + pax-mark m */qemu-system-* #515550
726 + emake check
727 + fi
728 +}
729 +
730 +qemu_python_install() {
731 + python_domodule "${S}/python/qemu"
732 +
733 + python_doscript "${S}/scripts/kvm/vmxcap"
734 + python_doscript "${S}/scripts/qmp/qmp-shell"
735 + python_doscript "${S}/scripts/qmp/qemu-ga-client"
736 +}
737 +
738 +# Generate binfmt support files.
739 +# - /etc/init.d/qemu-binfmt script which registers the user handlers (openrc)
740 +# - /usr/share/qemu/binfmt.d/qemu.conf (for use with systemd-binfmt)
741 +generate_initd() {
742 + local out="${T}/qemu-binfmt"
743 + local out_systemd="${T}/qemu.conf"
744 + local d="${T}/binfmt.d"
745 +
746 + einfo "Generating qemu binfmt scripts and configuration files"
747 +
748 + # Generate the debian fragments first.
749 + mkdir -p "${d}"
750 + "${S}"/scripts/qemu-binfmt-conf.sh \
751 + --debian \
752 + --exportdir "${d}" \
753 + --qemu-path "${EPREFIX}/usr/bin" \
754 + || die
755 + # Then turn the fragments into a shell script we can source.
756 + sed -E -i \
757 + -e 's:^([^ ]+) (.*)$:\1="\2":' \
758 + "${d}"/* || die
759 +
760 + # Generate the init.d script by assembling the fragments from above.
761 + local f qcpu package interpreter magic mask
762 + cat "${FILESDIR}"/qemu-binfmt.initd.head >"${out}" || die
763 + for f in "${d}"/qemu-* ; do
764 + source "${f}"
765 +
766 + # Normalize the cpu logic like we do in the init.d for the native cpu.
767 + qcpu=${package#qemu-}
768 + case ${qcpu} in
769 + arm*) qcpu="arm";;
770 + mips*) qcpu="mips";;
771 + ppc*) qcpu="ppc";;
772 + s390*) qcpu="s390";;
773 + sh*) qcpu="sh";;
774 + sparc*) qcpu="sparc";;
775 + esac
776 +
777 + # we use 'printf' here to be portable across 'sh'
778 + # implementations: #679168
779 + cat <<EOF >>"${out}"
780 + if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
781 + printf '%s\n' ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
782 + fi
783 +EOF
784 +
785 + echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >>"${out_systemd}"
786 +
787 + done
788 + cat "${FILESDIR}"/qemu-binfmt.initd.tail >>"${out}" || die
789 +}
790 +
791 +src_install() {
792 + if [[ -n ${user_targets} ]]; then
793 + cd "${S}/user-build"
794 + emake DESTDIR="${ED}" install
795 +
796 + # Install binfmt handler init script for user targets.
797 + generate_initd
798 + doinitd "${T}/qemu-binfmt"
799 +
800 + # Install binfmt/qemu.conf.
801 + insinto "/usr/share/qemu/binfmt.d"
802 + doins "${T}/qemu.conf"
803 + fi
804 +
805 + if [[ -n ${softmmu_targets} ]]; then
806 + cd "${S}/softmmu-build"
807 + emake DESTDIR="${ED}" install
808 +
809 + # This might not exist if the test failed. #512010
810 + [[ -e check-report.html ]] && dodoc check-report.html
811 +
812 + if use kernel_linux; then
813 + udev_newrules "${FILESDIR}"/65-kvm.rules-r2 65-kvm.rules
814 + fi
815 +
816 + if use python; then
817 + python_foreach_impl qemu_python_install
818 + fi
819 + fi
820 +
821 + cd "${S}/tools-build"
822 + emake DESTDIR="${ED}" install
823 +
824 + # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
825 + pushd "${ED}"/usr/bin >/dev/null
826 + pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
827 + popd >/dev/null
828 +
829 + # Install config file example for qemu-bridge-helper
830 + insinto "/etc/qemu"
831 + doins "${FILESDIR}/bridge.conf"
832 +
833 + cd "${S}"
834 + dodoc MAINTAINERS docs/specs/pci-ids.txt
835 + newdoc pc-bios/README README.pc-bios
836 +
837 + # Disallow stripping of prebuilt firmware files.
838 + dostrip -x ${QA_PREBUILT}
839 +
840 + if [[ -n ${softmmu_targets} ]]; then
841 + # Remove SeaBIOS since we're using the SeaBIOS packaged one
842 + rm "${ED}/usr/share/qemu/bios.bin"
843 + rm "${ED}/usr/share/qemu/bios-256k.bin"
844 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
845 + dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
846 + dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
847 + fi
848 +
849 + # Remove vgabios since we're using the seavgabios packaged one
850 + rm "${ED}/usr/share/qemu/vgabios.bin"
851 + rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
852 + rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
853 + rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
854 + rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
855 + rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
856 + # PPC/PPC64 loads vgabios-stdvga
857 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64; then
858 + dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
859 + dosym ../seavgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
860 + dosym ../seavgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
861 + dosym ../seavgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
862 + dosym ../seavgabios/vgabios-virtio.bin /usr/share/qemu/vgabios-virtio.bin
863 + dosym ../seavgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
864 + fi
865 +
866 + # Remove sgabios since we're using the sgabios packaged one
867 + rm "${ED}/usr/share/qemu/sgabios.bin"
868 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
869 + dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
870 + fi
871 +
872 + # Remove iPXE since we're using the iPXE packaged one
873 + rm "${ED}"/usr/share/qemu/pxe-*.rom
874 + if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
875 + dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
876 + dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
877 + dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
878 + dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
879 + dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
880 + dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
881 + fi
882 + fi
883 +
884 + DISABLE_AUTOFORMATTING=true
885 + readme.gentoo_create_doc
886 +}
887 +
888 +firmware_abi_change() {
889 + local pv
890 + for pv in ${REPLACING_VERSIONS}; do
891 + if ver_test ${pv} -lt ${FIRMWARE_ABI_VERSION}; then
892 + return 0
893 + fi
894 + done
895 + return 1
896 +}
897 +
898 +pkg_postinst() {
899 + if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
900 + udev_reload
901 + fi
902 +
903 + xdg_icon_cache_update
904 +
905 + [[ -z ${EPREFIX} ]] && [[ -f ${EROOT}/usr/libexec/qemu-bridge-helper ]] && \
906 + fcaps cap_net_admin ${EROOT}/usr/libexec/qemu-bridge-helper
907 +
908 + DISABLE_AUTOFORMATTING=true
909 + readme.gentoo_print_elog
910 +
911 + if use pin-upstream-blobs && firmware_abi_change; then
912 + ewarn "This version of qemu pins new versions of firmware blobs:"
913 + ewarn " $(best_version sys-firmware/edk2-ovmf)"
914 + ewarn " $(best_version sys-firmware/ipxe)"
915 + ewarn " $(best_version sys-firmware/seabios)"
916 + ewarn " $(best_version sys-firmware/sgabios)"
917 + ewarn "This might break resume of hibernated guests (started with a different"
918 + ewarn "firmware version) and live migration to/from qemu versions with different"
919 + ewarn "firmware. Please (cold) restart all running guests. For functional"
920 + ewarn "guest migration ensure that all"
921 + ewarn "hosts run at least"
922 + ewarn " app-emulation/qemu-${FIRMWARE_ABI_VERSION}."
923 + fi
924 +}
925 +
926 +pkg_info() {
927 + echo "Using:"
928 + echo " $(best_version app-emulation/spice-protocol)"
929 + echo " $(best_version sys-firmware/edk2-ovmf)"
930 + if has_version 'sys-firmware/edk2-ovmf[binary]'; then
931 + echo " USE=binary"
932 + else
933 + echo " USE=''"
934 + fi
935 + echo " $(best_version sys-firmware/ipxe)"
936 + echo " $(best_version sys-firmware/seabios)"
937 + if has_version 'sys-firmware/seabios[binary]'; then
938 + echo " USE=binary"
939 + else
940 + echo " USE=''"
941 + fi
942 + echo " $(best_version sys-firmware/sgabios)"
943 +}
944 +
945 +pkg_postrm() {
946 + xdg_icon_cache_update
947 +}