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