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