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