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