1 |
commit: 75d0202d68b81bc06d451b574670d8374751789f |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Dec 15 05:43:01 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Dec 15 05:55:01 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=75d0202d |
7 |
|
8 |
app-emulation/qemu: add upstream fixes for #567828 #568214 |
9 |
|
10 |
.../qemu/files/qemu-2.4.1-CVE-2015-7549.patch | 62 ++ |
11 |
.../qemu/files/qemu-2.4.1-CVE-2015-8504.patch | 46 ++ |
12 |
app-emulation/qemu/qemu-2.4.1-r2.ebuild | 642 +++++++++++++++++++++ |
13 |
3 files changed, 750 insertions(+) |
14 |
|
15 |
diff --git a/app-emulation/qemu/files/qemu-2.4.1-CVE-2015-7549.patch b/app-emulation/qemu/files/qemu-2.4.1-CVE-2015-7549.patch |
16 |
new file mode 100644 |
17 |
index 0000000..897fe34 |
18 |
--- /dev/null |
19 |
+++ b/app-emulation/qemu/files/qemu-2.4.1-CVE-2015-7549.patch |
20 |
@@ -0,0 +1,62 @@ |
21 |
+https://bugs.gentoo.org/568214 |
22 |
+ |
23 |
+From 43b11a91dd861a946b231b89b7542856ade23d1b Mon Sep 17 00:00:00 2001 |
24 |
+From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@××××××.com> |
25 |
+Date: Fri, 26 Jun 2015 14:25:29 +0200 |
26 |
+Subject: [PATCH] msix: implement pba write (but read-only) |
27 |
+MIME-Version: 1.0 |
28 |
+Content-Type: text/plain; charset=UTF-8 |
29 |
+Content-Transfer-Encoding: 8bit |
30 |
+ |
31 |
+qpci_msix_pending() writes on pba region, causing qemu to SEGV: |
32 |
+ |
33 |
+ Program received signal SIGSEGV, Segmentation fault. |
34 |
+ [Switching to Thread 0x7ffff7fba8c0 (LWP 25882)] |
35 |
+ 0x0000000000000000 in ?? () |
36 |
+ (gdb) bt |
37 |
+ #0 0x0000000000000000 in () |
38 |
+ #1 0x00005555556556c5 in memory_region_oldmmio_write_accessor (mr=0x5555579f3f80, addr=0, value=0x7fffffffbf68, size=4, shift=0, mask=4294967295, attrs=...) at /home/elmarco/src/qemu/memory.c:434 |
39 |
+ #2 0x00005555556558e1 in access_with_adjusted_size (addr=0, value=0x7fffffffbf68, size=4, access_size_min=1, access_size_max=4, access=0x55555565563e <memory_region_oldmmio_write_accessor>, mr=0x5555579f3f80, attrs=...) at /home/elmarco/src/qemu/memory.c:506 |
40 |
+ #3 0x00005555556581eb in memory_region_dispatch_write (mr=0x5555579f3f80, addr=0, data=0, size=4, attrs=...) at /home/elmarco/src/qemu/memory.c:1176 |
41 |
+ #4 0x000055555560b6f9 in address_space_rw (as=0x555555eff4e0 <address_space_memory>, addr=3759147008, attrs=..., buf=0x7fffffffc1b0 "", len=4, is_write=true) at /home/elmarco/src/qemu/exec.c:2439 |
42 |
+ #5 0x000055555560baa2 in cpu_physical_memory_rw (addr=3759147008, buf=0x7fffffffc1b0 "", len=4, is_write=1) at /home/elmarco/src/qemu/exec.c:2534 |
43 |
+ #6 0x000055555564c005 in cpu_physical_memory_write (addr=3759147008, buf=0x7fffffffc1b0, len=4) at /home/elmarco/src/qemu/include/exec/cpu-common.h:80 |
44 |
+ #7 0x000055555564cd9c in qtest_process_command (chr=0x55555642b890, words=0x5555578de4b0) at /home/elmarco/src/qemu/qtest.c:378 |
45 |
+ #8 0x000055555564db77 in qtest_process_inbuf (chr=0x55555642b890, inbuf=0x55555641b340) at /home/elmarco/src/qemu/qtest.c:569 |
46 |
+ #9 0x000055555564dc07 in qtest_read (opaque=0x55555642b890, buf=0x7fffffffc2e0 "writel 0xe0100800 0x0\n", size=22) at /home/elmarco/src/qemu/qtest.c:581 |
47 |
+ #10 0x000055555574ce3e in qemu_chr_be_write (s=0x55555642b890, buf=0x7fffffffc2e0 "writel 0xe0100800 0x0\n", len=22) at qemu-char.c:306 |
48 |
+ #11 0x0000555555751263 in tcp_chr_read (chan=0x55555642bcf0, cond=G_IO_IN, opaque=0x55555642b890) at qemu-char.c:2876 |
49 |
+ #12 0x00007ffff64c9a8a in g_main_context_dispatch (context=0x55555641c400) at gmain.c:3122 |
50 |
+ |
51 |
+(without this patch, this can be reproduced with the ivshmem qtest) |
52 |
+ |
53 |
+Implement an empty mmio write to avoid the crash. |
54 |
+ |
55 |
+Signed-off-by: Marc-André Lureau <marcandre.lureau@××××××.com> |
56 |
+Reviewed-by: Paolo Bonzini <pbonzini@××××××.com> |
57 |
+--- |
58 |
+ hw/pci/msix.c | 6 ++++++ |
59 |
+ 1 file changed, 6 insertions(+) |
60 |
+ |
61 |
+diff --git a/hw/pci/msix.c b/hw/pci/msix.c |
62 |
+index 2fdada4..64c93d8 100644 |
63 |
+--- a/hw/pci/msix.c |
64 |
++++ b/hw/pci/msix.c |
65 |
+@@ -200,8 +200,14 @@ static uint64_t msix_pba_mmio_read(void *opaque, hwaddr addr, |
66 |
+ return pci_get_long(dev->msix_pba + addr); |
67 |
+ } |
68 |
+ |
69 |
++static void msix_pba_mmio_write(void *opaque, hwaddr addr, |
70 |
++ uint64_t val, unsigned size) |
71 |
++{ |
72 |
++} |
73 |
++ |
74 |
+ static const MemoryRegionOps msix_pba_mmio_ops = { |
75 |
+ .read = msix_pba_mmio_read, |
76 |
++ .write = msix_pba_mmio_write, |
77 |
+ .endianness = DEVICE_LITTLE_ENDIAN, |
78 |
+ .valid = { |
79 |
+ .min_access_size = 4, |
80 |
+-- |
81 |
+2.6.2 |
82 |
+ |
83 |
|
84 |
diff --git a/app-emulation/qemu/files/qemu-2.4.1-CVE-2015-8504.patch b/app-emulation/qemu/files/qemu-2.4.1-CVE-2015-8504.patch |
85 |
new file mode 100644 |
86 |
index 0000000..7b0102a |
87 |
--- /dev/null |
88 |
+++ b/app-emulation/qemu/files/qemu-2.4.1-CVE-2015-8504.patch |
89 |
@@ -0,0 +1,46 @@ |
90 |
+https://bugs.gentoo.org/567828 |
91 |
+ |
92 |
+From 4c65fed8bdf96780735dbdb92a8bd0d6b6526cc3 Mon Sep 17 00:00:00 2001 |
93 |
+From: Prasad J Pandit <pjp@×××××××××××××.org> |
94 |
+Date: Thu, 3 Dec 2015 18:54:17 +0530 |
95 |
+Subject: [PATCH] ui: vnc: avoid floating point exception |
96 |
+ |
97 |
+While sending 'SetPixelFormat' messages to a VNC server, |
98 |
+the client could set the 'red-max', 'green-max' and 'blue-max' |
99 |
+values to be zero. This leads to a floating point exception in |
100 |
+write_png_palette while doing frame buffer updates. |
101 |
+ |
102 |
+Reported-by: Lian Yihan <lianyihan@×××.cn> |
103 |
+Signed-off-by: Prasad J Pandit <pjp@×××××××××××××.org> |
104 |
+Reviewed-by: Gerd Hoffmann <kraxel@××××××.com> |
105 |
+Signed-off-by: Peter Maydell <peter.maydell@××××××.org> |
106 |
+--- |
107 |
+ ui/vnc.c | 6 +++--- |
108 |
+ 1 file changed, 3 insertions(+), 3 deletions(-) |
109 |
+ |
110 |
+diff --git a/ui/vnc.c b/ui/vnc.c |
111 |
+index 7538405..cbe4d33 100644 |
112 |
+--- a/ui/vnc.c |
113 |
++++ b/ui/vnc.c |
114 |
+@@ -2198,15 +2198,15 @@ static void set_pixel_format(VncState *vs, |
115 |
+ return; |
116 |
+ } |
117 |
+ |
118 |
+- vs->client_pf.rmax = red_max; |
119 |
++ vs->client_pf.rmax = red_max ? red_max : 0xFF; |
120 |
+ vs->client_pf.rbits = hweight_long(red_max); |
121 |
+ vs->client_pf.rshift = red_shift; |
122 |
+ vs->client_pf.rmask = red_max << red_shift; |
123 |
+- vs->client_pf.gmax = green_max; |
124 |
++ vs->client_pf.gmax = green_max ? green_max : 0xFF; |
125 |
+ vs->client_pf.gbits = hweight_long(green_max); |
126 |
+ vs->client_pf.gshift = green_shift; |
127 |
+ vs->client_pf.gmask = green_max << green_shift; |
128 |
+- vs->client_pf.bmax = blue_max; |
129 |
++ vs->client_pf.bmax = blue_max ? blue_max : 0xFF; |
130 |
+ vs->client_pf.bbits = hweight_long(blue_max); |
131 |
+ vs->client_pf.bshift = blue_shift; |
132 |
+ vs->client_pf.bmask = blue_max << blue_shift; |
133 |
+-- |
134 |
+2.6.2 |
135 |
+ |
136 |
|
137 |
diff --git a/app-emulation/qemu/qemu-2.4.1-r2.ebuild b/app-emulation/qemu/qemu-2.4.1-r2.ebuild |
138 |
new file mode 100644 |
139 |
index 0000000..3556dfe |
140 |
--- /dev/null |
141 |
+++ b/app-emulation/qemu/qemu-2.4.1-r2.ebuild |
142 |
@@ -0,0 +1,642 @@ |
143 |
+# Copyright 1999-2015 Gentoo Foundation |
144 |
+# Distributed under the terms of the GNU General Public License v2 |
145 |
+# $Id$ |
146 |
+ |
147 |
+EAPI=5 |
148 |
+ |
149 |
+PYTHON_COMPAT=( python2_7 ) |
150 |
+PYTHON_REQ_USE="ncurses,readline" |
151 |
+ |
152 |
+inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \ |
153 |
+ user udev fcaps readme.gentoo pax-utils |
154 |
+ |
155 |
+BACKPORTS= |
156 |
+ |
157 |
+if [[ ${PV} = *9999* ]]; then |
158 |
+ EGIT_REPO_URI="git://git.qemu.org/qemu.git" |
159 |
+ inherit git-2 |
160 |
+ SRC_URI="" |
161 |
+else |
162 |
+ SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2 |
163 |
+ ${BACKPORTS:+ |
164 |
+ https://dev.gentoo.org/~cardoe/distfiles/${P}-${BACKPORTS}.tar.xz}" |
165 |
+ KEYWORDS="~amd64 ~ppc ~ppc64 ~x86 ~x86-fbsd" |
166 |
+fi |
167 |
+ |
168 |
+DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools" |
169 |
+HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org" |
170 |
+ |
171 |
+LICENSE="GPL-2 LGPL-2 BSD-2" |
172 |
+SLOT="0" |
173 |
+IUSE="accessibility +aio alsa bluetooth +caps +curl debug +fdt glusterfs \ |
174 |
+gtk gtk2 infiniband iscsi +jpeg \ |
175 |
+kernel_linux kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs |
176 |
++png pulseaudio python \ |
177 |
+rbd sasl +seccomp sdl sdl2 selinux smartcard snappy spice ssh static static-softmmu |
178 |
+static-user systemtap tci test +threads tls usb usbredir +uuid vde +vhost-net \ |
179 |
+virtfs +vnc vte xattr xen xfs" |
180 |
+ |
181 |
+COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel mips |
182 |
+mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc sparc64 unicore32 |
183 |
+x86_64" |
184 |
+IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 moxie ppcemb tricore xtensa xtensaeb" |
185 |
+IUSE_USER_TARGETS="${COMMON_TARGETS} armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus" |
186 |
+ |
187 |
+use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS}) |
188 |
+use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS}) |
189 |
+IUSE+=" ${use_softmmu_targets} ${use_user_targets}" |
190 |
+ |
191 |
+# Allow no targets to be built so that people can get a tools-only build. |
192 |
+# Block USE flag configurations known to not work. |
193 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE} |
194 |
+ gtk2? ( gtk ) |
195 |
+ qemu_softmmu_targets_arm? ( fdt ) |
196 |
+ qemu_softmmu_targets_microblaze? ( fdt ) |
197 |
+ qemu_softmmu_targets_ppc? ( fdt ) |
198 |
+ qemu_softmmu_targets_ppc64? ( fdt ) |
199 |
+ sdl2? ( sdl ) |
200 |
+ static? ( static-softmmu static-user ) |
201 |
+ static-softmmu? ( !alsa !pulseaudio !bluetooth !opengl !gtk !gtk2 ) |
202 |
+ virtfs? ( xattr ) |
203 |
+ vte? ( gtk )" |
204 |
+ |
205 |
+# Yep, you need both libcap and libcap-ng since virtfs only uses libcap. |
206 |
+# |
207 |
+# The attr lib isn't always linked in (although the USE flag is always |
208 |
+# respected). This is because qemu supports using the C library's API |
209 |
+# when available rather than always using the extranl library. |
210 |
+COMMON_LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)] |
211 |
+ sys-libs/zlib[static-libs(+)] |
212 |
+ xattr? ( sys-apps/attr[static-libs(+)] )" |
213 |
+SOFTMMU_LIB_DEPEND="${COMMON_LIB_DEPEND} |
214 |
+ >=x11-libs/pixman-0.28.0[static-libs(+)] |
215 |
+ accessibility? ( app-accessibility/brltty[static-libs(+)] ) |
216 |
+ aio? ( dev-libs/libaio[static-libs(+)] ) |
217 |
+ alsa? ( >=media-libs/alsa-lib-1.0.13 ) |
218 |
+ bluetooth? ( net-wireless/bluez ) |
219 |
+ caps? ( sys-libs/libcap-ng[static-libs(+)] ) |
220 |
+ curl? ( >=net-misc/curl-7.15.4[static-libs(+)] ) |
221 |
+ fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] ) |
222 |
+ glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] ) |
223 |
+ gtk? ( |
224 |
+ gtk2? ( |
225 |
+ x11-libs/gtk+:2 |
226 |
+ vte? ( x11-libs/vte:0 ) |
227 |
+ ) |
228 |
+ !gtk2? ( |
229 |
+ x11-libs/gtk+:3 |
230 |
+ vte? ( x11-libs/vte:2.90 ) |
231 |
+ ) |
232 |
+ ) |
233 |
+ infiniband? ( sys-infiniband/librdmacm:=[static-libs(+)] ) |
234 |
+ iscsi? ( net-libs/libiscsi ) |
235 |
+ jpeg? ( virtual/jpeg:=[static-libs(+)] ) |
236 |
+ lzo? ( dev-libs/lzo:2[static-libs(+)] ) |
237 |
+ ncurses? ( sys-libs/ncurses:0=[static-libs(+)] ) |
238 |
+ nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] ) |
239 |
+ numa? ( sys-process/numactl[static-libs(+)] ) |
240 |
+ opengl? ( |
241 |
+ virtual/opengl |
242 |
+ media-libs/libepoxy[static-libs(+)] |
243 |
+ media-libs/mesa[static-libs(+)] |
244 |
+ media-libs/mesa[egl,gles2] |
245 |
+ ) |
246 |
+ png? ( media-libs/libpng:0=[static-libs(+)] ) |
247 |
+ pulseaudio? ( media-sound/pulseaudio ) |
248 |
+ rbd? ( sys-cluster/ceph[static-libs(+)] ) |
249 |
+ sasl? ( dev-libs/cyrus-sasl[static-libs(+)] ) |
250 |
+ sdl? ( |
251 |
+ !sdl2? ( |
252 |
+ media-libs/libsdl[X] |
253 |
+ >=media-libs/libsdl-1.2.11[static-libs(+)] |
254 |
+ ) |
255 |
+ sdl2? ( |
256 |
+ media-libs/libsdl2[X] |
257 |
+ media-libs/libsdl2[static-libs(+)] |
258 |
+ ) |
259 |
+ ) |
260 |
+ seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] ) |
261 |
+ smartcard? ( dev-libs/nss !app-emulation/libcacard ) |
262 |
+ snappy? ( app-arch/snappy[static-libs(+)] ) |
263 |
+ spice? ( |
264 |
+ >=app-emulation/spice-protocol-0.12.3 |
265 |
+ >=app-emulation/spice-0.12.0[static-libs(+)] |
266 |
+ ) |
267 |
+ ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] ) |
268 |
+ tls? ( net-libs/gnutls[static-libs(+)] ) |
269 |
+ usb? ( >=virtual/libusb-1-r2[static-libs(+)] ) |
270 |
+ usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] ) |
271 |
+ uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] ) |
272 |
+ vde? ( net-misc/vde[static-libs(+)] ) |
273 |
+ virtfs? ( sys-libs/libcap ) |
274 |
+ xfs? ( sys-fs/xfsprogs[static-libs(+)] )" |
275 |
+USER_LIB_DEPEND="${COMMON_LIB_DEPEND}" |
276 |
+X86_FIRMWARE_DEPEND=" |
277 |
+ >=sys-firmware/ipxe-1.0.0_p20130624 |
278 |
+ pin-upstream-blobs? ( |
279 |
+ ~sys-firmware/seabios-1.8.2 |
280 |
+ ~sys-firmware/sgabios-0.1_pre8 |
281 |
+ ~sys-firmware/vgabios-0.7a |
282 |
+ ) |
283 |
+ !pin-upstream-blobs? ( |
284 |
+ sys-firmware/seabios |
285 |
+ sys-firmware/sgabios |
286 |
+ sys-firmware/vgabios |
287 |
+ )" |
288 |
+CDEPEND=" |
289 |
+ !static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND//\[static-libs(+)]} ) " ${use_softmmu_targets}) ) |
290 |
+ !static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND//\[static-libs(+)]} ) " ${use_user_targets}) ) |
291 |
+ qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} ) |
292 |
+ qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} ) |
293 |
+ python? ( ${PYTHON_DEPS} ) |
294 |
+ systemtap? ( dev-util/systemtap ) |
295 |
+ xen? ( app-emulation/xen-tools:= )" |
296 |
+DEPEND="${CDEPEND} |
297 |
+ dev-lang/perl |
298 |
+ =dev-lang/python-2* |
299 |
+ sys-apps/texinfo |
300 |
+ virtual/pkgconfig |
301 |
+ kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 ) |
302 |
+ gtk? ( nls? ( sys-devel/gettext ) ) |
303 |
+ static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND} ) " ${use_softmmu_targets}) ) |
304 |
+ static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND} ) " ${use_user_targets}) ) |
305 |
+ test? ( |
306 |
+ dev-libs/glib[utils] |
307 |
+ sys-devel/bc |
308 |
+ )" |
309 |
+RDEPEND="${CDEPEND} |
310 |
+ selinux? ( sec-policy/selinux-qemu ) |
311 |
+" |
312 |
+ |
313 |
+STRIP_MASK="/usr/share/qemu/palcode-clipper" |
314 |
+ |
315 |
+QA_PREBUILT=" |
316 |
+ usr/share/qemu/openbios-ppc |
317 |
+ usr/share/qemu/openbios-sparc64 |
318 |
+ usr/share/qemu/openbios-sparc32 |
319 |
+ usr/share/qemu/palcode-clipper |
320 |
+ usr/share/qemu/s390-ccw.img |
321 |
+ usr/share/qemu/u-boot.e500 |
322 |
+" |
323 |
+ |
324 |
+QA_WX_LOAD="usr/bin/qemu-i386 |
325 |
+ usr/bin/qemu-x86_64 |
326 |
+ usr/bin/qemu-alpha |
327 |
+ usr/bin/qemu-arm |
328 |
+ usr/bin/qemu-cris |
329 |
+ usr/bin/qemu-m68k |
330 |
+ usr/bin/qemu-microblaze |
331 |
+ usr/bin/qemu-microblazeel |
332 |
+ usr/bin/qemu-mips |
333 |
+ usr/bin/qemu-mipsel |
334 |
+ usr/bin/qemu-or32 |
335 |
+ usr/bin/qemu-ppc |
336 |
+ usr/bin/qemu-ppc64 |
337 |
+ usr/bin/qemu-ppc64abi32 |
338 |
+ usr/bin/qemu-sh4 |
339 |
+ usr/bin/qemu-sh4eb |
340 |
+ usr/bin/qemu-sparc |
341 |
+ usr/bin/qemu-sparc64 |
342 |
+ usr/bin/qemu-armeb |
343 |
+ usr/bin/qemu-sparc32plus |
344 |
+ usr/bin/qemu-s390x |
345 |
+ usr/bin/qemu-unicore32" |
346 |
+ |
347 |
+DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure |
348 |
+you have the kernel module loaded before running kvm. The easiest way to |
349 |
+ensure that the kernel module is loaded is to load it on boot.\n |
350 |
+For AMD CPUs the module is called 'kvm-amd'\n |
351 |
+For Intel CPUs the module is called 'kvm-intel'\n |
352 |
+Please review /etc/conf.d/modules for how to load these\n\n |
353 |
+Make sure your user is in the 'kvm' group\n |
354 |
+Just run 'gpasswd -a <USER> kvm', then have <USER> re-login." |
355 |
+ |
356 |
+qemu_support_kvm() { |
357 |
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 \ |
358 |
+ use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64 \ |
359 |
+ use qemu_softmmu_targets_s390x; then |
360 |
+ return 0 |
361 |
+ fi |
362 |
+ |
363 |
+ return 1 |
364 |
+} |
365 |
+ |
366 |
+pkg_pretend() { |
367 |
+ if use kernel_linux && kernel_is lt 2 6 25; then |
368 |
+ eerror "This version of KVM requres a host kernel of 2.6.25 or higher." |
369 |
+ elif use kernel_linux; then |
370 |
+ if ! linux_config_exists; then |
371 |
+ eerror "Unable to check your kernel for KVM support" |
372 |
+ else |
373 |
+ CONFIG_CHECK="~KVM ~TUN ~BRIDGE" |
374 |
+ ERROR_KVM="You must enable KVM in your kernel to continue" |
375 |
+ ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in" |
376 |
+ ERROR_KVM_AMD+=" your kernel configuration." |
377 |
+ ERROR_KVM_INTEL="If you have an Intel CPU, you must enable" |
378 |
+ ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration." |
379 |
+ ERROR_TUN="You will need the Universal TUN/TAP driver compiled" |
380 |
+ ERROR_TUN+=" into your kernel or loaded as a module to use the" |
381 |
+ ERROR_TUN+=" virtual network device if using -net tap." |
382 |
+ ERROR_BRIDGE="You will also need support for 802.1d" |
383 |
+ ERROR_BRIDGE+=" Ethernet Bridging for some network configurations." |
384 |
+ use vhost-net && CONFIG_CHECK+=" ~VHOST_NET" |
385 |
+ ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net" |
386 |
+ ERROR_VHOST_NET+=" support" |
387 |
+ |
388 |
+ if use amd64 || use x86 || use amd64-linux || use x86-linux; then |
389 |
+ CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL" |
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 |
+pkg_setup() { |
410 |
+ enewgroup kvm 78 |
411 |
+} |
412 |
+ |
413 |
+# Sanity check to make sure target lists are kept up-to-date. |
414 |
+check_targets() { |
415 |
+ local var=$1 mak=$2 |
416 |
+ local detected sorted |
417 |
+ |
418 |
+ pushd "${S}"/default-configs >/dev/null || die |
419 |
+ |
420 |
+ # Force C locale until glibc is updated. #564936 |
421 |
+ detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u)) |
422 |
+ sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u)) |
423 |
+ if [[ ${sorted} != "${detected}" ]] ; then |
424 |
+ eerror "The ebuild needs to be kept in sync." |
425 |
+ eerror "${var}: ${sorted}" |
426 |
+ eerror "$(printf '%-*s' ${#var} configure): ${detected}" |
427 |
+ die "sync ${var} to the list of targets" |
428 |
+ fi |
429 |
+ |
430 |
+ popd >/dev/null |
431 |
+} |
432 |
+ |
433 |
+src_prepare() { |
434 |
+ check_targets IUSE_SOFTMMU_TARGETS softmmu |
435 |
+ check_targets IUSE_USER_TARGETS linux-user |
436 |
+ |
437 |
+ # Alter target makefiles to accept CFLAGS set via flag-o |
438 |
+ sed -i -r \ |
439 |
+ -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \ |
440 |
+ Makefile Makefile.target || die |
441 |
+ |
442 |
+ # Cheap hack to disable gettext .mo generation. |
443 |
+ use nls || rm -f po/*.po |
444 |
+ |
445 |
+ epatch "${FILESDIR}"/qemu-1.7.0-cflags.patch |
446 |
+ epatch "${FILESDIR}"/${PN}-2.4.1-CVE-2015-{7504,7512}.patch #567144 |
447 |
+ epatch "${FILESDIR}"/${PN}-2.4.1-CVE-2015-8345.patch #566792 |
448 |
+ epatch "${FILESDIR}"/${PN}-2.4.1-CVE-2015-8504.patch #567828 |
449 |
+ epatch "${FILESDIR}"/${PN}-2.4.1-CVE-2015-7549.patch #568214 |
450 |
+ epatch "${FILESDIR}"/${PN}-2.4-mips-* #563162 |
451 |
+ [[ -n ${BACKPORTS} ]] && \ |
452 |
+ EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \ |
453 |
+ epatch |
454 |
+ |
455 |
+ # Fix ld and objcopy being called directly |
456 |
+ tc-export AR LD OBJCOPY |
457 |
+ |
458 |
+ # Verbose builds |
459 |
+ MAKEOPTS+=" V=1" |
460 |
+ |
461 |
+ epatch_user |
462 |
+} |
463 |
+ |
464 |
+## |
465 |
+# configures qemu based on the build directory and the build type |
466 |
+# we are using. |
467 |
+# |
468 |
+qemu_src_configure() { |
469 |
+ debug-print-function ${FUNCNAME} "$@" |
470 |
+ |
471 |
+ local buildtype=$1 |
472 |
+ local builddir="${S}/${buildtype}-build" |
473 |
+ local static_flag="static-${buildtype}" |
474 |
+ |
475 |
+ mkdir "${builddir}" |
476 |
+ |
477 |
+ local conf_opts=( |
478 |
+ --prefix=/usr |
479 |
+ --sysconfdir=/etc |
480 |
+ --libdir=/usr/$(get_libdir) |
481 |
+ --docdir=/usr/share/doc/${PF}/html |
482 |
+ --disable-bsd-user |
483 |
+ --disable-guest-agent |
484 |
+ --disable-strip |
485 |
+ --disable-werror |
486 |
+ --python="${PYTHON}" |
487 |
+ --cc="$(tc-getCC)" |
488 |
+ --cxx="$(tc-getCXX)" |
489 |
+ --host-cc="$(tc-getBUILD_CC)" |
490 |
+ $(use_enable debug debug-info) |
491 |
+ $(use_enable debug debug-tcg) |
492 |
+ --enable-docs |
493 |
+ $(use_enable tci tcg-interpreter) |
494 |
+ $(use_enable xattr attr) |
495 |
+ ) |
496 |
+ |
497 |
+ # Disable options not used by user targets as the default configure |
498 |
+ # options will autoprobe and try to link in a bunch of unused junk. |
499 |
+ conf_softmmu() { |
500 |
+ if [[ ${buildtype} == "user" ]] ; then |
501 |
+ echo "--disable-${2:-$1}" |
502 |
+ else |
503 |
+ use_enable "$@" |
504 |
+ fi |
505 |
+ } |
506 |
+ conf_opts+=( |
507 |
+ $(conf_softmmu accessibility brlapi) |
508 |
+ $(conf_softmmu aio linux-aio) |
509 |
+ $(conf_softmmu bluetooth bluez) |
510 |
+ $(conf_softmmu caps cap-ng) |
511 |
+ $(conf_softmmu curl) |
512 |
+ $(conf_softmmu fdt) |
513 |
+ $(conf_softmmu glusterfs) |
514 |
+ $(conf_softmmu gtk) |
515 |
+ $(conf_softmmu infiniband rdma) |
516 |
+ $(conf_softmmu iscsi libiscsi) |
517 |
+ $(conf_softmmu jpeg vnc-jpeg) |
518 |
+ $(conf_softmmu kernel_linux kvm) |
519 |
+ $(conf_softmmu lzo) |
520 |
+ $(conf_softmmu ncurses curses) |
521 |
+ $(conf_softmmu nfs libnfs) |
522 |
+ $(conf_softmmu numa) |
523 |
+ $(conf_softmmu opengl) |
524 |
+ $(conf_softmmu png vnc-png) |
525 |
+ $(conf_softmmu rbd) |
526 |
+ $(conf_softmmu sasl vnc-sasl) |
527 |
+ $(conf_softmmu sdl) |
528 |
+ $(conf_softmmu seccomp) |
529 |
+ $(conf_softmmu smartcard smartcard-nss) |
530 |
+ $(conf_softmmu snappy) |
531 |
+ $(conf_softmmu spice) |
532 |
+ $(conf_softmmu ssh libssh2) |
533 |
+ $(conf_softmmu tls vnc-tls) |
534 |
+ $(conf_softmmu usb libusb) |
535 |
+ $(conf_softmmu usbredir usb-redir) |
536 |
+ $(conf_softmmu uuid) |
537 |
+ $(conf_softmmu vde) |
538 |
+ $(conf_softmmu vhost-net) |
539 |
+ $(conf_softmmu virtfs) |
540 |
+ $(conf_softmmu vnc) |
541 |
+ $(conf_softmmu vte) |
542 |
+ $(conf_softmmu xen) |
543 |
+ $(conf_softmmu xen xen-pci-passthrough) |
544 |
+ $(conf_softmmu xfs xfsctl) |
545 |
+ ) |
546 |
+ |
547 |
+ case ${buildtype} in |
548 |
+ user) |
549 |
+ conf_opts+=( |
550 |
+ --enable-linux-user |
551 |
+ --disable-system |
552 |
+ --disable-blobs |
553 |
+ --disable-tools |
554 |
+ ) |
555 |
+ ;; |
556 |
+ softmmu) |
557 |
+ # audio options |
558 |
+ local audio_opts="oss" |
559 |
+ use alsa && audio_opts="alsa,${audio_opts}" |
560 |
+ use sdl && audio_opts="sdl,${audio_opts}" |
561 |
+ use pulseaudio && audio_opts="pa,${audio_opts}" |
562 |
+ |
563 |
+ conf_opts+=( |
564 |
+ --disable-linux-user |
565 |
+ --enable-system |
566 |
+ --with-system-pixman |
567 |
+ --audio-drv-list="${audio_opts}" |
568 |
+ ) |
569 |
+ use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) ) |
570 |
+ use sdl && conf_opts+=( --with-sdlabi=$(usex sdl2 2.0 1.2) ) |
571 |
+ ;; |
572 |
+ tools) |
573 |
+ conf_opts+=( |
574 |
+ --disable-linux-user |
575 |
+ --disable-system |
576 |
+ --disable-blobs |
577 |
+ ) |
578 |
+ static_flag="static" |
579 |
+ ;; |
580 |
+ esac |
581 |
+ |
582 |
+ local targets="${buildtype}_targets" |
583 |
+ [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" ) |
584 |
+ |
585 |
+ # Add support for SystemTAP |
586 |
+ use systemtap && conf_opts+=( --enable-trace-backend=dtrace ) |
587 |
+ |
588 |
+ # We always want to attempt to build with PIE support as it results |
589 |
+ # in a more secure binary. But it doesn't work with static or if |
590 |
+ # the current GCC doesn't have PIE support. |
591 |
+ if use ${static_flag}; then |
592 |
+ conf_opts+=( --static --disable-pie ) |
593 |
+ else |
594 |
+ gcc-specs-pie && conf_opts+=( --enable-pie ) |
595 |
+ fi |
596 |
+ |
597 |
+ echo "../configure ${conf_opts[*]}" |
598 |
+ cd "${builddir}" |
599 |
+ ../configure "${conf_opts[@]}" || die "configure failed" |
600 |
+ |
601 |
+ # FreeBSD's kernel does not support QEMU assigning/grabbing |
602 |
+ # host USB devices yet |
603 |
+ use kernel_FreeBSD && \ |
604 |
+ sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak |
605 |
+} |
606 |
+ |
607 |
+src_configure() { |
608 |
+ local target |
609 |
+ |
610 |
+ python_setup |
611 |
+ |
612 |
+ softmmu_targets= softmmu_bins=() |
613 |
+ user_targets= user_bins=() |
614 |
+ |
615 |
+ for target in ${IUSE_SOFTMMU_TARGETS} ; do |
616 |
+ if use "qemu_softmmu_targets_${target}"; then |
617 |
+ softmmu_targets+=",${target}-softmmu" |
618 |
+ softmmu_bins+=( "qemu-system-${target}" ) |
619 |
+ fi |
620 |
+ done |
621 |
+ |
622 |
+ for target in ${IUSE_USER_TARGETS} ; do |
623 |
+ if use "qemu_user_targets_${target}"; then |
624 |
+ user_targets+=",${target}-linux-user" |
625 |
+ user_bins+=( "qemu-${target}" ) |
626 |
+ fi |
627 |
+ done |
628 |
+ |
629 |
+ softmmu_targets=${softmmu_targets#,} |
630 |
+ user_targets=${user_targets#,} |
631 |
+ |
632 |
+ [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu" |
633 |
+ [[ -n ${user_targets} ]] && qemu_src_configure "user" |
634 |
+ [[ -z ${softmmu_targets}${user_targets} ]] && qemu_src_configure "tools" |
635 |
+} |
636 |
+ |
637 |
+src_compile() { |
638 |
+ if [[ -n ${user_targets} ]]; then |
639 |
+ cd "${S}/user-build" |
640 |
+ default |
641 |
+ fi |
642 |
+ |
643 |
+ if [[ -n ${softmmu_targets} ]]; then |
644 |
+ cd "${S}/softmmu-build" |
645 |
+ default |
646 |
+ fi |
647 |
+ |
648 |
+ if [[ -z ${softmmu_targets}${user_targets} ]]; then |
649 |
+ cd "${S}/tools-build" |
650 |
+ default |
651 |
+ fi |
652 |
+} |
653 |
+ |
654 |
+src_test() { |
655 |
+ if [[ -n ${softmmu_targets} ]]; then |
656 |
+ cd "${S}/softmmu-build" |
657 |
+ pax-mark m */qemu-system-* #515550 |
658 |
+ emake -j1 check |
659 |
+ emake -j1 check-report.html |
660 |
+ fi |
661 |
+} |
662 |
+ |
663 |
+qemu_python_install() { |
664 |
+ python_domodule "${S}/scripts/qmp/qmp.py" |
665 |
+ |
666 |
+ python_doscript "${S}/scripts/kvm/kvm_stat" |
667 |
+ python_doscript "${S}/scripts/kvm/vmxcap" |
668 |
+ python_doscript "${S}/scripts/qmp/qmp-shell" |
669 |
+ python_doscript "${S}/scripts/qmp/qemu-ga-client" |
670 |
+} |
671 |
+ |
672 |
+src_install() { |
673 |
+ if [[ -n ${user_targets} ]]; then |
674 |
+ cd "${S}/user-build" |
675 |
+ emake DESTDIR="${ED}" install |
676 |
+ |
677 |
+ # Install binfmt handler init script for user targets |
678 |
+ newinitd "${FILESDIR}/qemu-binfmt.initd-r1" qemu-binfmt |
679 |
+ fi |
680 |
+ |
681 |
+ if [[ -n ${softmmu_targets} ]]; then |
682 |
+ cd "${S}/softmmu-build" |
683 |
+ emake DESTDIR="${ED}" install |
684 |
+ |
685 |
+ # This might not exist if the test failed. #512010 |
686 |
+ [[ -e check-report.html ]] && dohtml check-report.html |
687 |
+ |
688 |
+ if use kernel_linux; then |
689 |
+ udev_dorules "${FILESDIR}"/65-kvm.rules |
690 |
+ fi |
691 |
+ |
692 |
+ if use python; then |
693 |
+ python_foreach_impl qemu_python_install |
694 |
+ fi |
695 |
+ fi |
696 |
+ |
697 |
+ if [[ -z ${softmmu_targets}${user_targets} ]]; then |
698 |
+ cd "${S}/tools-build" |
699 |
+ emake DESTDIR="${ED}" install |
700 |
+ fi |
701 |
+ |
702 |
+ # Disable mprotect on the qemu binaries as they use JITs to be fast #459348 |
703 |
+ pushd "${ED}"/usr/bin >/dev/null |
704 |
+ pax-mark m "${softmmu_bins[@]}" "${user_bins[@]}" |
705 |
+ popd >/dev/null |
706 |
+ |
707 |
+ # Install config file example for qemu-bridge-helper |
708 |
+ insinto "/etc/qemu" |
709 |
+ doins "${FILESDIR}/bridge.conf" |
710 |
+ |
711 |
+ # Remove the docdir placed qmp-commands.txt |
712 |
+ mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/qmp/" |
713 |
+ |
714 |
+ cd "${S}" |
715 |
+ dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt |
716 |
+ newdoc pc-bios/README README.pc-bios |
717 |
+ dodoc docs/qmp/*.txt |
718 |
+ |
719 |
+ if [[ -n ${softmmu_targets} ]]; then |
720 |
+ # Remove SeaBIOS since we're using the SeaBIOS packaged one |
721 |
+ rm "${ED}/usr/share/qemu/bios.bin" |
722 |
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then |
723 |
+ dosym ../seabios/bios.bin /usr/share/qemu/bios.bin |
724 |
+ fi |
725 |
+ |
726 |
+ # Remove vgabios since we're using the vgabios packaged one |
727 |
+ rm "${ED}/usr/share/qemu/vgabios.bin" |
728 |
+ rm "${ED}/usr/share/qemu/vgabios-cirrus.bin" |
729 |
+ rm "${ED}/usr/share/qemu/vgabios-qxl.bin" |
730 |
+ rm "${ED}/usr/share/qemu/vgabios-stdvga.bin" |
731 |
+ rm "${ED}/usr/share/qemu/vgabios-vmware.bin" |
732 |
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then |
733 |
+ dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin |
734 |
+ dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin |
735 |
+ dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin |
736 |
+ dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin |
737 |
+ dosym ../vgabios/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 |
+ qemu_support_kvm && readme.gentoo_create_doc |
759 |
+} |
760 |
+ |
761 |
+pkg_postinst() { |
762 |
+ if qemu_support_kvm; then |
763 |
+ readme.gentoo_print_elog |
764 |
+ fi |
765 |
+ |
766 |
+ if [[ -n ${softmmu_targets} ]] && use kernel_linux; then |
767 |
+ udev_reload |
768 |
+ fi |
769 |
+ |
770 |
+ fcaps cap_net_admin /usr/libexec/qemu-bridge-helper |
771 |
+} |
772 |
+ |
773 |
+pkg_info() { |
774 |
+ echo "Using:" |
775 |
+ echo " $(best_version app-emulation/spice-protocol)" |
776 |
+ echo " $(best_version sys-firmware/ipxe)" |
777 |
+ echo " $(best_version sys-firmware/seabios)" |
778 |
+ if has_version 'sys-firmware/seabios[binary]'; then |
779 |
+ echo " USE=binary" |
780 |
+ else |
781 |
+ echo " USE=''" |
782 |
+ fi |
783 |
+ echo " $(best_version sys-firmware/vgabios)" |
784 |
+} |