summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-emulation/qemu')
-rw-r--r--app-emulation/qemu/Manifest15
-rw-r--r--app-emulation/qemu/files/qemu-2.11.1-capstone_include_path.patch11
-rw-r--r--app-emulation/qemu/files/qemu-6.1.0-strings.patch26
-rw-r--r--app-emulation/qemu/files/qemu-7.0.0-pci-overflow-fortify-source-3.patch94
-rw-r--r--app-emulation/qemu/files/qemu-7.0.0-virtio-scsi-fixes.patch182
-rw-r--r--app-emulation/qemu/files/qemu-7.1.0-capstone-include-path.patch31
-rw-r--r--app-emulation/qemu/files/qemu-7.1.0-strings.patch26
-rw-r--r--app-emulation/qemu/files/qemu-7.2.0-disable-gmp.patch45
-rw-r--r--app-emulation/qemu/files/qemu-7.2.0-linux-headers-6.2-glibc-2.36.patch137
-rw-r--r--app-emulation/qemu/files/qemu-8.0.0-disable-keymap.patch29
-rw-r--r--app-emulation/qemu/files/qemu-8.0.0-make.patch13
-rw-r--r--app-emulation/qemu/files/qemu-8.0.0-remove-python-meson-check.patch40
-rw-r--r--app-emulation/qemu/files/qemu-8.1.0-also-build-virtfs-proxy-helper.patch (renamed from app-emulation/qemu/files/qemu-7.0.0-also-build-virtfs-proxy-helper.patch)18
-rw-r--r--app-emulation/qemu/files/qemu-8.1.0-find-sphinx.patch10
-rw-r--r--app-emulation/qemu/files/qemu-8.1.0-skip-tests.patch64
-rw-r--r--app-emulation/qemu/files/qemu-9.0.0-also-build-virtfs-proxy-helper.patch35
-rw-r--r--app-emulation/qemu/files/qemu-9.0.0-capstone-include-path.patch42
-rw-r--r--app-emulation/qemu/files/qemu-9.0.0-disable-keymap.patch44
-rw-r--r--app-emulation/qemu/metadata.xml26
-rw-r--r--app-emulation/qemu/qemu-7.2.11.ebuild (renamed from app-emulation/qemu/qemu-7.0.0-r2.ebuild)161
-rw-r--r--app-emulation/qemu/qemu-7.2.4.ebuild (renamed from app-emulation/qemu/qemu-7.0.0-r1.ebuild)188
-rw-r--r--app-emulation/qemu/qemu-8.0.5.ebuild972
-rw-r--r--app-emulation/qemu/qemu-8.1.5.ebuild972
-rw-r--r--app-emulation/qemu/qemu-8.2.3.ebuild992
-rw-r--r--app-emulation/qemu/qemu-9.0.0.ebuild996
-rw-r--r--app-emulation/qemu/qemu-9999.ebuild272
26 files changed, 4855 insertions, 586 deletions
diff --git a/app-emulation/qemu/Manifest b/app-emulation/qemu/Manifest
index 31a2d4d54918..b36c72fed2f6 100644
--- a/app-emulation/qemu/Manifest
+++ b/app-emulation/qemu/Manifest
@@ -1 +1,14 @@
-DIST qemu-7.0.0.tar.xz 125117636 BLAKE2B ceda6d9f1a585298bd49fed61e8bb35f0064ad8388a9f979c8bd68a38bfe1a47c5bb055e5f74f970c2c440957042b9de4a861524120040c56e4cd8b56c5cfb68 SHA512 44ecd10c018a3763e1bc87d1d35b98890d0d5636acd69fe9b5cadf5024d5af6a31684d60cbe1c3370e02986434c1fb0ad99224e0e6f6fe7eda169992508157b1
+DIST berkeley-softfloat-3-b64af41c3276f97f0e181920400ee056b9c88037.tar.bz2 84094 BLAKE2B 396f9df2e6ad559545054e89916915c3a3c8ff80e5e409498fec497b564d8b3ac9dd3cb966e26dce232ddff82af18a0e84e864ca18a80c2a2f4fe47e320249c2 SHA512 93c20d50a356c90f4293d8c7593611b2e0a9bc7567b6d946319f8ae06962ae1e297c8788f66fd38a1d3a0d44661bff9a07a63eaa84c8bb40ae01a45476be446c
+DIST berkeley-testfloat-3-e7af9751d9f9fd3b47911f51a5cfd08af256a9ab.tar.bz2 90020 BLAKE2B 3dda1ba90c4a5ad5cbce2acf35e93f7adbd387ae0e0f929b2cd4cbdf263f95183103118f32be38e8c80de49d7df44c26319ee2f465061d004ae7e64e43eeeb3e SHA512 65f41f42ea563b2cdceb6c71633f41e6694a79ffd02afed4540353a8e73668ae40118dfc108163aae751acbaa7c49630ed99f423465089503c03aee76b07f221
+DIST keycodemapdb-f5772a62ec52591ff6870b7e8ef32482371f22c6.tar.bz2 27971 BLAKE2B 0ed69ad24c53bd459c8753565814bcc1cd858f20d3a046c38912a35bcb0ba6d388ef5d2b93157cd028959284b330caf5467d82071c3df56a405dd8e08fd177c7 SHA512 8f2cc14e8bd46cb045e3ebfe32e463793ab7472ebda9b57b8ea0b06fa107a1a99c3ebcacb9c4548e30698d8ec154c0e56f789385201182b680819b8068a103f2
+DIST qemu-7.2.0-docs.tar.xz 1984184 BLAKE2B 103900fb7903ed8d75f7f012bf61fa2d6fce345b657c851d0437c3384f5735bd1cfd3129320683ea7846ea0b0940e5af5b2663c9320f12fee74b058523a8ea06 SHA512 a7edd448982865e07533c300d3e44a8b50cefbdde1982b73c24d0b2aa74315439252c59b634c75de312860874c7b06c75aa72629da681b5105f28ee936794585
+DIST qemu-7.2.11.tar.xz 121877020 BLAKE2B c546773b9ac7809b39a3afa51da5b1c06c3765fadb4df9d8529f8af65c26098676adf8e516620ca1b39201fa859878780edb56a445778e105cbe7db0f52b9f6a SHA512 c77ff1505128c05fe39eaa95cc11e4d2279bff06093acd613e54f71d4a13144f905551eec1d044c3a3fb751d3369c01d131d68c18b15d9a04bcc77370d93c217
+DIST qemu-7.2.4.tar.xz 121849100 BLAKE2B a9c5ffce9ff0fac4e2d1fa4be1a1dcee2f5d7f793ddf726871c5ae9a68c22f7ba03692a8a5096de3051030d3c2f34e46697d5af2d66c34984b8161ae3bb07b42 SHA512 fa765673833a1f2cbecdb9d47dc7dc29d7613be5a5c8fc63925ae70e1f5aafb4f9f02e45b212a329f17b689351b8a9cdf5f5235ab6adb71bb40e41868898d95b
+DIST qemu-8.0.0-docs.tar.xz 3218024 BLAKE2B b764a625024e78a39470048355471e12cfb57ab3c34e764dc4200fdf5c1aea635d26095ec961979bf46f177101c5bd38618bacf7e98e04bd64688ab5e29591aa SHA512 d9dfe191372e105fe16fe8f66f41ed793ade4c89b5ab1d84b39459f3419a1ca61bd49422a83981965cc257c05eca7fd49054703f58f179f5c7b656e9473a1054
+DIST qemu-8.0.5.tar.xz 126175064 BLAKE2B 1d1f78c185ab64b4ca946a44ad04d0bbb6ea48de058037e4ba18176abeb0f0528754c6e832f742f93227182bbce145544eca5b908a366006e7ee58876aca0bda SHA512 ec9679473dda84a2f56ae8ee0039ec4dafb056414bfc5a3a147b2b6bb45ae3b130dd80f6385e8567b5d18f4be94f3536bc8acc45c61eddf40c9678b46cb8bddc
+DIST qemu-8.1.0-docs.tar.xz 2129912 BLAKE2B 8aaf7b748538afdb5bcb6da15dbd96572d086824377c4b0e93f1ddc695f9a4775471e360a9616d2d481dbf8113e91d2601c69d92cef565fb90b65ffacfdb304e SHA512 905515742bb56a439fc8117ec48ea668e7b2bf0244587673e4352d9e8e49911eb84ff093596ff566e44787197cf9789ec8950e3d75fb7a670c5546394a322ac9
+DIST qemu-8.1.5.tar.xz 124007248 BLAKE2B 0d5db3e18c4dc1035fed442116be98b7e7bbfae905e4facef3278ef5a488332fa2d8e6599169fa1f740e96a035027e989c5cdffc0bfd4e0ca0fca1d0a537e8da SHA512 1005e0602a763979c4d0ec6e79a390e4232dcc3d0b8461fe42856c58e54ad25a2079f3850d27023fce8a2b382b36e3baa7882b69d48cbb72002984c160241c92
+DIST qemu-8.2.0-docs.tar.xz 2233352 BLAKE2B 22b9499fdf4ff93e72399dab3803f3171c855859dc7fe111612e2f9146db244ca6d2e0aad16aefdf29b231d2b3a2fbc22171fe6bac13b03445d54555ce798d16 SHA512 f57e78c28277c153fff00b25097d0df5c6ad36cb4e9f3acf30382bfb1c99508503c186c1bbecf266810ef24fd618428fdf3e0eee41c715a552918c9e6ef9e8e5
+DIST qemu-8.2.3.tar.xz 130106716 BLAKE2B 2ec91b5111952434686064bd603880d87c4f56774d2478ee953eb0454e2b14235b1d1cca484e015b96bceae3182f90b856d222ca590059032b4989babf1dffe8 SHA512 28c789d84754b26cd86ded9db8464ec82f07cdc3b1025a988e74b8c5b05df8839a3e9990ff96cfba50e032dd967e9dc18cf75f3525baeadd0fa019cb69108d0a
+DIST qemu-9.0.0-docs.tar.xz 2290196 BLAKE2B 82d22637ff2629bee372550e86651f12051ea6b4a57e314ef83f290425d4973ef01827eaf28a85b635788f22cb7cc1c747438b7525c92c99b90b234fb8f7655c SHA512 7c0ba1f3e7bbaa4e3feebc33a1946a5c190f2c14b9ed78b15c1f642668c8124960f8c85bcf36fe54a10d4edef47d2256e500f06d9173b92b03c599811a15a073
+DIST qemu-9.0.0.tar.xz 129789856 BLAKE2B d92acb859d9ce5097fee27a4689c71869aa38f65eb0308547956d54bd8caf29efe5389d9009f334f109ad228e0ef1f1fd1444d26360f03fac4320b204b657081 SHA512 1603517cd4c93632ba60ad7261eb67374f12a744bf58f10b0e8686e46d3a02d8b6bf58a0c617f23a1868084aaba6386c24341894f75539e0b816091718721427
diff --git a/app-emulation/qemu/files/qemu-2.11.1-capstone_include_path.patch b/app-emulation/qemu/files/qemu-2.11.1-capstone_include_path.patch
deleted file mode 100644
index d79570ebb8aa..000000000000
--- a/app-emulation/qemu/files/qemu-2.11.1-capstone_include_path.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- qemu-2.11.1/include/disas/capstone.h 2018-02-14 22:53:22.000000000 +0100
-+++ qemu-2.11.1/include/disas/capstone.h 2018-02-17 20:12:12.754703951 +0100
-@@ -3,7 +3,7 @@
-
- #ifdef CONFIG_CAPSTONE
-
--#include <capstone.h>
-+#include <capstone/capstone.h>
-
- #else
-
diff --git a/app-emulation/qemu/files/qemu-6.1.0-strings.patch b/app-emulation/qemu/files/qemu-6.1.0-strings.patch
deleted file mode 100644
index 2efe7b29330a..000000000000
--- a/app-emulation/qemu/files/qemu-6.1.0-strings.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Forward-ported from original patch for 5.2.0.
-
-diff --git a/configure b/configure
-index da2501489f..4660ee3ee5 100755
---- a/configure
-+++ b/configure
-@@ -516,6 +516,7 @@ ld="${LD-${cross_prefix}ld}"
- ranlib="${RANLIB-${cross_prefix}ranlib}"
- nm="${NM-${cross_prefix}nm}"
- strip="${STRIP-${cross_prefix}strip}"
-+strings="${STRINGS-${cross_prefix}strings}"
- windres="${WINDRES-${cross_prefix}windres}"
- pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
- query_pkg_config() {
-@@ -2380,9 +2381,9 @@ int main(int argc, char *argv[])
- EOF
-
- if compile_prog ; then
-- if strings -a $TMPE | grep -q BiGeNdIaN ; then
-+ if $strings -a $TMPE | grep -q BiGeNdIaN ; then
- bigendian="yes"
-- elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
-+ elif $strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
- bigendian="no"
- else
- echo big/little test failed
diff --git a/app-emulation/qemu/files/qemu-7.0.0-pci-overflow-fortify-source-3.patch b/app-emulation/qemu/files/qemu-7.0.0-pci-overflow-fortify-source-3.patch
deleted file mode 100644
index 767f66243fcc..000000000000
--- a/app-emulation/qemu/files/qemu-7.0.0-pci-overflow-fortify-source-3.patch
+++ /dev/null
@@ -1,94 +0,0 @@
-https://bugs.gentoo.org/849587
-https://bugzilla.opensuse.org/show_bug.cgi?id=1199924
-https://lists.gnu.org/archive/html/qemu-devel/2022-05/msg06183.html
-
-From qemu-devel Tue May 31 11:47:07 2022
-From: Claudio Fontana <cfontana () suse ! de>
-Date: Tue, 31 May 2022 11:47:07 +0000
-To: qemu-devel
-Subject: [PATCH] pci: fix overflow in snprintf string formatting
-Message-Id: <20220531114707.18830-1-cfontana () suse ! de>
-X-MARC-Message: https://marc.info/?l=qemu-devel&m=165399772310578
-
-the code in pcibus_get_fw_dev_path contained the potential for a
-stack buffer overflow of 1 byte, potentially writing to the stack an
-extra NUL byte.
-
-This overflow could happen if the PCI slot is >= 0x10000000,
-and the PCI function is >= 0x10000000, due to the size parameter
-of snprintf being incorrectly calculated in the call:
-
- if (PCI_FUNC(d->devfn))
- snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
-
-since the off obtained from a previous call to snprintf is added
-instead of subtracted from the total available size of the buffer.
-
-Without the accurate size guard from snprintf, we end up writing in the
-worst case:
-
-name (32) + "@" (1) + SLOT (8) + "," (1) + FUNC (8) + term NUL (1) = 51 bytes
-
-In order to provide something more robust, replace all of the code in
-pcibus_get_fw_dev_path with a single call to g_strdup_printf,
-so there is no need to rely on manual calculations.
-
-Found by compiling QEMU with FORTIFY_SOURCE=3 as the error:
-
-*** buffer overflow detected ***: terminated
-
-Thread 1 "qemu-system-x86" received signal SIGABRT, Aborted.
-[Switching to Thread 0x7ffff642c380 (LWP 121307)]
-0x00007ffff71ff55c in __pthread_kill_implementation () from /lib64/libc.so.6
-(gdb) bt
- #0 0x00007ffff71ff55c in __pthread_kill_implementation () at /lib64/libc.so.6
- #1 0x00007ffff71ac6f6 in raise () at /lib64/libc.so.6
- #2 0x00007ffff7195814 in abort () at /lib64/libc.so.6
- #3 0x00007ffff71f279e in __libc_message () at /lib64/libc.so.6
- #4 0x00007ffff729767a in __fortify_fail () at /lib64/libc.so.6
- #5 0x00007ffff7295c36 in () at /lib64/libc.so.6
- #6 0x00007ffff72957f5 in __snprintf_chk () at /lib64/libc.so.6
- #7 0x0000555555b1c1fd in pcibus_get_fw_dev_path ()
- #8 0x0000555555f2bde4 in qdev_get_fw_dev_path_helper.constprop ()
- #9 0x0000555555f2bd86 in qdev_get_fw_dev_path_helper.constprop ()
- #10 0x00005555559a6e5d in get_boot_device_path ()
- #11 0x00005555559a712c in get_boot_devices_list ()
- #12 0x0000555555b1a3d0 in fw_cfg_machine_reset ()
- #13 0x0000555555bf4c2d in pc_machine_reset ()
- #14 0x0000555555c66988 in qemu_system_reset ()
- #15 0x0000555555a6dff6 in qdev_machine_creation_done ()
- #16 0x0000555555c79186 in qmp_x_exit_preconfig.part ()
- #17 0x0000555555c7b459 in qemu_init ()
- #18 0x0000555555960a29 in main ()
-
-Found-by: Dario Faggioli <Dario Faggioli <dfaggioli@suse.com>
-Found-by: Martin Liška <martin.liska@suse.com>
-Cc: qemu-stable@nongnu.org
-Signed-off-by: Claudio Fontana <cfontana@suse.de>
---- a/hw/pci/pci.c
-+++ b/hw/pci/pci.c
-@@ -2640,15 +2640,15 @@ static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
- static char *pcibus_get_fw_dev_path(DeviceState *dev)
- {
- PCIDevice *d = (PCIDevice *)dev;
-- char path[50], name[33];
-- int off;
--
-- off = snprintf(path, sizeof(path), "%s@%x",
-- pci_dev_fw_name(dev, name, sizeof name),
-- PCI_SLOT(d->devfn));
-- if (PCI_FUNC(d->devfn))
-- snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
-- return g_strdup(path);
-+ char name[33];
-+ int has_func = !!PCI_FUNC(d->devfn);
-+
-+ return g_strdup_printf("%s@%x%s%.*x",
-+ pci_dev_fw_name(dev, name, sizeof(name)),
-+ PCI_SLOT(d->devfn),
-+ has_func ? "," : "",
-+ has_func,
-+ PCI_FUNC(d->devfn));
- }
-
- static char *pcibus_get_dev_path(DeviceState *dev)
diff --git a/app-emulation/qemu/files/qemu-7.0.0-virtio-scsi-fixes.patch b/app-emulation/qemu/files/qemu-7.0.0-virtio-scsi-fixes.patch
deleted file mode 100644
index 9ec6ede80896..000000000000
--- a/app-emulation/qemu/files/qemu-7.0.0-virtio-scsi-fixes.patch
+++ /dev/null
@@ -1,182 +0,0 @@
-https://bugs.gentoo.org/849500
-https://gitlab.com/qemu-project/qemu/-/commit/2f743ef6366c2df4ef51ef3ae318138cdc0125ab.patch
-https://gitlab.com/qemu-project/qemu/-/commit/38738f7dbbda90fbc161757b7f4be35b52205552.patch
-
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Wed, 27 Apr 2022 15:35:36 +0100
-Subject: [PATCH] virtio-scsi: fix ctrl and event handler functions in
- dataplane mode
-
-Commit f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare
-virtio_scsi_handle_cmd for dataplane") prepared the virtio-scsi cmd
-virtqueue handler function to be used in both the dataplane and
-non-datpalane code paths.
-
-It failed to convert the ctrl and event virtqueue handler functions,
-which are not designed to be called from the dataplane code path but
-will be since the ioeventfd is set up for those virtqueues when
-dataplane starts.
-
-Convert the ctrl and event virtqueue handler functions now so they
-operate correctly when called from the dataplane code path. Avoid code
-duplication by extracting this code into a helper function.
-
-Fixes: f34e8d8b8d48d73f36a67b6d5e492ef9784b5012 ("virtio-scsi: prepare virtio_scsi_handle_cmd for dataplane")
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
-Message-id: 20220427143541.119567-2-stefanha@redhat.com
-[Fixed s/by used/be used/ typo pointed out by Michael Tokarev
-<mjt@tls.msk.ru>.
---Stefan]
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---- a/hw/scsi/virtio-scsi.c
-+++ b/hw/scsi/virtio-scsi.c
-@@ -472,16 +472,32 @@ bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq)
- return progress;
- }
-
-+/*
-+ * If dataplane is configured but not yet started, do so now and return true on
-+ * success.
-+ *
-+ * Dataplane is started by the core virtio code but virtqueue handler functions
-+ * can also be invoked when a guest kicks before DRIVER_OK, so this helper
-+ * function helps us deal with manually starting ioeventfd in that case.
-+ */
-+static bool virtio_scsi_defer_to_dataplane(VirtIOSCSI *s)
-+{
-+ if (!s->ctx || s->dataplane_started) {
-+ return false;
-+ }
-+
-+ virtio_device_start_ioeventfd(&s->parent_obj.parent_obj);
-+ return !s->dataplane_fenced;
-+}
-+
- static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
- {
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
-
-- if (s->ctx) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_ctrl_vq(s, vq);
- virtio_scsi_release(s);
-@@ -720,12 +736,10 @@ static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
- /* use non-QOM casts in the data path */
- VirtIOSCSI *s = (VirtIOSCSI *)vdev;
-
-- if (s->ctx && !s->dataplane_started) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_cmd_vq(s, vq);
- virtio_scsi_release(s);
-@@ -855,12 +869,10 @@ static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)
- {
- VirtIOSCSI *s = VIRTIO_SCSI(vdev);
-
-- if (s->ctx) {
-- virtio_device_start_ioeventfd(vdev);
-- if (!s->dataplane_fenced) {
-- return;
-- }
-+ if (virtio_scsi_defer_to_dataplane(s)) {
-+ return;
- }
-+
- virtio_scsi_acquire(s);
- virtio_scsi_handle_event_vq(s, vq);
- virtio_scsi_release(s);
-GitLab
-
-From: Stefan Hajnoczi <stefanha@redhat.com>
-Date: Wed, 27 Apr 2022 15:35:37 +0100
-Subject: [PATCH] virtio-scsi: don't waste CPU polling the event virtqueue
-
-The virtio-scsi event virtqueue is not emptied by its handler function.
-This is typical for rx virtqueues where the device uses buffers when
-some event occurs (e.g. a packet is received, an error condition
-happens, etc).
-
-Polling non-empty virtqueues wastes CPU cycles. We are not waiting for
-new buffers to become available, we are waiting for an event to occur,
-so it's a misuse of CPU resources to poll for buffers.
-
-Introduce the new virtio_queue_aio_attach_host_notifier_no_poll() API,
-which is identical to virtio_queue_aio_attach_host_notifier() except
-that it does not poll the virtqueue.
-
-Before this patch the following command-line consumed 100% CPU in the
-IOThread polling and calling virtio_scsi_handle_event():
-
- $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \
- --object iothread,id=iothread0 \
- --device virtio-scsi-pci,iothread=iothread0 \
- --blockdev file,filename=test.img,aio=native,cache.direct=on,node-name=drive0 \
- --device scsi-hd,drive=drive0
-
-After this patch CPU is no longer wasted.
-
-Reported-by: Nir Soffer <nsoffer@redhat.com>
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-Tested-by: Nir Soffer <nsoffer@redhat.com>
-Message-id: 20220427143541.119567-3-stefanha@redhat.com
-Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---- a/hw/scsi/virtio-scsi-dataplane.c
-+++ b/hw/scsi/virtio-scsi-dataplane.c
-@@ -138,7 +138,7 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
-
- aio_context_acquire(s->ctx);
- virtio_queue_aio_attach_host_notifier(vs->ctrl_vq, s->ctx);
-- virtio_queue_aio_attach_host_notifier(vs->event_vq, s->ctx);
-+ virtio_queue_aio_attach_host_notifier_no_poll(vs->event_vq, s->ctx);
-
- for (i = 0; i < vs->conf.num_queues; i++) {
- virtio_queue_aio_attach_host_notifier(vs->cmd_vqs[i], s->ctx);
---- a/hw/virtio/virtio.c
-+++ b/hw/virtio/virtio.c
-@@ -3534,6 +3534,19 @@ void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx)
- virtio_queue_host_notifier_aio_poll_end);
- }
-
-+/*
-+ * Same as virtio_queue_aio_attach_host_notifier() but without polling. Use
-+ * this for rx virtqueues and similar cases where the virtqueue handler
-+ * function does not pop all elements. When the virtqueue is left non-empty
-+ * polling consumes CPU cycles and should not be used.
-+ */
-+void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx)
-+{
-+ aio_set_event_notifier(ctx, &vq->host_notifier, true,
-+ virtio_queue_host_notifier_read,
-+ NULL, NULL);
-+}
-+
- void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx)
- {
- aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL, NULL, NULL);
---- a/include/hw/virtio/virtio.h
-+++ b/include/hw/virtio/virtio.h
-@@ -317,6 +317,7 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
- void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled);
- void virtio_queue_host_notifier_read(EventNotifier *n);
- void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx);
-+void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx);
- void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);
- VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
- VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
-GitLab
diff --git a/app-emulation/qemu/files/qemu-7.1.0-capstone-include-path.patch b/app-emulation/qemu/files/qemu-7.1.0-capstone-include-path.patch
new file mode 100644
index 000000000000..585e798345f4
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-7.1.0-capstone-include-path.patch
@@ -0,0 +1,31 @@
+Forward ported from qemu-2.11.1-capstone_include_path.patch.
+This time also fix the capstone.h header check to use the path we're
+already patching in.
+
+Bug: https://bugs.gentoo.org/873157
+diff --git a/include/disas/capstone.h b/include/disas/capstone.h
+index e29068dd97..d8fdc5d537 100644
+--- a/include/disas/capstone.h
++++ b/include/disas/capstone.h
+@@ -3,7 +3,7 @@
+
+ #ifdef CONFIG_CAPSTONE
+
+-#include <capstone.h>
++#include <capstone/capstone.h>
+
+ #else
+
+diff --git a/meson.build b/meson.build
+index 20fddbd707..50ce96bbd1 100644
+--- a/meson.build
++++ b/meson.build
+@@ -2605,7 +2605,7 @@ if not get_option('capstone').auto() or have_system or have_user
+ # that reports a wrong -I path, causing the #include to
+ # fail later. If the system has such a broken version
+ # do not use it.
+- if capstone.found() and not cc.compiles('#include <capstone.h>',
++ if capstone.found() and not cc.compiles('#include <capstone/capstone.h>',
+ dependencies: [capstone])
+ capstone = not_found
+ if get_option('capstone').enabled()
diff --git a/app-emulation/qemu/files/qemu-7.1.0-strings.patch b/app-emulation/qemu/files/qemu-7.1.0-strings.patch
deleted file mode 100644
index 01f235b9a33c..000000000000
--- a/app-emulation/qemu/files/qemu-7.1.0-strings.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Forward-ported from original patch for 5.2.0.
-
-diff --git a/configure b/configure
-index da2501489f..4660ee3ee5 100755
---- a/configure
-+++ b/configure
-@@ -400,6 +400,7 @@ ld="${LD-${cross_prefix}ld}"
- nm="${NM-${cross_prefix}nm}"
- smbd="$SMBD"
- strip="${STRIP-${cross_prefix}strip}"
-+strings="${STRINGS-${cross_prefix}strings}"
- widl="${WIDL-${cross_prefix}widl}"
- windres="${WINDRES-${cross_prefix}windres}"
- pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
-@@ -1466,9 +1467,9 @@ int main(int argc, char *argv[])
- EOF
-
- if compile_prog ; then
-- if strings -a $TMPE | grep -q BiGeNdIaN ; then
-+ if $strings -a $TMPE | grep -q BiGeNdIaN ; then
- bigendian="yes"
-- elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
-+ elif $strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
- bigendian="no"
- else
- echo big/little test failed
diff --git a/app-emulation/qemu/files/qemu-7.2.0-disable-gmp.patch b/app-emulation/qemu/files/qemu-7.2.0-disable-gmp.patch
new file mode 100644
index 000000000000..3050228b4e0c
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-7.2.0-disable-gmp.patch
@@ -0,0 +1,45 @@
+commit 433c2acd1b9c3f7f5903273e85fed9a7f9157b23
+Author: John Helmert III <ajak@gentoo.org>
+Date: Wed Jan 4 12:25:08 2023 -0600
+
+ meson.build: disable gmp
+
+ gmp isn't required, and we want to avoid linking to it automatigcally
+ in Gentoo.
+
+ Bug: https://bugs.gentoo.org/886207
+ Signed-off-by: John Helmert III <ajak@gentoo.org>
+
+diff --git a/meson.build b/meson.build
+index 5c6b5a1c75..2f9550362d 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1234,15 +1234,6 @@ if not gnutls_crypto.found()
+ endif
+ endif
+
+-gmp = dependency('gmp', required: false, method: 'pkg-config', kwargs: static_kwargs)
+-if nettle.found() and gmp.found()
+- hogweed = dependency('hogweed', version: '>=3.4',
+- method: 'pkg-config',
+- required: get_option('nettle'),
+- kwargs: static_kwargs)
+-endif
+-
+-
+ gtk = not_found
+ gtkx11 = not_found
+ vte = not_found
+diff --git a/meson_options.txt b/meson_options.txt
+index 4b749ca549..e06b274960 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -277,6 +277,8 @@ option('vduse_blk_export', type: 'feature', value: 'auto',
+
+ option('capstone', type: 'feature', value: 'auto',
+ description: 'Whether and how to find the capstone library')
++option('gmp', type: 'feature', value: 'auto',
++ description: 'Whether or not to find the gmp library')
+ option('fdt', type: 'combo', value: 'auto',
+ choices: ['disabled', 'enabled', 'auto', 'system', 'internal'],
+ description: 'Whether and how to find the libfdt library')
diff --git a/app-emulation/qemu/files/qemu-7.2.0-linux-headers-6.2-glibc-2.36.patch b/app-emulation/qemu/files/qemu-7.2.0-linux-headers-6.2-glibc-2.36.patch
new file mode 100644
index 000000000000..2a58ca1ad735
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-7.2.0-linux-headers-6.2-glibc-2.36.patch
@@ -0,0 +1,137 @@
+https://bugs.gentoo.org/895662
+https://gitlab.com/qemu-project/qemu/-/commit/9f0246539ae84a5e21efd1cc4516fc343f08115a
+https://gitlab.com/qemu-project/qemu/-/commit/6003159ce18faad4e1bc7bf9c85669019cd4950e
+
+From 9f0246539ae84a5e21efd1cc4516fc343f08115a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
+Date: Tue, 10 Jan 2023 12:49:00 -0500
+Subject: [PATCH] Revert "linux-user: add more compat ioctl definitions"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This reverts commit c5495f4ecb0cdaaf2e9dddeb48f1689cdb520ca0.
+
+glibc has fixed (in 2.36.9000-40-g774058d729) the problem
+that caused a clash when both sys/mount.h annd linux/mount.h
+are included, and backported this to the 2.36 stable release
+too:
+
+ https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
+
+It is saner for QEMU to remove the workaround it applied for
+glibc 2.36 and expect distros to ship the 2.36 maint release
+with the fix. This avoids needing to add a further workaround
+to QEMU to deal with the fact that linux/brtfs.h now also pulls
+in linux/mount.h via linux/fs.h since Linux 6.1
+
+Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
+Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
+Message-Id: <20230110174901.2580297-2-berrange@redhat.com>
+Signed-off-by: Laurent Vivier <laurent@vivier.eu>
+--- a/linux-user/syscall.c
++++ b/linux-user/syscall.c
+@@ -111,31 +111,6 @@
+ #define FS_IOC32_SETFLAGS _IOW('f', 2, int)
+ #define FS_IOC32_GETVERSION _IOR('v', 1, int)
+ #define FS_IOC32_SETVERSION _IOW('v', 2, int)
+-
+-#define BLKGETSIZE64 _IOR(0x12,114,size_t)
+-#define BLKDISCARD _IO(0x12,119)
+-#define BLKIOMIN _IO(0x12,120)
+-#define BLKIOOPT _IO(0x12,121)
+-#define BLKALIGNOFF _IO(0x12,122)
+-#define BLKPBSZGET _IO(0x12,123)
+-#define BLKDISCARDZEROES _IO(0x12,124)
+-#define BLKSECDISCARD _IO(0x12,125)
+-#define BLKROTATIONAL _IO(0x12,126)
+-#define BLKZEROOUT _IO(0x12,127)
+-
+-#define FIBMAP _IO(0x00,1)
+-#define FIGETBSZ _IO(0x00,2)
+-
+-struct file_clone_range {
+- __s64 src_fd;
+- __u64 src_offset;
+- __u64 src_length;
+- __u64 dest_offset;
+-};
+-
+-#define FICLONE _IOW(0x94, 9, int)
+-#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range)
+-
+ #else
+ #include <linux/fs.h>
+ #endif
+--
+GitLab
+
+From 6003159ce18faad4e1bc7bf9c85669019cd4950e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
+Date: Tue, 10 Jan 2023 12:49:01 -0500
+Subject: [PATCH] Revert "linux-user: fix compat with glibc >= 2.36
+ sys/mount.h"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This reverts commit 3cd3df2a9584e6f753bb62a0028bd67124ab5532.
+
+glibc has fixed (in 2.36.9000-40-g774058d729) the problem
+that caused a clash when both sys/mount.h annd linux/mount.h
+are included, and backported this to the 2.36 stable release
+too:
+
+ https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
+
+It is saner for QEMU to remove the workaround it applied for
+glibc 2.36 and expect distros to ship the 2.36 maint release
+with the fix. This avoids needing to add a further workaround
+to QEMU to deal with the fact that linux/brtfs.h now also pulls
+in linux/mount.h via linux/fs.h since Linux 6.1
+
+Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
+Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
+Message-Id: <20230110174901.2580297-3-berrange@redhat.com>
+Signed-off-by: Laurent Vivier <laurent@vivier.eu>
+--- a/linux-user/syscall.c
++++ b/linux-user/syscall.c
+@@ -95,25 +95,7 @@
+ #include <linux/soundcard.h>
+ #include <linux/kd.h>
+ #include <linux/mtio.h>
+-
+-#ifdef HAVE_SYS_MOUNT_FSCONFIG
+-/*
+- * glibc >= 2.36 linux/mount.h conflicts with sys/mount.h,
+- * which in turn prevents use of linux/fs.h. So we have to
+- * define the constants ourselves for now.
+- */
+-#define FS_IOC_GETFLAGS _IOR('f', 1, long)
+-#define FS_IOC_SETFLAGS _IOW('f', 2, long)
+-#define FS_IOC_GETVERSION _IOR('v', 1, long)
+-#define FS_IOC_SETVERSION _IOW('v', 2, long)
+-#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
+-#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
+-#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
+-#define FS_IOC32_GETVERSION _IOR('v', 1, int)
+-#define FS_IOC32_SETVERSION _IOW('v', 2, int)
+-#else
+ #include <linux/fs.h>
+-#endif
+ #include <linux/fd.h>
+ #if defined(CONFIG_FIEMAP)
+ #include <linux/fiemap.h>
+--- a/meson.build
++++ b/meson.build
+@@ -2046,8 +2046,6 @@ config_host_data.set('HAVE_OPTRESET',
+ cc.has_header_symbol('getopt.h', 'optreset'))
+ config_host_data.set('HAVE_IPPROTO_MPTCP',
+ cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
+-config_host_data.set('HAVE_SYS_MOUNT_FSCONFIG',
+- cc.has_header_symbol('sys/mount.h', 'FSCONFIG_SET_FLAG'))
+
+ # has_member
+ config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
+--
+GitLab
diff --git a/app-emulation/qemu/files/qemu-8.0.0-disable-keymap.patch b/app-emulation/qemu/files/qemu-8.0.0-disable-keymap.patch
new file mode 100644
index 000000000000..6a5437056e6f
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-8.0.0-disable-keymap.patch
@@ -0,0 +1,29 @@
+diff --git a/meson.build b/meson.build
+index c44d05a13..5c5c09894 100644
+--- a/meson.build
++++ b/meson.build
+@@ -671,6 +671,8 @@ endif
+
+ if get_option('xkbcommon').auto() and not have_system and not have_tools
+ xkbcommon = not_found
++elif get_option('xkbcommon').disabled()
++ xkbcommon = not_found
+ else
+ xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
+ method: 'pkg-config', kwargs: static_kwargs)
+diff --git a/pc-bios/keymaps/meson.build b/pc-bios/keymaps/meson.build
+index 158a3b410..3bb318a23 100644
+--- a/pc-bios/keymaps/meson.build
++++ b/pc-bios/keymaps/meson.build
+@@ -33,8 +33,10 @@ keymaps = {
+ 'tr': '-l tr',
+ }
+
+-if meson.is_cross_build() or not xkbcommon.found()
++if meson.is_cross_build()
+ native_qemu_keymap = find_program('qemu-keymap', required: false, disabler: true)
++elif get_option('xkbcommon').disabled()
++ native_qemu_keymap = not_found
+ else
+ native_qemu_keymap = qemu_keymap
+ endif
diff --git a/app-emulation/qemu/files/qemu-8.0.0-make.patch b/app-emulation/qemu/files/qemu-8.0.0-make.patch
new file mode 100644
index 000000000000..40bafd490052
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-8.0.0-make.patch
@@ -0,0 +1,13 @@
+diff --git a/configure b/configure
+index 800b5850f..331e8950d 100755
+--- a/configure
++++ b/configure
+@@ -1069,7 +1069,7 @@ then
+ fi
+ fi
+
+-if ! has "$make"
++if ! has $make
+ then
+ error_exit "GNU make ($make) not found"
+ fi
diff --git a/app-emulation/qemu/files/qemu-8.0.0-remove-python-meson-check.patch b/app-emulation/qemu/files/qemu-8.0.0-remove-python-meson-check.patch
new file mode 100644
index 000000000000..07d3836c57e4
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-8.0.0-remove-python-meson-check.patch
@@ -0,0 +1,40 @@
+diff --git a/configure b/configure
+index 4369fa5..7807ad5 100755
+--- a/configure
++++ b/configure
+@@ -1095,34 +1095,7 @@ has_meson() {
+ fi
+ }
+
+-if test -z "$meson"; then
+- if test "$explicit_python" = no && has_meson && version_ge "$(meson --version)" 0.61.5; then
+- meson=meson
+- elif test "$git_submodules_action" != 'ignore' ; then
+- meson=git
+- elif test -e "${source_path}/meson/meson.py" ; then
+- meson=internal
+- else
+- if test "$explicit_python" = yes; then
+- error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
+- else
+- error_exit "Meson not found. Use --meson=/path/to/meson"
+- fi
+- fi
+-else
+- # Meson uses its own Python interpreter to invoke other Python scripts,
+- # but the user wants to use the one they specified with --python.
+- #
+- # We do not want to override the distro Python interpreter (and sometimes
+- # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
+- # just require --meson=git|internal together with --python.
+- if test "$explicit_python" = yes; then
+- case "$meson" in
+- git | internal) ;;
+- *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
+- esac
+- fi
+-fi
++meson=meson
+
+ if test "$meson" = git; then
+ git_submodules="${git_submodules} meson"
diff --git a/app-emulation/qemu/files/qemu-7.0.0-also-build-virtfs-proxy-helper.patch b/app-emulation/qemu/files/qemu-8.1.0-also-build-virtfs-proxy-helper.patch
index ca2e9433792c..61ea0f36d90a 100644
--- a/app-emulation/qemu/files/qemu-7.0.0-also-build-virtfs-proxy-helper.patch
+++ b/app-emulation/qemu/files/qemu-8.1.0-also-build-virtfs-proxy-helper.patch
@@ -1,4 +1,4 @@
-From c1093041466772f4b62961bcc5a354801d41355d Mon Sep 17 00:00:00 2001
+From d02ea89239768c93651a161d057f2bf04d56a024 Mon Sep 17 00:00:00 2001
From: Matthias Maier <tamiko@43-1.org>
Date: Mon, 4 Apr 2022 12:56:59 +0200
Subject: [PATCH] also build virtfs-proxy-helper
@@ -15,18 +15,18 @@ all, it is a tiny executable
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
-index 861de93c4f..a8d29be3aa 100644
+index 063c736aee..fda8639293 100644
--- a/meson.build
+++ b/meson.build
-@@ -1474,7 +1474,7 @@ have_virtfs = get_option('virtfs') \
- .disable_auto_if(not have_tools and not have_system) \
+@@ -2008,8 +2008,6 @@ have_virtfs = get_option('virtfs') \
.allowed()
--have_virtfs_proxy_helper = targetos != 'darwin' and have_virtfs and have_tools
-+have_virtfs_proxy_helper = have_tools and libattr.found() and libcap_ng.found()
-
- foreach k : get_option('trace_backends')
- config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)
+ have_virtfs_proxy_helper = get_option('virtfs_proxy_helper') \
+- .require(targetos != 'darwin', error_message: 'the virtfs proxy helper is incompatible with macOS') \
+- .require(have_virtfs, error_message: 'the virtfs proxy helper requires that virtfs is enabled') \
+ .disable_auto_if(not have_tools) \
+ .require(libcap_ng.found(), error_message: 'the virtfs proxy helper requires libcap-ng') \
+ .allowed()
--
2.35.1
diff --git a/app-emulation/qemu/files/qemu-8.1.0-find-sphinx.patch b/app-emulation/qemu/files/qemu-8.1.0-find-sphinx.patch
new file mode 100644
index 000000000000..b6ef6214af55
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-8.1.0-find-sphinx.patch
@@ -0,0 +1,10 @@
+This gets confused by python-any-r1 and tries to find sphinx-build in ${T}.
+--- a/docs/meson.build
++++ b/docs/meson.build
+@@ -1,5 +1,4 @@
+-sphinx_build = find_program(fs.parent(python.full_path()) / 'sphinx-build',
+- required: get_option('docs'))
++sphinx_build = find_program('sphinx-build', required: get_option('docs'))
+
+ # Check if tools are available to build documentation.
+ build_docs = false
diff --git a/app-emulation/qemu/files/qemu-8.1.0-skip-tests.patch b/app-emulation/qemu/files/qemu-8.1.0-skip-tests.patch
new file mode 100644
index 000000000000..f668584e8d4b
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-8.1.0-skip-tests.patch
@@ -0,0 +1,64 @@
+* netdev-socket.c
+qtest-i386/netdev-socket fails with:
+```
+stderr:
+qemu-system-i386: -netdev dgram,id=st0,remote.type=inet,remote.host=230.0.0.1,remote.port=1234: can't add socket to multicast group 230.0.0.1: No such device
+Broken pipe
+../tests/qtest/libqtest.c:191: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
+```
+
+* vhost-user-test.c
+qtest-x86_64/qos-test fails with a timeout:
+```
+qemu-system-x86_64: Failed to set msg fds.
+qemu-system-x86_64: vhost VQ 0 ring restore failed: -22: Invalid argument (22)
+qemu-system-x86_64: Failed to set msg fds.
+qemu-system-x86_64: vhost VQ 1 ring restore failed: -22: Invalid argument (22)
+**
+ERROR:../tests/qtest/vhost-user-test.c:892:wait_for_rings_started: assertion failed (ctpop64(s->rings) == count): (1 == 2)
+**
+ERROR:../tests/qtest/qos-test.c:191:subprocess_run_one_test: child process (/x86_64/pc/i440FX-pcihost/pci-bus-pc/pci-bus/virtio-net-pci/virtio-net/virtio-net-tests/vhost-user/reconnect/subprocess [6082]) failed unexpectedl
+```
+
+--- a/tests/qtest/netdev-socket.c
++++ b/tests/qtest/netdev-socket.c
+@@ -498,6 +498,10 @@ int main(int argc, char **argv)
+ socket_init();
+ g_test_init(&argc, &argv, NULL);
+
++ /* XXX: Skip test for now on Gentoo, fails with "No such device" */
++ g_test_skip("Skipping test known to fail on Gentoo");
++ return 0;
++
+ if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) {
+ g_error("socket_check_protocol_support() failed\n");
+ }
+--- a/tests/qtest/vhost-user-test.c
++++ b/tests/qtest/vhost-user-test.c
+@@ -243,7 +243,7 @@ static bool wait_for_fds(TestServer *s)
+
+ g_mutex_lock(&s->data_mutex);
+
+- end_time = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND;
++ end_time = g_get_monotonic_time() + 30 * G_TIME_SPAN_SECOND;
+ while (!s->fds_num) {
+ if (!g_cond_wait_until(&s->data_cond, &s->data_mutex, end_time)) {
+ /* timeout has passed */
+@@ -672,7 +672,7 @@ static void wait_for_log_fd(TestServer *s)
+ gint64 end_time;
+
+ g_mutex_lock(&s->data_mutex);
+- end_time = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND;
++ end_time = g_get_monotonic_time() + 30 * G_TIME_SPAN_SECOND;
+ while (s->log_fd == -1) {
+ if (!g_cond_wait_until(&s->data_cond, &s->data_mutex, end_time)) {
+ /* timeout has passed */
+@@ -885,7 +885,7 @@ static void wait_for_rings_started(TestServer *s, size_t count)
+ gint64 end_time;
+
+ g_mutex_lock(&s->data_mutex);
+- end_time = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND;
++ end_time = g_get_monotonic_time() + 30 * G_TIME_SPAN_SECOND;
+ while (ctpop64(s->rings) != count) {
+ if (!g_cond_wait_until(&s->data_cond, &s->data_mutex, end_time)) {
+ /* timeout has passed */
diff --git a/app-emulation/qemu/files/qemu-9.0.0-also-build-virtfs-proxy-helper.patch b/app-emulation/qemu/files/qemu-9.0.0-also-build-virtfs-proxy-helper.patch
new file mode 100644
index 000000000000..603d20c42fc8
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-9.0.0-also-build-virtfs-proxy-helper.patch
@@ -0,0 +1,35 @@
+From 951325a0c9519d4910d80cc6c7a5728c0dbc4946 Mon Sep 17 00:00:00 2001
+Message-ID: <951325a0c9519d4910d80cc6c7a5728c0dbc4946.1714317553.git.mprivozn@redhat.com>
+From: Matthias Maier <tamiko@43-1.org>
+Date: Mon, 4 Apr 2022 12:56:59 +0200
+Subject: [PATCH] also build virtfs-proxy-helper
+
+The Gentoo ebuild splits the qemu build into a softmmu, user and tool
+phase in order to be able to build and link some of the qemu emulators
+statically. This unfortunately has the consequence that we never
+configure with "have_virtfs" and "have_tools" at the same time.
+
+As a workaround, simply build the virtfs userland unconditionally. After
+all, it is a tiny executable.
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+---
+ meson.build | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index c3a2be7b2d..50a5cfcf4e 100644
+--- a/meson.build
++++ b/meson.build
+@@ -2116,8 +2116,6 @@ have_virtfs = get_option('virtfs') \
+ .allowed()
+
+ have_virtfs_proxy_helper = get_option('virtfs_proxy_helper') \
+- .require(host_os != 'darwin', error_message: 'the virtfs proxy helper is incompatible with macOS') \
+- .require(have_virtfs, error_message: 'the virtfs proxy helper requires that virtfs is enabled') \
+ .disable_auto_if(not have_tools) \
+ .require(libcap_ng.found(), error_message: 'the virtfs proxy helper requires libcap-ng') \
+ .allowed()
+--
+2.43.2
+
diff --git a/app-emulation/qemu/files/qemu-9.0.0-capstone-include-path.patch b/app-emulation/qemu/files/qemu-9.0.0-capstone-include-path.patch
new file mode 100644
index 000000000000..3e0408d6b213
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-9.0.0-capstone-include-path.patch
@@ -0,0 +1,42 @@
+From 67a8b35e98f5c0853f7cdf26db0ebc6ce20b929c Mon Sep 17 00:00:00 2001
+Message-ID: <67a8b35e98f5c0853f7cdf26db0ebc6ce20b929c.1714317553.git.mprivozn@redhat.com>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Sun, 28 Apr 2024 17:10:46 +0200
+Subject: [PATCH] Forward ported from qemu-7.1.0-capstone-include-path.patch.
+
+Bug: https://bugs.gentoo.org/873157
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+---
+ include/disas/capstone.h | 2 +-
+ meson.build | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/include/disas/capstone.h b/include/disas/capstone.h
+index e29068dd97..d8fdc5d537 100644
+--- a/include/disas/capstone.h
++++ b/include/disas/capstone.h
+@@ -3,7 +3,7 @@
+
+ #ifdef CONFIG_CAPSTONE
+
+-#include <capstone.h>
++#include <capstone/capstone.h>
+
+ #else
+
+diff --git a/meson.build b/meson.build
+index ea3ccff968..c3a2be7b2d 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1712,7 +1712,7 @@ if not get_option('capstone').auto() or have_system or have_user
+ # that reports a wrong -I path, causing the #include to
+ # fail later. If the system has such a broken version
+ # do not use it.
+- if capstone.found() and not cc.compiles('#include <capstone.h>',
++ if capstone.found() and not cc.compiles('#include <capstone/capstone.h>',
+ dependencies: [capstone])
+ capstone = not_found
+ if get_option('capstone').enabled()
+--
+2.43.2
+
diff --git a/app-emulation/qemu/files/qemu-9.0.0-disable-keymap.patch b/app-emulation/qemu/files/qemu-9.0.0-disable-keymap.patch
new file mode 100644
index 000000000000..c85d213626e2
--- /dev/null
+++ b/app-emulation/qemu/files/qemu-9.0.0-disable-keymap.patch
@@ -0,0 +1,44 @@
+From 8cca781563e89facd312d622a69af124eb2757c6 Mon Sep 17 00:00:00 2001
+Message-ID: <8cca781563e89facd312d622a69af124eb2757c6.1714317553.git.mprivozn@redhat.com>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Sun, 28 Apr 2024 17:10:13 +0200
+Subject: [PATCH] 8.0.0-disable-keymap.patch
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+---
+ meson.build | 2 ++
+ pc-bios/keymaps/meson.build | 4 +++-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 5db2dbc12e..ea3ccff968 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1098,6 +1098,8 @@ endif
+
+ if get_option('xkbcommon').auto() and not have_system and not have_tools
+ xkbcommon = not_found
++elif get_option('xkbcommon').disabled()
++ xkbcommon = not_found
+ else
+ xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
+ method: 'pkg-config')
+diff --git a/pc-bios/keymaps/meson.build b/pc-bios/keymaps/meson.build
+index 0bd8ce0077..3888f4c64f 100644
+--- a/pc-bios/keymaps/meson.build
++++ b/pc-bios/keymaps/meson.build
+@@ -33,8 +33,10 @@ keymaps = {
+ 'tr': '-l tr',
+ }
+
+-if meson.is_cross_build() or not xkbcommon.found()
++if meson.is_cross_build()
+ native_qemu_keymap = find_program('qemu-keymap', required: false, disabler: true)
++elif get_option('xkbcommon').disabled()
++ native_qemu_keymap = not_found
+ else
+ native_qemu_keymap = qemu_keymap
+ endif
+--
+2.43.2
+
diff --git a/app-emulation/qemu/metadata.xml b/app-emulation/qemu/metadata.xml
index 5fbcd7706e9c..adb556795249 100644
--- a/app-emulation/qemu/metadata.xml
+++ b/app-emulation/qemu/metadata.xml
@@ -1,26 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
- <maintainer type="person">
- <email>ajak@gentoo.org</email>
- <name>John Helmert III</name>
- </maintainer>
- <maintainer type="person">
- <email>sam@gentoo.org</email>
- <name>Sam James</name>
- </maintainer>
- <maintainer type="person">
- <email>tamiko@gentoo.org</email>
- <name>Matthias Maier</name>
- </maintainer>
- <maintainer type="person">
- <email>zlogene@gentoo.org</email>
- <name>Mikle Kolyada</name>
- </maintainer>
<maintainer type="project">
<email>virtualization@gentoo.org</email>
<name>Gentoo Virtualization Project</name>
</maintainer>
+ <maintainer type="person">
+ <email>dilfridge@gentoo.org</email>
+ <name>Andreas K. Hüttel</name>
+ </maintainer>
<use>
<flag name="accessibility">Adds support for braille displays using brltty</flag>
<flag name="aio">Enables support for Linux's Async IO</flag>
@@ -39,6 +27,7 @@
<pkg>net-libs/libiscsi</pkg> instead of indirectly via the Linux
block layer that <pkg>sys-block/open-iscsi</pkg> does.</flag>
<flag name="io-uring">Enable efficient I/O via <pkg>sys-libs/liburing</pkg>.</flag>
+ <flag name="keyutils">Support Linux keyrings via <pkg>sys-apps/keyutils</pkg></flag>
<flag name="multipath">Enable multipath persistent reservation passthrough via
<pkg>sys-fs/multipath-tools</pkg>.</flag>
<flag name="ncurses">Enable the ncurses-based console</flag>
@@ -47,6 +36,7 @@
<flag name="pin-upstream-blobs">Pin the versions of BIOS firmware to the version included in the upstream release.
This is needed to sanely support migration/suspend/resume/snapshotting/etc... of instances.
When the blobs are different, random corruption/bugs/crashes/etc... may be observed.</flag>
+ <flag name="pipewire">Enable pipewire output for sound emulation</flag>
<flag name="plugins">Enable qemu plugin API via shared library loading.</flag>
<flag name="pulseaudio">Enable pulseaudio output for sound emulation</flag>
<flag name="rbd">Enable rados block device backend support, see https://docs.ceph.com/en/mimic/rbd/qemu-rbd/</flag>
@@ -65,7 +55,6 @@
<flag name="usbredir">Use <pkg>sys-apps/usbredir</pkg> to redirect USB devices to another machine over TCP</flag>
<flag name="vde">Enable VDE-based networking</flag>
<flag name="vhost-net">Enable accelerated networking using vhost-net, see https://www.linux-kvm.org/page/VhostNet</flag>
- <flag name="vhost-user-fs">Enable shared file system access using the FUSE protocol carried over virtio.</flag>
<flag name="virgl">Enable experimental Virgil 3d (virtual software GPU)</flag>
<flag name="virtfs">Enable VirtFS via virtio-9p-pci / fsdev. See https://wiki.qemu.org/Documentation/9psetup</flag>
<flag name="vte">Enable terminal support (<pkg>x11-libs/vte</pkg>) in the GTK+ interface</flag>
@@ -73,4 +62,7 @@
<pkg>sys-apps/attr</pkg>. Requisite for the virtfs backend.</flag>
<flag name="xen">Enables support for Xen backends</flag>
</use>
+ <upstream>
+ <remote-id type="gitlab">qemu-project/qemu</remote-id>
+ </upstream>
</pkgmetadata>
diff --git a/app-emulation/qemu/qemu-7.0.0-r2.ebuild b/app-emulation/qemu/qemu-7.2.11.ebuild
index f048b6385812..e59ab048ded1 100644
--- a/app-emulation/qemu/qemu-7.0.0-r2.ebuild
+++ b/app-emulation/qemu/qemu-7.2.11.ebuild
@@ -1,20 +1,31 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-PYTHON_COMPAT=( python3_{8,9,10} )
+# Generate using https://github.com/thesamesam/sam-gentoo-scripts/blob/main/niche/generate-qemu-docs
+# Set to 1 if prebuilt, 0 if not
+# (the construct below is to allow overriding from env for script)
+QEMU_DOCS_PREBUILT=${QEMU_DOCS_PREBUILT:-1}
+QEMU_DOCS_PREBUILT_DEV=ajak
+QEMU_DOCS_VERSION="7.2.0"
+# Default to generating docs (inc. man pages) if no prebuilt; overridden later
+# bug #830088
+QEMU_DOC_USEFLAG="+doc"
+
+PYTHON_COMPAT=( python3_{10,11} )
PYTHON_REQ_USE="ncurses,readline"
-FIRMWARE_ABI_VERSION="7.0.0"
+FIRMWARE_ABI_VERSION="7.2.0"
inherit linux-info toolchain-funcs python-r1 udev fcaps readme.gentoo-r1 \
pax-utils xdg-utils
if [[ ${PV} == *9999* ]]; then
+ QEMU_DOCS_PREBUILT=0
+
EGIT_REPO_URI="https://gitlab.com/qemu-project/qemu.git/"
EGIT_SUBMODULES=(
- meson
tests/fp/berkeley-softfloat-3
tests/fp/berkeley-testfloat-3
ui/keycodemapdb
@@ -24,8 +35,13 @@ if [[ ${PV} == *9999* ]]; then
else
MY_P="${PN}-${PV/_rc/-rc}"
SRC_URI="https://download.qemu.org/${MY_P}.tar.xz"
- KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
+
+ if [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ SRC_URI+=" !doc? ( https://dev.gentoo.org/~${QEMU_DOCS_PREBUILT_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${QEMU_DOCS_VERSION}-docs.tar.xz )"
+ fi
+
S="${WORKDIR}/${MY_P}"
+ [[ "${PV}" != *_rc* ]] && KEYWORDS="amd64 ~arm arm64 ~loong ~ppc ppc64 ~riscv x86"
fi
DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
@@ -34,7 +50,9 @@ HOMEPAGE="https://www.qemu.org https://www.linux-kvm.org"
LICENSE="GPL-2 LGPL-2 BSD-2"
SLOT="0"
-IUSE="accessibility +aio alsa bpf bzip2 capstone +caps +curl debug +doc
+[[ ${QEMU_DOCS_PREBUILT} == 1 ]] && QEMU_DOC_USEFLAG="doc"
+
+IUSE="accessibility +aio alsa bpf bzip2 capstone +curl debug ${QEMU_DOC_USEFLAG}
+fdt fuse glusterfs +gnutls gtk infiniband iscsi io-uring
jack jemalloc +jpeg
lzo multipath
@@ -42,7 +60,7 @@ IUSE="accessibility +aio alsa bpf bzip2 capstone +caps +curl debug +doc
plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
+slirp
smartcard snappy spice ssh static static-user systemtap test udev usb
- usbredir vde +vhost-net vhost-user-fs virgl virtfs +vnc vte xattr xen
+ usbredir vde +vhost-net virgl virtfs +vnc vte xattr xen
zstd"
COMMON_TARGETS="
@@ -52,6 +70,7 @@ COMMON_TARGETS="
cris
hppa
i386
+ loongarch64
m68k
microblaze
microblazeel
@@ -96,9 +115,11 @@ use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
RESTRICT="!test? ( test )"
+
# Allow no targets to be built so that people can get a tools-only build.
# Block USE flag configurations known to not work.
-REQUIRED_USE="${PYTHON_REQUIRED_USE}
+REQUIRED_USE="
+ ${PYTHON_REQUIRED_USE}
qemu_softmmu_targets_arm? ( fdt )
qemu_softmmu_targets_microblaze? ( fdt )
qemu_softmmu_targets_mips64el? ( fdt )
@@ -110,14 +131,16 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}
sdl-image? ( sdl )
static? ( static-user !alsa !gtk !jack !opengl !pam !pulseaudio !plugins !rbd !snappy !udev )
static-user? ( !plugins )
- vhost-user-fs? ( caps seccomp )
virgl? ( opengl )
- virtfs? ( caps xattr )
+ virtfs? ( xattr )
vnc? ( gnutls )
vte? ( gtk )
multipath? ( udev )
plugins? ( !static !static-user )
"
+for smname in ${IUSE_SOFTMMU_TARGETS} ; do
+ REQUIRED_USE+=" qemu_softmmu_targets_${smname}? ( seccomp ) "
+done
# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
# and user/softmmu targets (qemu-*, qemu-system-*).
@@ -128,15 +151,16 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}
# respected). This is because qemu supports using the C library's API
# when available rather than always using the external library.
ALL_DEPEND="
- >=dev-libs/glib-2.0[static-libs(+)]
+ dev-libs/glib:2[static-libs(+)]
sys-libs/zlib[static-libs(+)]
python? ( ${PYTHON_DEPS} )
- systemtap? ( dev-util/systemtap )
+ systemtap? ( dev-debug/systemtap )
xattr? ( sys-apps/attr[static-libs(+)] )"
# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
# softmmu targets (qemu-system-*).
SOFTMMU_TOOLS_DEPEND="
+ sys-libs/libcap-ng[static-libs(+)]
>=x11-libs/pixman-0.28.0[static-libs(+)]
accessibility? (
app-accessibility/brltty[api]
@@ -146,18 +170,20 @@ SOFTMMU_TOOLS_DEPEND="
alsa? ( >=media-libs/alsa-lib-1.0.13 )
bpf? ( dev-libs/libbpf:= )
bzip2? ( app-arch/bzip2[static-libs(+)] )
- capstone? ( dev-libs/capstone:= )
- caps? ( sys-libs/libcap-ng[static-libs(+)] )
+ capstone? ( dev-libs/capstone:=[static-libs(+)] )
curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
fdt? ( >=sys-apps/dtc-1.5.1[static-libs(+)] )
fuse? ( >=sys-fs/fuse-3.1:3[static-libs(+)] )
glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
gnutls? (
- dev-libs/nettle:=[static-libs(+)]
>=net-libs/gnutls-3.0:=[static-libs(+)]
+ dev-libs/nettle:=[static-libs(+)]
)
gtk? (
+ x11-libs/cairo
+ x11-libs/gdk-pixbuf:2
x11-libs/gtk+:3
+ x11-libs/libX11
vte? ( x11-libs/vte:2.91 )
)
infiniband? ( sys-cluster/rdma-core[static-libs(+)] )
@@ -182,7 +208,7 @@ SOFTMMU_TOOLS_DEPEND="
)
pam? ( sys-libs/pam )
png? ( media-libs/libpng:0=[static-libs(+)] )
- pulseaudio? ( media-sound/pulseaudio )
+ pulseaudio? ( media-libs/libpulse )
rbd? ( sys-cluster/ceph )
sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
sdl? (
@@ -200,7 +226,7 @@ SOFTMMU_TOOLS_DEPEND="
)
ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
udev? ( virtual/libudev:= )
- usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
+ usb? ( >=virtual/libusb-1-r2:1[static-libs(+)] )
usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
vde? ( net-misc/vde[static-libs(+)] )
virgl? ( media-libs/virglrenderer[static-libs(+)] )
@@ -209,44 +235,54 @@ SOFTMMU_TOOLS_DEPEND="
zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
"
-EDK2_OVMF_VERSION="202105"
-SEABIOS_VERSION="1.14.0"
+EDK2_OVMF_VERSION="202202"
+SEABIOS_VERSION="1.16.0"
X86_FIRMWARE_DEPEND="
pin-upstream-blobs? (
- ~sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}[binary]
+ ~sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
~sys-firmware/ipxe-1.21.1[binary,qemu]
- ~sys-firmware/seabios-${SEABIOS_VERSION}[binary,seavgabios]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
~sys-firmware/sgabios-0.1_pre10[binary]
)
!pin-upstream-blobs? (
- >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ || (
+ >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ >=sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ )
sys-firmware/ipxe[qemu]
- >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
sys-firmware/sgabios
)"
PPC_FIRMWARE_DEPEND="
pin-upstream-blobs? (
- ~sys-firmware/seabios-${SEABIOS_VERSION}[binary,seavgabios]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
)
!pin-upstream-blobs? (
- >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
)
"
BDEPEND="
$(python_gen_impl_dep)
dev-lang/perl
+ dev-build/meson
sys-apps/texinfo
virtual/pkgconfig
doc? (
dev-python/sphinx[${PYTHON_USEDEP}]
- dev-python/sphinx_rtd_theme[${PYTHON_USEDEP}]
+ dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
)
gtk? ( nls? ( sys-devel/gettext ) )
test? (
dev-libs/glib[utils]
- sys-devel/bc
+ app-alternatives/bc
)
"
CDEPEND="
@@ -274,13 +310,11 @@ RDEPEND="${CDEPEND}
)"
PATCHES=(
- "${FILESDIR}"/${PN}-2.11.1-capstone_include_path.patch
"${FILESDIR}"/${PN}-5.2.0-disable-keymap.patch
"${FILESDIR}"/${PN}-6.0.0-make.patch
- "${FILESDIR}"/${PN}-6.1.0-strings.patch
- "${FILESDIR}"/${PN}-7.0.0-also-build-virtfs-proxy-helper.patch
- "${FILESDIR}"/${P}-virtio-scsi-fixes.patch
- "${FILESDIR}"/${P}-pci-overflow-fortify-source-3.patch
+ "${FILESDIR}"/${PN}-7.1.0-also-build-virtfs-proxy-helper.patch
+ "${FILESDIR}"/${PN}-7.1.0-capstone-include-path.patch
+ "${FILESDIR}"/${PN}-7.2.0-disable-gmp.patch
)
QA_PREBUILT="
@@ -425,8 +459,8 @@ src_prepare() {
# drop it. No change to level of protection b/c we patch our toolchain.
sed -i -e 's/-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2//' configure || die
- # Remove bundled copy of libfdt
- rm -r dtc || die
+ # Remove bundled modules
+ rm -r dtc meson roms/*/ || die
}
##
@@ -471,7 +505,6 @@ qemu_src_configure() {
# are enabled), but it's not really worth the hassle. Disable it
# all the time to avoid automatically detecting it. #568856
--disable-gcrypt
- --python="${PYTHON}"
--cc="$(tc-getCC)"
--cxx="$(tc-getCXX)"
--host-cc="$(tc-getBUILD_CC)"
@@ -526,7 +559,6 @@ qemu_src_configure() {
$(conf_softmmu bpf)
$(conf_notuser bzip2)
$(conf_notuser capstone)
- $(conf_notuser caps cap-ng)
$(conf_notuser curl)
$(conf_tools doc docs)
$(conf_notuser fdt)
@@ -548,13 +580,13 @@ qemu_src_configure() {
$(conf_notuser numa)
$(conf_notuser opengl)
$(conf_notuser pam auth-pam)
- $(conf_notuser png vnc-png)
+ $(conf_notuser png)
$(conf_notuser rbd)
$(conf_notuser sasl vnc-sasl)
$(conf_notuser sdl)
$(conf_softmmu sdl-image)
$(conf_notuser seccomp)
- $(conf_notuser slirp slirp system)
+ $(conf_notuser slirp)
$(conf_notuser smartcard)
$(conf_notuser snappy)
$(conf_notuser spice)
@@ -564,8 +596,6 @@ qemu_src_configure() {
$(conf_notuser usbredir usb-redir)
$(conf_notuser vde)
$(conf_notuser vhost-net)
- $(conf_notuser vhost-user-fs)
- $(conf_tools vhost-user-fs virtiofsd)
$(conf_notuser virgl virglrenderer)
$(conf_softmmu virtfs)
$(conf_notuser vnc)
@@ -600,6 +630,8 @@ qemu_src_configure() {
--disable-system
--disable-blobs
--disable-tools
+ --disable-cap-ng
+ --disable-seccomp
)
local static_flag="static-user"
;;
@@ -608,6 +640,8 @@ qemu_src_configure() {
--disable-linux-user
--enable-system
--disable-tools
+ --enable-cap-ng
+ --enable-seccomp
)
local static_flag="static"
;;
@@ -617,6 +651,7 @@ qemu_src_configure() {
--disable-system
--disable-blobs
--enable-tools
+ --enable-cap-ng
)
local static_flag="static"
;;
@@ -796,6 +831,11 @@ src_install() {
cd "${S}/tools-build" || die
emake DESTDIR="${ED}" install
+ # If USE=doc, there'll be newly generated docs which we install instead.
+ if ! use doc && [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ doman "${WORKDIR}"/${PN}-${QEMU_DOCS_VERSION}-docs/docs/*.[0-8]
+ fi
+
# Disable mprotect on the qemu binaries as they use JITs to be fast #459348
pushd "${ED}"/usr/bin >/dev/null || die
pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
@@ -814,10 +854,7 @@ src_install() {
if [[ -n ${softmmu_targets} ]]; then
# Remove SeaBIOS since we're using the SeaBIOS packaged one
- rm "${ED}/usr/share/qemu/bios.bin"
- rm "${ED}/usr/share/qemu/bios-256k.bin"
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
- dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
fi
@@ -828,6 +865,7 @@ src_install() {
rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
+
# PPC/PPC64 loads vgabios-stdvga
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64; then
dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
@@ -839,13 +877,11 @@ src_install() {
fi
# Remove sgabios since we're using the sgabios packaged one
- rm "${ED}/usr/share/qemu/sgabios.bin"
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
fi
# Remove iPXE since we're using the iPXE packaged one
- rm "${ED}"/usr/share/qemu/pxe-*.rom
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
@@ -885,9 +921,20 @@ pkg_postinst() {
if use pin-upstream-blobs && firmware_abi_change; then
ewarn "This version of qemu pins new versions of firmware blobs:"
- ewarn " $(best_version sys-firmware/edk2-ovmf)"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ ewarn " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ ewarn " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ ewarn " $(best_version sys-firmware/seabios-bin)"
+ else
+ ewarn " $(best_version sys-firmware/seabios)"
+ fi
+
ewarn " $(best_version sys-firmware/ipxe)"
- ewarn " $(best_version sys-firmware/seabios)"
ewarn " $(best_version sys-firmware/sgabios)"
ewarn "This might break resume of hibernated guests (started with a different"
ewarn "firmware version) and live migration to/from qemu versions with different"
@@ -901,22 +948,24 @@ pkg_postinst() {
pkg_info() {
echo "Using:"
echo " $(best_version app-emulation/spice-protocol)"
- echo " $(best_version sys-firmware/edk2-ovmf)"
- if has_version 'sys-firmware/edk2-ovmf[binary]'; then
- echo " USE=binary"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ echo " $(best_version sys-firmware/edk2-ovmf-bin)"
else
- echo " USE=''"
+ echo " $(best_version sys-firmware/edk2-ovmf)"
fi
- echo " $(best_version sys-firmware/ipxe)"
- echo " $(best_version sys-firmware/seabios)"
- if has_version 'sys-firmware/seabios[binary]'; then
- echo " USE=binary"
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ echo " $(best_version sys-firmware/seabios-bin)"
else
- echo " USE=''"
+ echo " $(best_version sys-firmware/seabios)"
fi
+
+ echo " $(best_version sys-firmware/ipxe)"
echo " $(best_version sys-firmware/sgabios)"
}
pkg_postrm() {
xdg_icon_cache_update
+ udev_reload
}
diff --git a/app-emulation/qemu/qemu-7.0.0-r1.ebuild b/app-emulation/qemu/qemu-7.2.4.ebuild
index 10bff2d0b799..ecb35f27987f 100644
--- a/app-emulation/qemu/qemu-7.0.0-r1.ebuild
+++ b/app-emulation/qemu/qemu-7.2.4.ebuild
@@ -1,20 +1,31 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-PYTHON_COMPAT=( python3_{8,9,10} )
+# Generate using https://github.com/thesamesam/sam-gentoo-scripts/blob/main/niche/generate-qemu-docs
+# Set to 1 if prebuilt, 0 if not
+# (the construct below is to allow overriding from env for script)
+QEMU_DOCS_PREBUILT=${QEMU_DOCS_PREBUILT:-1}
+QEMU_DOCS_PREBUILT_DEV=ajak
+QEMU_DOCS_VERSION="7.2.0"
+# Default to generating docs (inc. man pages) if no prebuilt; overridden later
+# bug #830088
+QEMU_DOC_USEFLAG="+doc"
+
+PYTHON_COMPAT=( python3_{10,11} )
PYTHON_REQ_USE="ncurses,readline"
-FIRMWARE_ABI_VERSION="7.0.0"
+FIRMWARE_ABI_VERSION="7.2.0"
inherit linux-info toolchain-funcs python-r1 udev fcaps readme.gentoo-r1 \
pax-utils xdg-utils
-if [[ ${PV} = *9999* ]]; then
+if [[ ${PV} == *9999* ]]; then
+ QEMU_DOCS_PREBUILT=0
+
EGIT_REPO_URI="https://gitlab.com/qemu-project/qemu.git/"
EGIT_SUBMODULES=(
- meson
tests/fp/berkeley-softfloat-3
tests/fp/berkeley-testfloat-3
ui/keycodemapdb
@@ -24,8 +35,13 @@ if [[ ${PV} = *9999* ]]; then
else
MY_P="${PN}-${PV/_rc/-rc}"
SRC_URI="https://download.qemu.org/${MY_P}.tar.xz"
- KEYWORDS="amd64 ~arm arm64 ~loong ~ppc ppc64 ~riscv x86"
+
+ if [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ SRC_URI+=" !doc? ( https://dev.gentoo.org/~${QEMU_DOCS_PREBUILT_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${QEMU_DOCS_VERSION}-docs.tar.xz )"
+ fi
+
S="${WORKDIR}/${MY_P}"
+ [[ "${PV}" != *_rc* ]] && KEYWORDS="amd64 ~arm arm64 ~loong ~ppc ppc64 ~riscv x86"
fi
DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
@@ -34,7 +50,9 @@ HOMEPAGE="https://www.qemu.org https://www.linux-kvm.org"
LICENSE="GPL-2 LGPL-2 BSD-2"
SLOT="0"
-IUSE="accessibility +aio alsa bpf bzip2 capstone +caps +curl debug +doc
+[[ ${QEMU_DOCS_PREBUILT} == 1 ]] && QEMU_DOC_USEFLAG="doc"
+
+IUSE="accessibility +aio alsa bpf bzip2 capstone +curl debug ${QEMU_DOC_USEFLAG}
+fdt fuse glusterfs +gnutls gtk infiniband iscsi io-uring
jack jemalloc +jpeg
lzo multipath
@@ -42,7 +60,7 @@ IUSE="accessibility +aio alsa bpf bzip2 capstone +caps +curl debug +doc
plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
+slirp
smartcard snappy spice ssh static static-user systemtap test udev usb
- usbredir vde +vhost-net vhost-user-fs virgl virtfs +vnc vte xattr xen
+ usbredir vde +vhost-net virgl virtfs +vnc vte xattr xen
zstd"
COMMON_TARGETS="
@@ -52,6 +70,7 @@ COMMON_TARGETS="
cris
hppa
i386
+ loongarch64
m68k
microblaze
microblazeel
@@ -96,9 +115,11 @@ use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
RESTRICT="!test? ( test )"
+
# Allow no targets to be built so that people can get a tools-only build.
# Block USE flag configurations known to not work.
-REQUIRED_USE="${PYTHON_REQUIRED_USE}
+REQUIRED_USE="
+ ${PYTHON_REQUIRED_USE}
qemu_softmmu_targets_arm? ( fdt )
qemu_softmmu_targets_microblaze? ( fdt )
qemu_softmmu_targets_mips64el? ( fdt )
@@ -110,14 +131,16 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}
sdl-image? ( sdl )
static? ( static-user !alsa !gtk !jack !opengl !pam !pulseaudio !plugins !rbd !snappy !udev )
static-user? ( !plugins )
- vhost-user-fs? ( caps seccomp )
virgl? ( opengl )
- virtfs? ( caps xattr )
+ virtfs? ( xattr )
vnc? ( gnutls )
vte? ( gtk )
multipath? ( udev )
plugins? ( !static !static-user )
"
+for smname in ${IUSE_SOFTMMU_TARGETS} ; do
+ REQUIRED_USE+=" qemu_softmmu_targets_${smname}? ( seccomp ) "
+done
# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
# and user/softmmu targets (qemu-*, qemu-system-*).
@@ -128,15 +151,16 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}
# respected). This is because qemu supports using the C library's API
# when available rather than always using the external library.
ALL_DEPEND="
- >=dev-libs/glib-2.0[static-libs(+)]
+ dev-libs/glib:2[static-libs(+)]
sys-libs/zlib[static-libs(+)]
python? ( ${PYTHON_DEPS} )
- systemtap? ( dev-util/systemtap )
+ systemtap? ( dev-debug/systemtap )
xattr? ( sys-apps/attr[static-libs(+)] )"
# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
# softmmu targets (qemu-system-*).
SOFTMMU_TOOLS_DEPEND="
+ sys-libs/libcap-ng[static-libs(+)]
>=x11-libs/pixman-0.28.0[static-libs(+)]
accessibility? (
app-accessibility/brltty[api]
@@ -146,18 +170,20 @@ SOFTMMU_TOOLS_DEPEND="
alsa? ( >=media-libs/alsa-lib-1.0.13 )
bpf? ( dev-libs/libbpf:= )
bzip2? ( app-arch/bzip2[static-libs(+)] )
- capstone? ( dev-libs/capstone:= )
- caps? ( sys-libs/libcap-ng[static-libs(+)] )
+ capstone? ( dev-libs/capstone:=[static-libs(+)] )
curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
fdt? ( >=sys-apps/dtc-1.5.1[static-libs(+)] )
fuse? ( >=sys-fs/fuse-3.1:3[static-libs(+)] )
glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
gnutls? (
- dev-libs/nettle:=[static-libs(+)]
>=net-libs/gnutls-3.0:=[static-libs(+)]
+ dev-libs/nettle:=[static-libs(+)]
)
gtk? (
+ x11-libs/cairo
+ x11-libs/gdk-pixbuf:2
x11-libs/gtk+:3
+ x11-libs/libX11
vte? ( x11-libs/vte:2.91 )
)
infiniband? ( sys-cluster/rdma-core[static-libs(+)] )
@@ -165,7 +191,7 @@ SOFTMMU_TOOLS_DEPEND="
io-uring? ( sys-libs/liburing:=[static-libs(+)] )
jack? ( virtual/jack )
jemalloc? ( dev-libs/jemalloc )
- jpeg? ( virtual/jpeg:0=[static-libs(+)] )
+ jpeg? ( media-libs/libjpeg-turbo:=[static-libs(+)] )
lzo? ( dev-libs/lzo:2[static-libs(+)] )
multipath? ( sys-fs/multipath-tools )
ncurses? (
@@ -182,7 +208,7 @@ SOFTMMU_TOOLS_DEPEND="
)
pam? ( sys-libs/pam )
png? ( media-libs/libpng:0=[static-libs(+)] )
- pulseaudio? ( media-sound/pulseaudio )
+ pulseaudio? ( media-libs/libpulse )
rbd? ( sys-cluster/ceph )
sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
sdl? (
@@ -200,7 +226,7 @@ SOFTMMU_TOOLS_DEPEND="
)
ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
udev? ( virtual/libudev:= )
- usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
+ usb? ( >=virtual/libusb-1-r2:1[static-libs(+)] )
usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
vde? ( net-misc/vde[static-libs(+)] )
virgl? ( media-libs/virglrenderer[static-libs(+)] )
@@ -209,44 +235,54 @@ SOFTMMU_TOOLS_DEPEND="
zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
"
-EDK2_OVMF_VERSION="202105"
-SEABIOS_VERSION="1.14.0"
+EDK2_OVMF_VERSION="202202"
+SEABIOS_VERSION="1.16.0"
X86_FIRMWARE_DEPEND="
pin-upstream-blobs? (
- ~sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}[binary]
+ ~sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
~sys-firmware/ipxe-1.21.1[binary,qemu]
- ~sys-firmware/seabios-${SEABIOS_VERSION}[binary,seavgabios]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
~sys-firmware/sgabios-0.1_pre10[binary]
)
!pin-upstream-blobs? (
- >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ || (
+ >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ >=sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ )
sys-firmware/ipxe[qemu]
- >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
sys-firmware/sgabios
)"
PPC_FIRMWARE_DEPEND="
pin-upstream-blobs? (
- ~sys-firmware/seabios-${SEABIOS_VERSION}[binary,seavgabios]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
)
!pin-upstream-blobs? (
- >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
)
"
BDEPEND="
$(python_gen_impl_dep)
dev-lang/perl
+ dev-build/meson
sys-apps/texinfo
virtual/pkgconfig
doc? (
dev-python/sphinx[${PYTHON_USEDEP}]
- dev-python/sphinx_rtd_theme[${PYTHON_USEDEP}]
+ dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
)
gtk? ( nls? ( sys-devel/gettext ) )
test? (
dev-libs/glib[utils]
- sys-devel/bc
+ app-alternatives/bc
)
"
CDEPEND="
@@ -274,11 +310,12 @@ RDEPEND="${CDEPEND}
)"
PATCHES=(
- "${FILESDIR}"/${PN}-2.11.1-capstone_include_path.patch
"${FILESDIR}"/${PN}-5.2.0-disable-keymap.patch
"${FILESDIR}"/${PN}-6.0.0-make.patch
- "${FILESDIR}"/${PN}-6.1.0-strings.patch
- "${FILESDIR}"/${PN}-7.0.0-also-build-virtfs-proxy-helper.patch
+ "${FILESDIR}"/${PN}-7.1.0-also-build-virtfs-proxy-helper.patch
+ "${FILESDIR}"/${PN}-7.1.0-capstone-include-path.patch
+ "${FILESDIR}"/${PN}-7.2.0-disable-gmp.patch
+ "${FILESDIR}"/${PN}-7.2.0-linux-headers-6.2-glibc-2.36.patch
)
QA_PREBUILT="
@@ -418,8 +455,13 @@ src_prepare() {
# Verbose builds
MAKEOPTS+=" V=1"
- # Remove bundled copy of libfdt
- rm -r dtc || die
+ # We already force -D_FORTIFY_SOURCE=2 (or 3) in our toolchain, but
+ # this setting (-U then -D..=2) will prevent us from trying out 3, so
+ # drop it. No change to level of protection b/c we patch our toolchain.
+ sed -i -e 's/-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2//' configure || die
+
+ # Remove bundled modules
+ rm -r dtc meson roms/*/ || die
}
##
@@ -432,7 +474,7 @@ qemu_src_configure() {
local buildtype=$1
local builddir="${S}/${buildtype}-build"
- mkdir "${builddir}"
+ mkdir "${builddir}" || die
local conf_opts=(
--prefix=/usr
@@ -464,10 +506,10 @@ qemu_src_configure() {
# are enabled), but it's not really worth the hassle. Disable it
# all the time to avoid automatically detecting it. #568856
--disable-gcrypt
- --python="${PYTHON}"
--cc="$(tc-getCC)"
--cxx="$(tc-getCXX)"
--host-cc="$(tc-getBUILD_CC)"
+
$(use_enable alsa)
$(use_enable debug debug-info)
$(use_enable debug debug-tcg)
@@ -518,7 +560,6 @@ qemu_src_configure() {
$(conf_softmmu bpf)
$(conf_notuser bzip2)
$(conf_notuser capstone)
- $(conf_notuser caps cap-ng)
$(conf_notuser curl)
$(conf_tools doc docs)
$(conf_notuser fdt)
@@ -540,13 +581,13 @@ qemu_src_configure() {
$(conf_notuser numa)
$(conf_notuser opengl)
$(conf_notuser pam auth-pam)
- $(conf_notuser png vnc-png)
+ $(conf_notuser png)
$(conf_notuser rbd)
$(conf_notuser sasl vnc-sasl)
$(conf_notuser sdl)
$(conf_softmmu sdl-image)
$(conf_notuser seccomp)
- $(conf_notuser slirp slirp system)
+ $(conf_notuser slirp)
$(conf_notuser smartcard)
$(conf_notuser snappy)
$(conf_notuser spice)
@@ -556,8 +597,6 @@ qemu_src_configure() {
$(conf_notuser usbredir usb-redir)
$(conf_notuser vde)
$(conf_notuser vhost-net)
- $(conf_notuser vhost-user-fs)
- $(conf_tools vhost-user-fs virtiofsd)
$(conf_notuser virgl virglrenderer)
$(conf_softmmu virtfs)
$(conf_notuser vnc)
@@ -592,6 +631,8 @@ qemu_src_configure() {
--disable-system
--disable-blobs
--disable-tools
+ --disable-cap-ng
+ --disable-seccomp
)
local static_flag="static-user"
;;
@@ -600,6 +641,8 @@ qemu_src_configure() {
--disable-linux-user
--enable-system
--disable-tools
+ --enable-cap-ng
+ --enable-seccomp
)
local static_flag="static"
;;
@@ -609,6 +652,7 @@ qemu_src_configure() {
--disable-system
--disable-blobs
--enable-tools
+ --enable-cap-ng
)
local static_flag="static"
;;
@@ -673,22 +717,22 @@ src_configure() {
src_compile() {
if [[ -n ${user_targets} ]]; then
- cd "${S}/user-build"
+ cd "${S}/user-build" || die
default
fi
if [[ -n ${softmmu_targets} ]]; then
- cd "${S}/softmmu-build"
+ cd "${S}/softmmu-build" || die
default
fi
- cd "${S}/tools-build"
+ cd "${S}/tools-build" || die
default
}
src_test() {
if [[ -n ${softmmu_targets} ]]; then
- cd "${S}/softmmu-build"
+ cd "${S}/softmmu-build" || die
pax-mark m */qemu-system-* #515550
emake check
fi
@@ -785,19 +829,24 @@ src_install() {
fi
fi
- cd "${S}/tools-build"
+ cd "${S}/tools-build" || die
emake DESTDIR="${ED}" install
+ # If USE=doc, there'll be newly generated docs which we install instead.
+ if ! use doc && [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ doman "${WORKDIR}"/${PN}-${QEMU_DOCS_VERSION}-docs/docs/*.[0-8]
+ fi
+
# Disable mprotect on the qemu binaries as they use JITs to be fast #459348
- pushd "${ED}"/usr/bin >/dev/null
+ pushd "${ED}"/usr/bin >/dev/null || die
pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
- popd >/dev/null
+ popd >/dev/null || die
# Install config file example for qemu-bridge-helper
insinto "/etc/qemu"
doins "${FILESDIR}/bridge.conf"
- cd "${S}"
+ cd "${S}" || die
dodoc MAINTAINERS docs/specs/pci-ids.txt
newdoc pc-bios/README README.pc-bios
@@ -806,10 +855,7 @@ src_install() {
if [[ -n ${softmmu_targets} ]]; then
# Remove SeaBIOS since we're using the SeaBIOS packaged one
- rm "${ED}/usr/share/qemu/bios.bin"
- rm "${ED}/usr/share/qemu/bios-256k.bin"
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
- dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
fi
@@ -820,6 +866,7 @@ src_install() {
rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
+
# PPC/PPC64 loads vgabios-stdvga
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64; then
dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
@@ -831,13 +878,11 @@ src_install() {
fi
# Remove sgabios since we're using the sgabios packaged one
- rm "${ED}/usr/share/qemu/sgabios.bin"
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
fi
# Remove iPXE since we're using the iPXE packaged one
- rm "${ED}"/usr/share/qemu/pxe-*.rom
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
@@ -877,9 +922,20 @@ pkg_postinst() {
if use pin-upstream-blobs && firmware_abi_change; then
ewarn "This version of qemu pins new versions of firmware blobs:"
- ewarn " $(best_version sys-firmware/edk2-ovmf)"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ ewarn " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ ewarn " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ ewarn " $(best_version sys-firmware/seabios-bin)"
+ else
+ ewarn " $(best_version sys-firmware/seabios)"
+ fi
+
ewarn " $(best_version sys-firmware/ipxe)"
- ewarn " $(best_version sys-firmware/seabios)"
ewarn " $(best_version sys-firmware/sgabios)"
ewarn "This might break resume of hibernated guests (started with a different"
ewarn "firmware version) and live migration to/from qemu versions with different"
@@ -893,22 +949,24 @@ pkg_postinst() {
pkg_info() {
echo "Using:"
echo " $(best_version app-emulation/spice-protocol)"
- echo " $(best_version sys-firmware/edk2-ovmf)"
- if has_version 'sys-firmware/edk2-ovmf[binary]'; then
- echo " USE=binary"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ echo " $(best_version sys-firmware/edk2-ovmf-bin)"
else
- echo " USE=''"
+ echo " $(best_version sys-firmware/edk2-ovmf)"
fi
- echo " $(best_version sys-firmware/ipxe)"
- echo " $(best_version sys-firmware/seabios)"
- if has_version 'sys-firmware/seabios[binary]'; then
- echo " USE=binary"
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ echo " $(best_version sys-firmware/seabios-bin)"
else
- echo " USE=''"
+ echo " $(best_version sys-firmware/seabios)"
fi
+
+ echo " $(best_version sys-firmware/ipxe)"
echo " $(best_version sys-firmware/sgabios)"
}
pkg_postrm() {
xdg_icon_cache_update
+ udev_reload
}
diff --git a/app-emulation/qemu/qemu-8.0.5.ebuild b/app-emulation/qemu/qemu-8.0.5.ebuild
new file mode 100644
index 000000000000..32cb18d7115d
--- /dev/null
+++ b/app-emulation/qemu/qemu-8.0.5.ebuild
@@ -0,0 +1,972 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+# Generate using https://github.com/thesamesam/sam-gentoo-scripts/blob/main/niche/generate-qemu-docs
+# Set to 1 if prebuilt, 0 if not
+# (the construct below is to allow overriding from env for script)
+QEMU_DOCS_PREBUILT=${QEMU_DOCS_PREBUILT:-1}
+QEMU_DOCS_PREBUILT_DEV=sam
+QEMU_DOCS_VERSION="8.0.0"
+# Default to generating docs (inc. man pages) if no prebuilt; overridden later
+# bug #830088
+QEMU_DOC_USEFLAG="+doc"
+
+PYTHON_COMPAT=( python3_{10..12} )
+PYTHON_REQ_USE="ncurses,readline"
+
+FIRMWARE_ABI_VERSION="7.2.0"
+
+inherit linux-info toolchain-funcs python-r1 udev fcaps readme.gentoo-r1 \
+ pax-utils xdg-utils
+
+if [[ ${PV} == *9999* ]]; then
+ QEMU_DOCS_PREBUILT=0
+
+ EGIT_REPO_URI="https://gitlab.com/qemu-project/qemu.git/"
+ EGIT_SUBMODULES=(
+ tests/fp/berkeley-softfloat-3
+ tests/fp/berkeley-testfloat-3
+ ui/keycodemapdb
+ )
+ inherit git-r3
+ SRC_URI=""
+else
+ MY_P="${PN}-${PV/_rc/-rc}"
+ SRC_URI="https://download.qemu.org/${MY_P}.tar.xz"
+
+ if [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ SRC_URI+=" !doc? ( https://dev.gentoo.org/~${QEMU_DOCS_PREBUILT_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${QEMU_DOCS_VERSION}-docs.tar.xz )"
+ fi
+
+ S="${WORKDIR}/${MY_P}"
+ [[ "${PV}" != *_rc* ]] && KEYWORDS="amd64 ~arm arm64 ~loong ~ppc ppc64 ~riscv x86"
+fi
+
+DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
+HOMEPAGE="https://www.qemu.org https://www.linux-kvm.org"
+
+LICENSE="GPL-2 LGPL-2 BSD-2"
+SLOT="0"
+
+[[ ${QEMU_DOCS_PREBUILT} == 1 ]] && QEMU_DOC_USEFLAG="doc"
+
+IUSE="accessibility +aio alsa bpf bzip2 capstone +curl debug ${QEMU_DOC_USEFLAG}
+ +fdt fuse glusterfs +gnutls gtk infiniband iscsi io-uring
+ jack jemalloc +jpeg
+ lzo multipath
+ ncurses nfs nls numa opengl +oss pam +pin-upstream-blobs
+ plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
+ +slirp
+ smartcard snappy spice ssh static-user systemtap test udev usb
+ usbredir vde +vhost-net virgl virtfs +vnc vte xattr xen
+ zstd"
+
+COMMON_TARGETS="
+ aarch64
+ alpha
+ arm
+ cris
+ hppa
+ i386
+ loongarch64
+ m68k
+ microblaze
+ microblazeel
+ mips
+ mips64
+ mips64el
+ mipsel
+ nios2
+ or1k
+ ppc
+ ppc64
+ riscv32
+ riscv64
+ s390x
+ sh4
+ sh4eb
+ sparc
+ sparc64
+ x86_64
+ xtensa
+ xtensaeb
+"
+IUSE_SOFTMMU_TARGETS="
+ ${COMMON_TARGETS}
+ avr
+ rx
+ tricore
+"
+IUSE_USER_TARGETS="
+ ${COMMON_TARGETS}
+ aarch64_be
+ armeb
+ hexagon
+ mipsn32
+ mipsn32el
+ ppc64le
+ sparc32plus
+"
+
+use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
+use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
+IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
+
+RESTRICT="!test? ( test )"
+
+# Allow no targets to be built so that people can get a tools-only build.
+# Block USE flag configurations known to not work.
+REQUIRED_USE="
+ ${PYTHON_REQUIRED_USE}
+ qemu_softmmu_targets_arm? ( fdt )
+ qemu_softmmu_targets_microblaze? ( fdt )
+ qemu_softmmu_targets_mips64el? ( fdt )
+ qemu_softmmu_targets_ppc64? ( fdt )
+ qemu_softmmu_targets_ppc? ( fdt )
+ qemu_softmmu_targets_riscv32? ( fdt )
+ qemu_softmmu_targets_riscv64? ( fdt )
+ qemu_softmmu_targets_x86_64? ( fdt )
+ sdl-image? ( sdl )
+ static-user? ( !plugins )
+ virgl? ( opengl )
+ virtfs? ( xattr )
+ vnc? ( gnutls )
+ vte? ( gtk )
+ multipath? ( udev )
+ plugins? ( !static-user )
+"
+for smname in ${IUSE_SOFTMMU_TARGETS} ; do
+ REQUIRED_USE+=" qemu_softmmu_targets_${smname}? ( kernel_linux? ( seccomp ) )"
+done
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# and user/softmmu targets (qemu-*, qemu-system-*).
+#
+# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
+#
+# The attr lib isn't always linked in (although the USE flag is always
+# respected). This is because qemu supports using the C library's API
+# when available rather than always using the external library.
+ALL_DEPEND="
+ dev-libs/glib:2[static-libs(+)]
+ sys-libs/zlib[static-libs(+)]
+ python? ( ${PYTHON_DEPS} )
+ systemtap? ( dev-debug/systemtap )
+ xattr? ( sys-apps/attr[static-libs(+)] )
+"
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# softmmu targets (qemu-system-*).
+SOFTMMU_TOOLS_DEPEND="
+ >=x11-libs/pixman-0.28.0[static-libs(+)]
+ accessibility? (
+ app-accessibility/brltty[api]
+ app-accessibility/brltty[static-libs(+)]
+ )
+ aio? ( dev-libs/libaio[static-libs(+)] )
+ alsa? ( >=media-libs/alsa-lib-1.0.13 )
+ bpf? ( dev-libs/libbpf:= )
+ bzip2? ( app-arch/bzip2[static-libs(+)] )
+ capstone? ( dev-libs/capstone:=[static-libs(+)] )
+ curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
+ fdt? ( >=sys-apps/dtc-1.5.1[static-libs(+)] )
+ fuse? ( >=sys-fs/fuse-3.1:3[static-libs(+)] )
+ glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
+ gnutls? (
+ >=net-libs/gnutls-3.0:=[static-libs(+)]
+ dev-libs/nettle:=[static-libs(+)]
+ )
+ gtk? (
+ x11-libs/cairo
+ x11-libs/gdk-pixbuf:2
+ x11-libs/gtk+:3
+ x11-libs/libX11
+ vte? ( x11-libs/vte:2.91 )
+ )
+ infiniband? ( sys-cluster/rdma-core[static-libs(+)] )
+ iscsi? ( net-libs/libiscsi )
+ io-uring? ( sys-libs/liburing:=[static-libs(+)] )
+ jack? ( virtual/jack )
+ jemalloc? ( dev-libs/jemalloc )
+ jpeg? ( media-libs/libjpeg-turbo:=[static-libs(+)] )
+ kernel_linux? ( sys-libs/libcap-ng[static-libs(+)] )
+ lzo? ( dev-libs/lzo:2[static-libs(+)] )
+ multipath? ( sys-fs/multipath-tools )
+ ncurses? (
+ sys-libs/ncurses:=[unicode(+)]
+ sys-libs/ncurses:=[static-libs(+)]
+ )
+ nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
+ numa? ( sys-process/numactl[static-libs(+)] )
+ opengl? (
+ virtual/opengl
+ media-libs/libepoxy[static-libs(+)]
+ media-libs/mesa[static-libs(+)]
+ media-libs/mesa[egl(+),gbm(+)]
+ )
+ pam? ( sys-libs/pam )
+ png? ( >=media-libs/libpng-1.6.34:=[static-libs(+)] )
+ pulseaudio? ( media-libs/libpulse )
+ rbd? ( sys-cluster/ceph )
+ sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
+ sdl? (
+ media-libs/libsdl2[video]
+ media-libs/libsdl2[static-libs(+)]
+ )
+ sdl-image? ( media-libs/sdl2-image[static-libs(+)] )
+ seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
+ slirp? ( net-libs/libslirp[static-libs(+)] )
+ smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
+ snappy? ( app-arch/snappy:= )
+ spice? (
+ >=app-emulation/spice-protocol-0.14.0
+ >=app-emulation/spice-0.14.0[static-libs(+)]
+ )
+ ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
+ udev? ( virtual/libudev:= )
+ usb? ( >=virtual/libusb-1-r2:1[static-libs(+)] )
+ usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
+ vde? ( net-misc/vde[static-libs(+)] )
+ virgl? ( media-libs/virglrenderer[static-libs(+)] )
+ virtfs? ( sys-libs/libcap )
+ xen? ( app-emulation/xen-tools:= )
+ zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
+"
+
+EDK2_OVMF_VERSION="202202"
+SEABIOS_VERSION="1.16.0"
+
+X86_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ ~sys-firmware/ipxe-1.21.1[binary,qemu]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ ~sys-firmware/sgabios-0.1_pre10[binary]
+ )
+ !pin-upstream-blobs? (
+ || (
+ >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ >=sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ )
+ sys-firmware/ipxe[qemu]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ sys-firmware/sgabios
+ )
+"
+PPC_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ !pin-upstream-blobs? (
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ )
+"
+
+BDEPEND="
+ $(python_gen_impl_dep)
+ dev-lang/perl
+ dev-build/meson
+ sys-apps/texinfo
+ virtual/pkgconfig
+ doc? (
+ dev-python/sphinx[${PYTHON_USEDEP}]
+ dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
+ )
+ gtk? ( nls? ( sys-devel/gettext ) )
+ test? (
+ dev-libs/glib[utils]
+ app-alternatives/bc
+ )
+"
+CDEPEND="
+ ${ALL_DEPEND//\[static-libs(+)]}
+ ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
+ qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc? ( ${PPC_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc64? ( ${PPC_FIRMWARE_DEPEND} )
+"
+DEPEND="
+ ${CDEPEND}
+ kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
+ static-user? ( ${ALL_DEPEND} )
+"
+RDEPEND="
+ ${CDEPEND}
+ acct-group/kvm
+ selinux? (
+ sec-policy/selinux-qemu
+ sys-libs/libselinux
+ )
+"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-8.0.0-disable-keymap.patch
+ "${FILESDIR}"/${PN}-8.0.0-make.patch
+ "${FILESDIR}"/${PN}-7.1.0-also-build-virtfs-proxy-helper.patch
+ "${FILESDIR}"/${PN}-7.1.0-capstone-include-path.patch
+ "${FILESDIR}"/${PN}-7.2.0-disable-gmp.patch
+ "${FILESDIR}"/${PN}-8.0.0-remove-python-meson-check.patch
+)
+
+QA_PREBUILT="
+ usr/share/qemu/hppa-firmware.img
+ usr/share/qemu/openbios-ppc
+ usr/share/qemu/openbios-sparc64
+ usr/share/qemu/openbios-sparc32
+ usr/share/qemu/opensbi-riscv64-generic-fw_dynamic.elf
+ usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.elf
+ usr/share/qemu/palcode-clipper
+ usr/share/qemu/s390-ccw.img
+ usr/share/qemu/s390-netboot.img
+ usr/share/qemu/u-boot.e500
+"
+
+QA_WX_LOAD="
+ usr/bin/qemu-i386
+ usr/bin/qemu-x86_64
+ usr/bin/qemu-alpha
+ usr/bin/qemu-arm
+ usr/bin/qemu-cris
+ usr/bin/qemu-m68k
+ usr/bin/qemu-microblaze
+ usr/bin/qemu-microblazeel
+ usr/bin/qemu-mips
+ usr/bin/qemu-mipsel
+ usr/bin/qemu-or1k
+ usr/bin/qemu-ppc
+ usr/bin/qemu-ppc64
+ usr/bin/qemu-sh4
+ usr/bin/qemu-sh4eb
+ usr/bin/qemu-sparc
+ usr/bin/qemu-sparc64
+ usr/bin/qemu-armeb
+ usr/bin/qemu-sparc32plus
+ usr/bin/qemu-s390x
+ usr/bin/qemu-unicore32
+"
+
+DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
+kernel module loaded before running kvm. The easiest way to ensure that the
+kernel module is loaded is to load it on boot.
+ For AMD CPUs the module is called 'kvm-amd'.
+ For Intel CPUs the module is called 'kvm-intel'.
+Please review /etc/conf.d/modules for how to load these.
+
+Make sure your user is in the 'kvm' group. Just run
+ $ gpasswd -a <USER> kvm
+then have <USER> re-login.
+
+For brand new installs, the default permissions on /dev/kvm might not let
+you access it. You can tell udev to reset ownership/perms:
+ $ udevadm trigger -c add /dev/kvm
+
+If you want to register binfmt handlers for qemu user targets:
+For openrc:
+ # rc-update add qemu-binfmt
+For systemd:
+ # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
+
+pkg_pretend() {
+ if use kernel_linux && kernel_is lt 2 6 25; then
+ eerror "This version of KVM requires a host kernel of 2.6.25 or higher."
+ elif use kernel_linux; then
+ if ! linux_config_exists; then
+ eerror "Unable to check your kernel for KVM support"
+ else
+ CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
+ ERROR_KVM="You must enable KVM in your kernel to continue"
+ ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
+ ERROR_KVM_AMD+=" your kernel configuration."
+ ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
+ ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
+ ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
+ ERROR_TUN+=" into your kernel or loaded as a module to use the"
+ ERROR_TUN+=" virtual network device if using -net tap."
+ ERROR_BRIDGE="You will also need support for 802.1d"
+ ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
+ use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
+ ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
+ ERROR_VHOST_NET+=" support"
+ use test && CONFIG_CHECK+=" IP_MULTICAST"
+ ERROR_IP_MULTICAST="Test suite requires IP_MULTICAST"
+
+ if use amd64 || use x86 || use amd64-linux || use x86-linux; then
+ if grep -q AuthenticAMD /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_AMD"
+ elif grep -q GenuineIntel /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_INTEL"
+ fi
+ fi
+
+ use python && CONFIG_CHECK+=" ~DEBUG_FS"
+ ERROR_DEBUG_FS="debugFS support required for kvm_stat"
+
+ # Now do the actual checks setup above
+ check_extra_config
+ fi
+ fi
+
+ if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
+ eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
+ eerror "instances are still pointing to it. Please update your"
+ eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
+ eerror "and the right system binary (e.g. qemu-system-x86_64)."
+ die "update your virt configs to not use qemu-kvm"
+ fi
+}
+
+# Sanity check to make sure target lists are kept up-to-date.
+check_targets() {
+ local var=$1 mak=$2
+ local detected sorted
+
+ pushd "${S}"/configs/targets/ >/dev/null || die
+
+ # Force C locale until glibc is updated. #564936
+ detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
+ sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
+ if [[ ${sorted} != "${detected}" ]] ; then
+ eerror "The ebuild needs to be kept in sync."
+ eerror "${var}: ${sorted}"
+ eerror "$(printf '%-*s' ${#var} configure): ${detected}"
+ die "sync ${var} to the list of targets"
+ fi
+
+ popd >/dev/null
+}
+
+src_prepare() {
+ check_targets IUSE_SOFTMMU_TARGETS softmmu
+ check_targets IUSE_USER_TARGETS linux-user
+
+ default
+
+ # Use correct toolchain to fix cross-compiling
+ tc-export AR AS LD NM OBJCOPY PKG_CONFIG RANLIB STRINGS
+ export WINDRES=${CHOST}-windres
+
+ # Verbose builds
+ MAKEOPTS+=" V=1"
+
+ # We already force -D_FORTIFY_SOURCE=2 (or 3) in our toolchain, but
+ # this setting (-U then -D..=2) will prevent us from trying out 3, so
+ # drop it. No change to level of protection b/c we patch our toolchain.
+ sed -i -e 's/-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2//' configure || die
+
+ # Remove bundled modules
+ rm -r dtc meson roms/*/ || die
+}
+
+##
+# configures qemu based on the build directory and the build type
+# we are using.
+#
+qemu_src_configure() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ local buildtype=$1
+ local builddir="${S}/${buildtype}-build"
+
+ mkdir "${builddir}" || die
+
+ local conf_opts=(
+ --prefix=/usr
+ --sysconfdir=/etc
+ --bindir=/usr/bin
+ --libdir=/usr/$(get_libdir)
+ --datadir=/usr/share
+ --docdir=/usr/share/doc/${PF}/html
+ --mandir=/usr/share/man
+ --localstatedir=/var
+ --disable-bsd-user
+ --disable-containers # bug #732972
+ --disable-guest-agent
+ --disable-strip
+ --with-git-submodules=ignore
+
+ # bug #746752: TCG interpreter has a few limitations:
+ # - it does not support FPU
+ # - it's generally slower on non-self-modifying code
+ # It's advantage is support for host architectures
+ # where native codegeneration is not implemented.
+ # Gentoo has qemu keyworded only on targets with
+ # native code generation available. Avoid the interpreter.
+ --disable-tcg-interpreter
+
+ --disable-werror
+ # We support gnutls/nettle for crypto operations. It is possible
+ # to use gcrypt when gnutls/nettle are disabled (but not when they
+ # are enabled), but it's not really worth the hassle. Disable it
+ # all the time to avoid automatically detecting it. #568856
+ --disable-gcrypt
+ --cc="$(tc-getCC)"
+ --cxx="$(tc-getCXX)"
+ --host-cc="$(tc-getBUILD_CC)"
+
+ $(use_enable alsa)
+ $(use_enable debug debug-info)
+ $(use_enable debug debug-tcg)
+ $(use_enable jack)
+ $(use_enable nls gettext)
+ $(use_enable oss)
+ $(use_enable plugins)
+ $(use_enable pulseaudio pa)
+ $(use_enable selinux)
+ $(use_enable xattr attr)
+ )
+
+ # Disable options not used by user targets. This simplifies building
+ # static user targets (USE=static-user) considerably.
+ conf_notuser() {
+ if [[ ${buildtype} == "user" ]] ; then
+ echo "--disable-${2:-$1}"
+ else
+ use_enable "$@"
+ fi
+ }
+ # Enable option only for softmmu build, but not 'user' or 'tools'
+ conf_softmmu() {
+ if [[ ${buildtype} == "softmmu" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Enable option only for tools build, but not 'user' or 'softmmu'
+ conf_tools() {
+ if [[ ${buildtype} == "tools" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Special case for the malloc flag, because the --disable flag does
+ # not exist and trying like above will break configuring.
+ conf_malloc() {
+ if [[ ! ${buildtype} == "user" ]] ; then
+ usex "${1}" "--enable-malloc=${1}" ""
+ fi
+ }
+ conf_opts+=(
+ $(conf_notuser accessibility brlapi)
+ $(conf_notuser aio linux-aio)
+ $(conf_softmmu bpf)
+ $(conf_notuser bzip2)
+ $(conf_notuser capstone)
+ $(conf_notuser curl)
+ $(conf_tools doc docs)
+ $(conf_notuser fdt)
+ $(conf_notuser fuse)
+ $(conf_notuser glusterfs)
+ $(conf_notuser gnutls)
+ $(conf_notuser gnutls nettle)
+ $(conf_notuser gtk)
+ $(conf_notuser infiniband rdma)
+ $(conf_notuser iscsi libiscsi)
+ $(conf_notuser io-uring linux-io-uring)
+ $(conf_malloc jemalloc)
+ $(conf_notuser jpeg vnc-jpeg)
+ $(conf_notuser kernel_linux kvm)
+ $(conf_notuser lzo)
+ $(conf_notuser multipath mpath)
+ $(conf_notuser ncurses curses)
+ $(conf_notuser nfs libnfs)
+ $(conf_notuser numa)
+ $(conf_notuser opengl)
+ $(conf_notuser pam auth-pam)
+ $(conf_notuser png)
+ $(conf_notuser rbd)
+ $(conf_notuser sasl vnc-sasl)
+ $(conf_notuser sdl)
+ $(conf_softmmu sdl-image)
+ $(conf_notuser seccomp)
+ $(conf_notuser slirp)
+ $(conf_notuser smartcard)
+ $(conf_notuser snappy)
+ $(conf_notuser spice)
+ $(conf_notuser ssh libssh)
+ $(conf_notuser udev libudev)
+ $(conf_notuser usb libusb)
+ $(conf_notuser usbredir usb-redir)
+ $(conf_notuser vde)
+ $(conf_notuser vhost-net)
+ $(conf_notuser virgl virglrenderer)
+ $(conf_softmmu virtfs)
+ $(conf_notuser vnc)
+ $(conf_notuser vte)
+ $(conf_notuser xen)
+ $(conf_notuser xen xen-pci-passthrough)
+ # use prebuilt keymaps, bug #759604
+ --disable-xkbcommon
+ $(conf_notuser zstd)
+ )
+
+ if [[ ! ${buildtype} == "user" ]] ; then
+ # audio options
+ local audio_opts=(
+ # Note: backend order matters here: #716202
+ # We iterate from higher-level to lower level.
+ $(usex pulseaudio pa "")
+ $(usev jack)
+ $(usev sdl)
+ $(usev alsa)
+ $(usev oss)
+ )
+ conf_opts+=(
+ --audio-drv-list=$(IFS=,; echo "${audio_opts[*]}")
+ )
+ fi
+
+ case ${buildtype} in
+ user)
+ conf_opts+=(
+ --enable-linux-user
+ --disable-system
+ --disable-tools
+ --disable-cap-ng
+ --disable-seccomp
+ )
+ local static_flag="static-user"
+ ;;
+ softmmu)
+ conf_opts+=(
+ --disable-linux-user
+ --enable-system
+ --disable-tools
+ --enable-cap-ng
+ --enable-seccomp
+ )
+ local static_flag="none"
+ ;;
+ tools)
+ conf_opts+=(
+ --disable-linux-user
+ --disable-system
+ --enable-tools
+ --enable-cap-ng
+ )
+ local static_flag="none"
+ ;;
+ esac
+
+ local targets="${buildtype}_targets"
+ [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
+
+ # Add support for SystemTAP
+ use systemtap && conf_opts+=( --enable-trace-backends="dtrace" )
+
+ # We always want to attempt to build with PIE support as it results
+ # in a more secure binary. But it doesn't work with static or if
+ # the current GCC doesn't have PIE support.
+ if [[ ${static_flag} != "none" ]] && use ${static_flag}; then
+ conf_opts+=( --static --disable-pie )
+ else
+ tc-enables-pie && conf_opts+=( --enable-pie )
+ fi
+
+ # Meson will not use a cross-file unless cross_prefix is set.
+ tc-is-cross-compiler && conf_opts+=( --cross-prefix="${CHOST}-" )
+
+ # Plumb through equivalent of EXTRA_ECONF to allow experiments
+ # like bug #747928.
+ conf_opts+=( ${EXTRA_CONF_QEMU} )
+
+ echo "../configure ${conf_opts[*]}"
+ cd "${builddir}"
+ ../configure "${conf_opts[@]}" || die "configure failed"
+}
+
+src_configure() {
+ local target
+
+ python_setup
+
+ softmmu_targets= softmmu_bins=()
+ user_targets= user_bins=()
+
+ for target in ${IUSE_SOFTMMU_TARGETS} ; do
+ if use "qemu_softmmu_targets_${target}"; then
+ softmmu_targets+=",${target}-softmmu"
+ softmmu_bins+=( "qemu-system-${target}" )
+ fi
+ done
+
+ for target in ${IUSE_USER_TARGETS} ; do
+ if use "qemu_user_targets_${target}"; then
+ user_targets+=",${target}-linux-user"
+ user_bins+=( "qemu-${target}" )
+ fi
+ done
+
+ softmmu_targets=${softmmu_targets#,}
+ user_targets=${user_targets#,}
+
+ [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
+ [[ -n ${user_targets} ]] && qemu_src_configure "user"
+ qemu_src_configure "tools"
+}
+
+src_compile() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build" || die
+ default
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build" || die
+ default
+ fi
+
+ cd "${S}/tools-build" || die
+ default
+}
+
+src_test() {
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build" || die
+ pax-mark m */qemu-system-* #515550
+ emake check
+ fi
+}
+
+qemu_python_install() {
+ python_domodule "${S}/python/qemu"
+
+ python_doscript "${S}/scripts/kvm/vmxcap"
+ python_doscript "${S}/scripts/qmp/qmp-shell"
+ python_doscript "${S}/scripts/qmp/qemu-ga-client"
+}
+
+# Generate binfmt support files.
+# - /etc/init.d/qemu-binfmt script which registers the user handlers (openrc)
+# - /usr/share/qemu/binfmt.d/qemu.conf (for use with systemd-binfmt)
+generate_initd() {
+ local out="${T}/qemu-binfmt"
+ local out_systemd="${T}/qemu.conf"
+ local d="${T}/binfmt.d"
+
+ einfo "Generating qemu binfmt scripts and configuration files"
+
+ # Generate the debian fragments first.
+ mkdir -p "${d}"
+ "${S}"/scripts/qemu-binfmt-conf.sh \
+ --debian \
+ --exportdir "${d}" \
+ --qemu-path "${EPREFIX}/usr/bin" \
+ || die
+ # Then turn the fragments into a shell script we can source.
+ sed -E -i \
+ -e 's:^([^ ]+) (.*)$:\1="\2":' \
+ "${d}"/* || die
+
+ # Generate the init.d script by assembling the fragments from above.
+ local f qcpu package interpreter magic mask
+ cat "${FILESDIR}"/qemu-binfmt.initd.head >"${out}" || die
+ for f in "${d}"/qemu-* ; do
+ source "${f}"
+
+ # Normalize the cpu logic like we do in the init.d for the native cpu.
+ qcpu=${package#qemu-}
+ case ${qcpu} in
+ arm*) qcpu="arm";;
+ mips*) qcpu="mips";;
+ ppc*) qcpu="ppc";;
+ s390*) qcpu="s390";;
+ sh*) qcpu="sh";;
+ sparc*) qcpu="sparc";;
+ esac
+
+ # we use 'printf' here to be portable across 'sh'
+ # implementations: #679168
+ cat <<EOF >>"${out}"
+ if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
+ printf '%s\n' ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
+ fi
+EOF
+
+ echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >>"${out_systemd}"
+
+ done
+ cat "${FILESDIR}"/qemu-binfmt.initd.tail >>"${out}" || die
+}
+
+src_install() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build"
+ emake DESTDIR="${ED}" install
+
+ # Install binfmt handler init script for user targets.
+ generate_initd
+ doinitd "${T}/qemu-binfmt"
+
+ # Install binfmt/qemu.conf.
+ insinto "/usr/share/qemu/binfmt.d"
+ doins "${T}/qemu.conf"
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build"
+ emake DESTDIR="${ED}" install
+
+ # This might not exist if the test failed. #512010
+ [[ -e check-report.html ]] && dodoc check-report.html
+
+ if use kernel_linux; then
+ udev_newrules "${FILESDIR}"/65-kvm.rules-r2 65-kvm.rules
+ fi
+
+ if use python; then
+ python_foreach_impl qemu_python_install
+ fi
+ fi
+
+ cd "${S}/tools-build" || die
+ emake DESTDIR="${ED}" install
+
+ # If USE=doc, there'll be newly generated docs which we install instead.
+ if ! use doc && [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ doman "${WORKDIR}"/${PN}-${QEMU_DOCS_VERSION}-docs/docs/*.[0-8]
+ fi
+
+ # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
+ pushd "${ED}"/usr/bin >/dev/null || die
+ pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
+ popd >/dev/null || die
+
+ # Install config file example for qemu-bridge-helper
+ insinto "/etc/qemu"
+ doins "${FILESDIR}/bridge.conf"
+
+ cd "${S}" || die
+ dodoc MAINTAINERS docs/specs/pci-ids.txt
+ newdoc pc-bios/README README.pc-bios
+
+ # Disallow stripping of prebuilt firmware files.
+ dostrip -x ${QA_PREBUILT}
+
+ if [[ -n ${softmmu_targets} ]]; then
+ # Remove SeaBIOS since we're using the SeaBIOS packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
+ fi
+
+ # Remove vgabios since we're using the seavgabios packaged one
+ rm "${ED}/usr/share/qemu/vgabios.bin"
+ rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
+ rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
+ rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
+ rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
+ rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
+
+ # PPC/PPC64 loads vgabios-stdvga
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64; then
+ dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
+ dosym ../seavgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
+ dosym ../seavgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
+ dosym ../seavgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
+ dosym ../seavgabios/vgabios-virtio.bin /usr/share/qemu/vgabios-virtio.bin
+ dosym ../seavgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
+ fi
+
+ # Remove sgabios since we're using the sgabios packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
+ fi
+
+ # Remove iPXE since we're using the iPXE packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
+ dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
+ dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
+ dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
+ dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
+ dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
+ fi
+ fi
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_create_doc
+}
+
+firmware_abi_change() {
+ local pv
+ for pv in ${REPLACING_VERSIONS}; do
+ if ver_test ${pv} -lt ${FIRMWARE_ABI_VERSION}; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+pkg_postinst() {
+ if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
+ udev_reload
+ fi
+
+ xdg_icon_cache_update
+
+ [[ -z ${EPREFIX} ]] && [[ -f ${EROOT}/usr/libexec/qemu-bridge-helper ]] && \
+ fcaps cap_net_admin "${EROOT}"/usr/libexec/qemu-bridge-helper
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_print_elog
+
+ if use pin-upstream-blobs && firmware_abi_change; then
+ ewarn "This version of qemu pins new versions of firmware blobs:"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ ewarn " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ ewarn " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ ewarn " $(best_version sys-firmware/seabios-bin)"
+ else
+ ewarn " $(best_version sys-firmware/seabios)"
+ fi
+
+ ewarn " $(best_version sys-firmware/ipxe)"
+ ewarn " $(best_version sys-firmware/sgabios)"
+ ewarn "This might break resume of hibernated guests (started with a different"
+ ewarn "firmware version) and live migration to/from qemu versions with different"
+ ewarn "firmware. Please (cold) restart all running guests. For functional"
+ ewarn "guest migration ensure that all"
+ ewarn "hosts run at least"
+ ewarn " app-emulation/qemu-${FIRMWARE_ABI_VERSION}."
+ fi
+}
+
+pkg_info() {
+ echo "Using:"
+ echo " $(best_version app-emulation/spice-protocol)"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ echo " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ echo " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ echo " $(best_version sys-firmware/seabios-bin)"
+ else
+ echo " $(best_version sys-firmware/seabios)"
+ fi
+
+ echo " $(best_version sys-firmware/ipxe)"
+ echo " $(best_version sys-firmware/sgabios)"
+}
+
+pkg_postrm() {
+ xdg_icon_cache_update
+ udev_reload
+}
diff --git a/app-emulation/qemu/qemu-8.1.5.ebuild b/app-emulation/qemu/qemu-8.1.5.ebuild
new file mode 100644
index 000000000000..05d55122f855
--- /dev/null
+++ b/app-emulation/qemu/qemu-8.1.5.ebuild
@@ -0,0 +1,972 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+# Generate using https://github.com/thesamesam/sam-gentoo-scripts/blob/main/niche/generate-qemu-docs
+# Set to 1 if prebuilt, 0 if not
+# (the construct below is to allow overriding from env for script)
+QEMU_DOCS_PREBUILT=${QEMU_DOCS_PREBUILT:-1}
+QEMU_DOCS_PREBUILT_DEV=sam
+#QEMU_DOCS_VERSION=$(ver_cut 1-3)
+QEMU_DOCS_VERSION=8.1.0
+# Default to generating docs (inc. man pages) if no prebuilt; overridden later
+# bug #830088
+QEMU_DOC_USEFLAG="+doc"
+
+PYTHON_COMPAT=( python3_{10..12} )
+PYTHON_REQ_USE="ncurses,readline"
+
+FIRMWARE_ABI_VERSION="7.2.0"
+
+inherit linux-info toolchain-funcs python-r1 udev fcaps readme.gentoo-r1 \
+ pax-utils xdg-utils
+
+if [[ ${PV} == *9999* ]]; then
+ QEMU_DOCS_PREBUILT=0
+
+ EGIT_REPO_URI="https://gitlab.com/qemu-project/qemu.git/"
+ EGIT_SUBMODULES=(
+ tests/fp/berkeley-softfloat-3
+ tests/fp/berkeley-testfloat-3
+ subprojects/keycodemapdb
+ )
+ inherit git-r3
+ SRC_URI=""
+else
+ MY_P="${PN}-${PV/_rc/-rc}"
+ SRC_URI="https://download.qemu.org/${MY_P}.tar.xz"
+
+ if [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ SRC_URI+=" !doc? ( https://dev.gentoo.org/~${QEMU_DOCS_PREBUILT_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${QEMU_DOCS_VERSION}-docs.tar.xz )"
+ fi
+
+ S="${WORKDIR}/${MY_P}"
+ [[ "${PV}" != *_rc* ]] && KEYWORDS="amd64 ~arm arm64 ~loong ~ppc ppc64 ~riscv x86"
+fi
+
+DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
+HOMEPAGE="https://www.qemu.org https://www.linux-kvm.org"
+
+LICENSE="GPL-2 LGPL-2 BSD-2"
+SLOT="0"
+
+[[ ${QEMU_DOCS_PREBUILT} == 1 ]] && QEMU_DOC_USEFLAG="doc"
+
+IUSE="accessibility +aio alsa bpf bzip2 capstone +curl debug ${QEMU_DOC_USEFLAG}
+ +fdt fuse glusterfs +gnutls gtk infiniband iscsi io-uring
+ jack jemalloc +jpeg keyutils
+ lzo multipath
+ ncurses nfs nls numa opengl +oss pam +pin-upstream-blobs pipewire
+ plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
+ +slirp
+ smartcard snappy spice ssh static-user systemtap test udev usb
+ usbredir vde +vhost-net virgl virtfs +vnc vte xattr xen
+ zstd"
+
+COMMON_TARGETS="
+ aarch64
+ alpha
+ arm
+ cris
+ hppa
+ i386
+ loongarch64
+ m68k
+ microblaze
+ microblazeel
+ mips
+ mips64
+ mips64el
+ mipsel
+ nios2
+ or1k
+ ppc
+ ppc64
+ riscv32
+ riscv64
+ s390x
+ sh4
+ sh4eb
+ sparc
+ sparc64
+ x86_64
+ xtensa
+ xtensaeb
+"
+IUSE_SOFTMMU_TARGETS="
+ ${COMMON_TARGETS}
+ avr
+ rx
+ tricore
+"
+IUSE_USER_TARGETS="
+ ${COMMON_TARGETS}
+ aarch64_be
+ armeb
+ hexagon
+ mipsn32
+ mipsn32el
+ ppc64le
+ sparc32plus
+"
+
+use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
+use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
+IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
+
+RESTRICT="!test? ( test )"
+
+# Allow no targets to be built so that people can get a tools-only build.
+# Block USE flag configurations known to not work.
+REQUIRED_USE="
+ ${PYTHON_REQUIRED_USE}
+ qemu_softmmu_targets_arm? ( fdt )
+ qemu_softmmu_targets_microblaze? ( fdt )
+ qemu_softmmu_targets_mips64el? ( fdt )
+ qemu_softmmu_targets_ppc64? ( fdt )
+ qemu_softmmu_targets_ppc? ( fdt )
+ qemu_softmmu_targets_riscv32? ( fdt )
+ qemu_softmmu_targets_riscv64? ( fdt )
+ qemu_softmmu_targets_x86_64? ( fdt )
+ sdl-image? ( sdl )
+ static-user? ( !plugins )
+ virgl? ( opengl )
+ virtfs? ( xattr )
+ vnc? ( gnutls )
+ vte? ( gtk )
+ multipath? ( udev )
+ plugins? ( !static-user )
+"
+for smname in ${IUSE_SOFTMMU_TARGETS} ; do
+ REQUIRED_USE+=" qemu_softmmu_targets_${smname}? ( kernel_linux? ( seccomp ) )"
+done
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# and user/softmmu targets (qemu-*, qemu-system-*).
+#
+# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
+#
+# The attr lib isn't always linked in (although the USE flag is always
+# respected). This is because qemu supports using the C library's API
+# when available rather than always using the external library.
+ALL_DEPEND="
+ dev-libs/glib:2[static-libs(+)]
+ sys-libs/zlib[static-libs(+)]
+ python? ( ${PYTHON_DEPS} )
+ systemtap? ( dev-debug/systemtap )
+ xattr? ( sys-apps/attr[static-libs(+)] )
+"
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# softmmu targets (qemu-system-*).
+SOFTMMU_TOOLS_DEPEND="
+ >=x11-libs/pixman-0.28.0[static-libs(+)]
+ accessibility? (
+ app-accessibility/brltty[api]
+ app-accessibility/brltty[static-libs(+)]
+ )
+ aio? ( dev-libs/libaio[static-libs(+)] )
+ alsa? ( >=media-libs/alsa-lib-1.0.13 )
+ bpf? ( dev-libs/libbpf:= )
+ bzip2? ( app-arch/bzip2[static-libs(+)] )
+ capstone? ( dev-libs/capstone:=[static-libs(+)] )
+ curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
+ fdt? ( >=sys-apps/dtc-1.5.1[static-libs(+)] )
+ fuse? ( >=sys-fs/fuse-3.1:3[static-libs(+)] )
+ glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
+ gnutls? (
+ >=net-libs/gnutls-3.0:=[static-libs(+)]
+ dev-libs/nettle:=[static-libs(+)]
+ )
+ gtk? (
+ x11-libs/gtk+:3
+ vte? ( x11-libs/vte:2.91 )
+ )
+ infiniband? ( sys-cluster/rdma-core[static-libs(+)] )
+ iscsi? ( net-libs/libiscsi )
+ io-uring? ( sys-libs/liburing:=[static-libs(+)] )
+ jack? ( virtual/jack )
+ jemalloc? ( dev-libs/jemalloc )
+ jpeg? ( media-libs/libjpeg-turbo:=[static-libs(+)] )
+ kernel_linux? ( sys-libs/libcap-ng[static-libs(+)] )
+ keyutils? ( sys-apps/keyutils[static-libs(+)] )
+ lzo? ( dev-libs/lzo:2[static-libs(+)] )
+ multipath? ( sys-fs/multipath-tools )
+ ncurses? (
+ sys-libs/ncurses:=[unicode(+)]
+ sys-libs/ncurses:=[static-libs(+)]
+ )
+ nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
+ numa? ( sys-process/numactl[static-libs(+)] )
+ opengl? (
+ virtual/opengl
+ media-libs/libepoxy[static-libs(+)]
+ media-libs/mesa[static-libs(+)]
+ media-libs/mesa[egl(+),gbm(+)]
+ )
+ pam? ( sys-libs/pam )
+ pipewire? ( >=media-video/pipewire-0.3.60 )
+ png? ( >=media-libs/libpng-1.6.34:=[static-libs(+)] )
+ pulseaudio? ( media-libs/libpulse )
+ rbd? ( sys-cluster/ceph )
+ sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
+ sdl? (
+ media-libs/libsdl2[video]
+ media-libs/libsdl2[static-libs(+)]
+ )
+ sdl-image? ( media-libs/sdl2-image[static-libs(+)] )
+ seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
+ slirp? ( net-libs/libslirp[static-libs(+)] )
+ smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
+ snappy? ( app-arch/snappy:= )
+ spice? (
+ >=app-emulation/spice-protocol-0.14.0
+ >=app-emulation/spice-0.14.0[static-libs(+)]
+ )
+ ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
+ udev? ( virtual/libudev:= )
+ usb? ( >=virtual/libusb-1-r2:1[static-libs(+)] )
+ usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
+ vde? ( net-misc/vde[static-libs(+)] )
+ virgl? ( media-libs/virglrenderer[static-libs(+)] )
+ virtfs? ( sys-libs/libcap )
+ xen? ( app-emulation/xen-tools:= )
+ zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
+"
+
+EDK2_OVMF_VERSION="202202"
+SEABIOS_VERSION="1.16.0"
+
+X86_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ ~sys-firmware/ipxe-1.21.1[binary,qemu]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ ~sys-firmware/sgabios-0.1_pre10[binary]
+ )
+ !pin-upstream-blobs? (
+ || (
+ >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ >=sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ )
+ sys-firmware/ipxe[qemu]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ sys-firmware/sgabios
+ )
+"
+PPC_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ !pin-upstream-blobs? (
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ )
+"
+
+# See bug #913084 for pip dep
+BDEPEND="
+ $(python_gen_impl_dep)
+ dev-lang/perl
+ >=dev-build/meson-0.63.0
+ app-alternatives/ninja
+ dev-python/pip[${PYTHON_USEDEP}]
+ virtual/pkgconfig
+ doc? (
+ >=dev-python/sphinx-1.6.0[${PYTHON_USEDEP}]
+ dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
+ )
+ gtk? ( nls? ( sys-devel/gettext ) )
+ test? (
+ dev-libs/glib[utils]
+ app-alternatives/bc
+ )
+"
+CDEPEND="
+ ${ALL_DEPEND//\[static-libs(+)]}
+ ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
+ qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc? ( ${PPC_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc64? ( ${PPC_FIRMWARE_DEPEND} )
+"
+DEPEND="
+ ${CDEPEND}
+ kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
+ static-user? ( ${ALL_DEPEND} )
+"
+RDEPEND="
+ ${CDEPEND}
+ acct-group/kvm
+ selinux? (
+ sec-policy/selinux-qemu
+ sys-libs/libselinux
+ )
+"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-8.0.0-disable-keymap.patch
+ "${FILESDIR}"/${PN}-7.1.0-capstone-include-path.patch
+ "${FILESDIR}"/${PN}-8.1.0-also-build-virtfs-proxy-helper.patch
+ "${FILESDIR}"/${PN}-8.1.0-skip-tests.patch
+ "${FILESDIR}"/${PN}-8.1.0-find-sphinx.patch
+)
+
+QA_PREBUILT="
+ usr/share/qemu/hppa-firmware.img
+ usr/share/qemu/openbios-ppc
+ usr/share/qemu/openbios-sparc64
+ usr/share/qemu/openbios-sparc32
+ usr/share/qemu/opensbi-riscv64-generic-fw_dynamic.elf
+ usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.elf
+ usr/share/qemu/palcode-clipper
+ usr/share/qemu/s390-ccw.img
+ usr/share/qemu/s390-netboot.img
+ usr/share/qemu/u-boot.e500
+"
+
+QA_WX_LOAD="
+ usr/bin/qemu-i386
+ usr/bin/qemu-x86_64
+ usr/bin/qemu-alpha
+ usr/bin/qemu-arm
+ usr/bin/qemu-cris
+ usr/bin/qemu-m68k
+ usr/bin/qemu-microblaze
+ usr/bin/qemu-microblazeel
+ usr/bin/qemu-mips
+ usr/bin/qemu-mipsel
+ usr/bin/qemu-or1k
+ usr/bin/qemu-ppc
+ usr/bin/qemu-ppc64
+ usr/bin/qemu-sh4
+ usr/bin/qemu-sh4eb
+ usr/bin/qemu-sparc
+ usr/bin/qemu-sparc64
+ usr/bin/qemu-armeb
+ usr/bin/qemu-sparc32plus
+ usr/bin/qemu-s390x
+ usr/bin/qemu-unicore32
+"
+
+DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
+kernel module loaded before running kvm. The easiest way to ensure that the
+kernel module is loaded is to load it on boot.
+ For AMD CPUs the module is called 'kvm-amd'.
+ For Intel CPUs the module is called 'kvm-intel'.
+Please review /etc/conf.d/modules for how to load these.
+
+Make sure your user is in the 'kvm' group. Just run
+ $ gpasswd -a <USER> kvm
+then have <USER> re-login.
+
+For brand new installs, the default permissions on /dev/kvm might not let
+you access it. You can tell udev to reset ownership/perms:
+ $ udevadm trigger -c add /dev/kvm
+
+If you want to register binfmt handlers for qemu user targets:
+For openrc:
+ # rc-update add qemu-binfmt
+For systemd:
+ # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
+
+pkg_pretend() {
+ if use kernel_linux && kernel_is lt 2 6 25; then
+ eerror "This version of KVM requires a host kernel of 2.6.25 or higher."
+ elif use kernel_linux; then
+ if ! linux_config_exists; then
+ eerror "Unable to check your kernel for KVM support"
+ else
+ CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
+ ERROR_KVM="You must enable KVM in your kernel to continue"
+ ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
+ ERROR_KVM_AMD+=" your kernel configuration."
+ ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
+ ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
+ ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
+ ERROR_TUN+=" into your kernel or loaded as a module to use the"
+ ERROR_TUN+=" virtual network device if using -net tap."
+ ERROR_BRIDGE="You will also need support for 802.1d"
+ ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
+ use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
+ ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
+ ERROR_VHOST_NET+=" support"
+ use test && CONFIG_CHECK+=" IP_MULTICAST"
+ ERROR_IP_MULTICAST="Test suite requires IP_MULTICAST"
+
+ if use amd64 || use x86 || use amd64-linux || use x86-linux; then
+ if grep -q AuthenticAMD /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_AMD"
+ elif grep -q GenuineIntel /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_INTEL"
+ fi
+ fi
+
+ use python && CONFIG_CHECK+=" ~DEBUG_FS"
+ ERROR_DEBUG_FS="debugFS support required for kvm_stat"
+
+ # Now do the actual checks setup above
+ check_extra_config
+ fi
+ fi
+
+ if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
+ eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
+ eerror "instances are still pointing to it. Please update your"
+ eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
+ eerror "and the right system binary (e.g. qemu-system-x86_64)."
+ die "update your virt configs to not use qemu-kvm"
+ fi
+}
+
+# Sanity check to make sure target lists are kept up-to-date.
+check_targets() {
+ local var=$1 mak=$2
+ local detected sorted
+
+ pushd "${S}"/configs/targets/ >/dev/null || die
+
+ # Force C locale until glibc is updated. #564936
+ detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
+ sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
+ if [[ ${sorted} != "${detected}" ]] ; then
+ eerror "The ebuild needs to be kept in sync."
+ eerror "${var}: ${sorted}"
+ eerror "$(printf '%-*s' ${#var} configure): ${detected}"
+ die "sync ${var} to the list of targets"
+ fi
+
+ popd >/dev/null
+}
+
+src_prepare() {
+ check_targets IUSE_SOFTMMU_TARGETS softmmu
+ check_targets IUSE_USER_TARGETS linux-user
+
+ default
+
+ # Use correct toolchain to fix cross-compiling
+ tc-export AR AS LD NM OBJCOPY PKG_CONFIG RANLIB STRINGS
+ export WINDRES=${CHOST}-windres
+
+ # Verbose builds
+ MAKEOPTS+=" V=1"
+
+ # Remove bundled modules
+ rm -r subprojects/dtc roms/*/ || die
+}
+
+##
+# configures qemu based on the build directory and the build type
+# we are using.
+#
+qemu_src_configure() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ local buildtype=$1
+ local builddir="${S}/${buildtype}-build"
+
+ mkdir "${builddir}" || die
+
+ local conf_opts=(
+ --prefix=/usr
+ --sysconfdir=/etc
+ --bindir=/usr/bin
+ --libdir=/usr/$(get_libdir)
+ --datadir=/usr/share
+ --docdir=/usr/share/doc/${PF}/html
+ --mandir=/usr/share/man
+ --localstatedir=/var
+ --disable-bsd-user
+ --disable-containers # bug #732972
+ --disable-guest-agent
+ --disable-strip
+ --disable-download
+
+ # bug #746752: TCG interpreter has a few limitations:
+ # - it does not support FPU
+ # - it's generally slower on non-self-modifying code
+ # It's advantage is support for host architectures
+ # where native codegeneration is not implemented.
+ # Gentoo has qemu keyworded only on targets with
+ # native code generation available. Avoid the interpreter.
+ --disable-tcg-interpreter
+
+ --disable-werror
+ # We support gnutls/nettle for crypto operations. It is possible
+ # to use gcrypt when gnutls/nettle are disabled (but not when they
+ # are enabled), but it's not really worth the hassle. Disable it
+ # all the time to avoid automatically detecting it. #568856
+ --disable-gcrypt
+ --cc="$(tc-getCC)"
+ --cxx="$(tc-getCXX)"
+ --objcc="$(tc-getCC)"
+ --host-cc="$(tc-getBUILD_CC)"
+
+ $(use_enable alsa)
+ $(use_enable debug debug-info)
+ $(use_enable debug debug-tcg)
+ $(use_enable jack)
+ $(use_enable nls gettext)
+ $(use_enable oss)
+ $(use_enable pipewire)
+ $(use_enable plugins)
+ $(use_enable pulseaudio pa)
+ $(use_enable selinux)
+ $(use_enable xattr attr)
+ )
+
+ # Disable options not used by user targets. This simplifies building
+ # static user targets (USE=static-user) considerably.
+ conf_notuser() {
+ if [[ ${buildtype} == "user" ]] ; then
+ echo "--disable-${2:-$1}"
+ else
+ use_enable "$@"
+ fi
+ }
+ # Enable option only for softmmu build, but not 'user' or 'tools'
+ conf_softmmu() {
+ if [[ ${buildtype} == "softmmu" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Enable option only for tools build, but not 'user' or 'softmmu'
+ conf_tools() {
+ if [[ ${buildtype} == "tools" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Special case for the malloc flag, because the --disable flag does
+ # not exist and trying like above will break configuring.
+ conf_malloc() {
+ if [[ ! ${buildtype} == "user" ]] ; then
+ usex "${1}" "--enable-malloc=${1}" ""
+ fi
+ }
+ conf_opts+=(
+ $(conf_notuser accessibility brlapi)
+ $(conf_notuser aio linux-aio)
+ $(conf_softmmu bpf)
+ $(conf_notuser bzip2)
+ $(conf_notuser capstone)
+ $(conf_notuser curl)
+ $(conf_tools doc docs)
+ $(conf_notuser fdt)
+ $(conf_notuser fuse)
+ $(conf_notuser glusterfs)
+ $(conf_notuser gnutls)
+ $(conf_notuser gnutls nettle)
+ $(conf_notuser gtk)
+ $(conf_notuser infiniband rdma)
+ $(conf_notuser iscsi libiscsi)
+ $(conf_notuser io-uring linux-io-uring)
+ $(conf_malloc jemalloc)
+ $(conf_notuser jpeg vnc-jpeg)
+ $(conf_notuser kernel_linux kvm)
+ $(conf_notuser keyutils libkeyutils)
+ $(conf_notuser lzo)
+ $(conf_notuser multipath mpath)
+ $(conf_notuser ncurses curses)
+ $(conf_notuser nfs libnfs)
+ $(conf_notuser numa)
+ $(conf_notuser opengl)
+ $(conf_notuser pam auth-pam)
+ $(conf_notuser png)
+ $(conf_notuser rbd)
+ $(conf_notuser sasl vnc-sasl)
+ $(conf_notuser sdl)
+ $(conf_softmmu sdl-image)
+ $(conf_notuser seccomp)
+ $(conf_notuser slirp)
+ $(conf_notuser smartcard)
+ $(conf_notuser snappy)
+ $(conf_notuser spice)
+ $(conf_notuser ssh libssh)
+ $(conf_notuser udev libudev)
+ $(conf_notuser usb libusb)
+ $(conf_notuser usbredir usb-redir)
+ $(conf_notuser vde)
+ $(conf_notuser vhost-net)
+ $(conf_notuser virgl virglrenderer)
+ $(conf_softmmu virtfs)
+ $(conf_notuser vnc)
+ $(conf_notuser vte)
+ $(conf_notuser xen)
+ $(conf_notuser xen xen-pci-passthrough)
+ # use prebuilt keymaps, bug #759604
+ --disable-xkbcommon
+ $(conf_notuser zstd)
+ )
+
+ if [[ ! ${buildtype} == "user" ]] ; then
+ # audio options
+ local audio_opts=(
+ # Note: backend order matters here: #716202
+ # We iterate from higher-level to lower level.
+ $(usex pulseaudio pa "")
+ $(usev pipewire)
+ $(usev jack)
+ $(usev sdl)
+ $(usev alsa)
+ $(usev oss)
+ )
+ conf_opts+=(
+ --audio-drv-list=$(IFS=,; echo "${audio_opts[*]}")
+ )
+ fi
+
+ case ${buildtype} in
+ user)
+ conf_opts+=(
+ --enable-linux-user
+ --disable-system
+ --disable-tools
+ --disable-cap-ng
+ --disable-seccomp
+ )
+ local static_flag="static-user"
+ ;;
+ softmmu)
+ conf_opts+=(
+ --disable-linux-user
+ --enable-system
+ --disable-tools
+ --enable-cap-ng
+ --enable-seccomp
+ )
+ local static_flag="none"
+ ;;
+ tools)
+ conf_opts+=(
+ --disable-linux-user
+ --disable-system
+ --enable-tools
+ --enable-cap-ng
+ )
+ local static_flag="none"
+ ;;
+ esac
+
+ local targets="${buildtype}_targets"
+ [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
+
+ # Add support for SystemTAP
+ use systemtap && conf_opts+=( --enable-trace-backends="dtrace" )
+
+ # We always want to attempt to build with PIE support as it results
+ # in a more secure binary. But it doesn't work with static or if
+ # the current GCC doesn't have PIE support.
+ if [[ ${static_flag} != "none" ]] && use ${static_flag}; then
+ conf_opts+=( --static --disable-pie )
+ else
+ tc-enables-pie && conf_opts+=( --enable-pie )
+ fi
+
+ # Meson will not use a cross-file unless cross_prefix is set.
+ tc-is-cross-compiler && conf_opts+=( --cross-prefix="${CHOST}-" )
+
+ # Plumb through equivalent of EXTRA_ECONF to allow experiments
+ # like bug #747928.
+ conf_opts+=( ${EXTRA_CONF_QEMU} )
+
+ echo "../configure ${conf_opts[*]}"
+ cd "${builddir}"
+ ../configure "${conf_opts[@]}" || die "configure failed"
+}
+
+src_configure() {
+ local target
+
+ python_setup
+
+ softmmu_targets= softmmu_bins=()
+ user_targets= user_bins=()
+
+ for target in ${IUSE_SOFTMMU_TARGETS} ; do
+ if use "qemu_softmmu_targets_${target}"; then
+ softmmu_targets+=",${target}-softmmu"
+ softmmu_bins+=( "qemu-system-${target}" )
+ fi
+ done
+
+ for target in ${IUSE_USER_TARGETS} ; do
+ if use "qemu_user_targets_${target}"; then
+ user_targets+=",${target}-linux-user"
+ user_bins+=( "qemu-${target}" )
+ fi
+ done
+
+ softmmu_targets=${softmmu_targets#,}
+ user_targets=${user_targets#,}
+
+ [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
+ [[ -n ${user_targets} ]] && qemu_src_configure "user"
+ qemu_src_configure "tools"
+}
+
+src_compile() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build" || die
+ default
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build" || die
+ default
+ fi
+
+ cd "${S}/tools-build" || die
+ default
+}
+
+src_test() {
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build" || die
+ pax-mark m */qemu-system-* #515550
+ emake check
+ fi
+}
+
+qemu_python_install() {
+ python_domodule "${S}/python/qemu"
+
+ python_doscript "${S}/scripts/kvm/vmxcap"
+ python_doscript "${S}/scripts/qmp/qmp-shell"
+ python_doscript "${S}/scripts/qmp/qemu-ga-client"
+}
+
+# Generate binfmt support files.
+# - /etc/init.d/qemu-binfmt script which registers the user handlers (openrc)
+# - /usr/share/qemu/binfmt.d/qemu.conf (for use with systemd-binfmt)
+generate_initd() {
+ local out="${T}/qemu-binfmt"
+ local out_systemd="${T}/qemu.conf"
+ local d="${T}/binfmt.d"
+
+ einfo "Generating qemu binfmt scripts and configuration files"
+
+ # Generate the debian fragments first.
+ mkdir -p "${d}"
+ "${S}"/scripts/qemu-binfmt-conf.sh \
+ --debian \
+ --exportdir "${d}" \
+ --qemu-path "${EPREFIX}/usr/bin" \
+ || die
+ # Then turn the fragments into a shell script we can source.
+ sed -E -i \
+ -e 's:^([^ ]+) (.*)$:\1="\2":' \
+ "${d}"/* || die
+
+ # Generate the init.d script by assembling the fragments from above.
+ local f qcpu package interpreter magic mask
+ cat "${FILESDIR}"/qemu-binfmt.initd.head >"${out}" || die
+ for f in "${d}"/qemu-* ; do
+ source "${f}"
+
+ # Normalize the cpu logic like we do in the init.d for the native cpu.
+ qcpu=${package#qemu-}
+ case ${qcpu} in
+ arm*) qcpu="arm";;
+ mips*) qcpu="mips";;
+ ppc*) qcpu="ppc";;
+ s390*) qcpu="s390";;
+ sh*) qcpu="sh";;
+ sparc*) qcpu="sparc";;
+ esac
+
+ # we use 'printf' here to be portable across 'sh'
+ # implementations: #679168
+ cat <<EOF >>"${out}"
+ if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
+ printf '%s\n' ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
+ fi
+EOF
+
+ echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >>"${out_systemd}"
+
+ done
+ cat "${FILESDIR}"/qemu-binfmt.initd.tail >>"${out}" || die
+}
+
+src_install() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build"
+ emake DESTDIR="${ED}" install
+
+ # Install binfmt handler init script for user targets.
+ generate_initd
+ doinitd "${T}/qemu-binfmt"
+
+ # Install binfmt/qemu.conf.
+ insinto "/usr/share/qemu/binfmt.d"
+ doins "${T}/qemu.conf"
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build"
+ emake DESTDIR="${ED}" install
+
+ # This might not exist if the test failed. #512010
+ [[ -e check-report.html ]] && dodoc check-report.html
+
+ if use kernel_linux; then
+ udev_newrules "${FILESDIR}"/65-kvm.rules-r2 65-kvm.rules
+ fi
+
+ if use python; then
+ python_foreach_impl qemu_python_install
+ fi
+ fi
+
+ cd "${S}/tools-build" || die
+ emake DESTDIR="${ED}" install
+
+ # If USE=doc, there'll be newly generated docs which we install instead.
+ if ! use doc && [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ doman "${WORKDIR}"/${PN}-${QEMU_DOCS_VERSION}-docs/docs/*.[0-8]
+ fi
+
+ # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
+ pushd "${ED}"/usr/bin >/dev/null || die
+ pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
+ popd >/dev/null || die
+
+ # Install config file example for qemu-bridge-helper
+ insinto "/etc/qemu"
+ doins "${FILESDIR}/bridge.conf"
+
+ cd "${S}" || die
+ dodoc MAINTAINERS
+ newdoc pc-bios/README README.pc-bios
+
+ # Disallow stripping of prebuilt firmware files.
+ dostrip -x ${QA_PREBUILT}
+
+ if [[ -n ${softmmu_targets} ]]; then
+ # Remove SeaBIOS since we're using the SeaBIOS packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
+ fi
+
+ # Remove vgabios since we're using the seavgabios packaged one
+ rm "${ED}/usr/share/qemu/vgabios.bin"
+ rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
+ rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
+ rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
+ rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
+ rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
+
+ # PPC/PPC64 loads vgabios-stdvga
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64; then
+ dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
+ dosym ../seavgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
+ dosym ../seavgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
+ dosym ../seavgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
+ dosym ../seavgabios/vgabios-virtio.bin /usr/share/qemu/vgabios-virtio.bin
+ dosym ../seavgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
+ fi
+
+ # Remove sgabios since we're using the sgabios packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
+ fi
+
+ # Remove iPXE since we're using the iPXE packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
+ dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
+ dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
+ dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
+ dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
+ dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
+ fi
+ fi
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_create_doc
+}
+
+firmware_abi_change() {
+ local pv
+ for pv in ${REPLACING_VERSIONS}; do
+ if ver_test ${pv} -lt ${FIRMWARE_ABI_VERSION}; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+pkg_postinst() {
+ if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
+ udev_reload
+ fi
+
+ xdg_icon_cache_update
+
+ [[ -z ${EPREFIX} ]] && [[ -f ${EROOT}/usr/libexec/qemu-bridge-helper ]] && \
+ fcaps cap_net_admin "${EROOT}"/usr/libexec/qemu-bridge-helper
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_print_elog
+
+ if use pin-upstream-blobs && firmware_abi_change; then
+ ewarn "This version of qemu pins new versions of firmware blobs:"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ ewarn " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ ewarn " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ ewarn " $(best_version sys-firmware/seabios-bin)"
+ else
+ ewarn " $(best_version sys-firmware/seabios)"
+ fi
+
+ ewarn " $(best_version sys-firmware/ipxe)"
+ ewarn " $(best_version sys-firmware/sgabios)"
+ ewarn "This might break resume of hibernated guests (started with a different"
+ ewarn "firmware version) and live migration to/from qemu versions with different"
+ ewarn "firmware. Please (cold) restart all running guests. For functional"
+ ewarn "guest migration ensure that all"
+ ewarn "hosts run at least"
+ ewarn " app-emulation/qemu-${FIRMWARE_ABI_VERSION}."
+ fi
+}
+
+pkg_info() {
+ echo "Using:"
+ echo " $(best_version app-emulation/spice-protocol)"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ echo " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ echo " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ echo " $(best_version sys-firmware/seabios-bin)"
+ else
+ echo " $(best_version sys-firmware/seabios)"
+ fi
+
+ echo " $(best_version sys-firmware/ipxe)"
+ echo " $(best_version sys-firmware/sgabios)"
+}
+
+pkg_postrm() {
+ xdg_icon_cache_update
+ udev_reload
+}
diff --git a/app-emulation/qemu/qemu-8.2.3.ebuild b/app-emulation/qemu/qemu-8.2.3.ebuild
new file mode 100644
index 000000000000..1c6bab186548
--- /dev/null
+++ b/app-emulation/qemu/qemu-8.2.3.ebuild
@@ -0,0 +1,992 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+# Generate using https://github.com/thesamesam/sam-gentoo-scripts/blob/main/niche/generate-qemu-docs
+# Set to 1 if prebuilt, 0 if not
+# (the construct below is to allow overriding from env for script)
+QEMU_DOCS_PREBUILT=${QEMU_DOCS_PREBUILT:-1}
+QEMU_DOCS_PREBUILT_DEV=sam
+QEMU_DOCS_VERSION=$(ver_cut 1-2).0
+# Default to generating docs (inc. man pages) if no prebuilt; overridden later
+# bug #830088
+QEMU_DOC_USEFLAG="+doc"
+
+PYTHON_COMPAT=( python3_{10..12} )
+PYTHON_REQ_USE="ncurses,readline"
+
+FIRMWARE_ABI_VERSION="7.2.0"
+
+inherit linux-info toolchain-funcs python-r1 udev fcaps readme.gentoo-r1 \
+ pax-utils xdg-utils
+
+if [[ ${PV} == *9999* ]]; then
+ QEMU_DOCS_PREBUILT=0
+
+ EGIT_REPO_URI="https://gitlab.com/qemu-project/qemu.git/"
+ EGIT_SUBMODULES=()
+ inherit git-r3
+ SRC_URI=""
+ declare -A SUBPROJECTS=(
+ [keycodemapdb]="f5772a62ec52591ff6870b7e8ef32482371f22c6"
+ [berkeley-softfloat-3]="b64af41c3276f97f0e181920400ee056b9c88037"
+ [berkeley-testfloat-3]="40619cbb3bf32872df8c53cc457039229428a263"
+ )
+
+ for proj in "${!SUBPROJECTS[@]}"; do
+ c=${SUBPROJECTS[${proj}]}
+ SRC_URI+=" https://gitlab.com/qemu-project/${proj}/-/archive/${c}/${proj}-${c}.tar.bz2"
+ done
+else
+ MY_P="${PN}-${PV/_rc/-rc}"
+ SRC_URI="https://download.qemu.org/${MY_P}.tar.xz"
+
+ if [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ SRC_URI+=" !doc? ( https://dev.gentoo.org/~${QEMU_DOCS_PREBUILT_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${QEMU_DOCS_VERSION}-docs.tar.xz )"
+ fi
+
+ S="${WORKDIR}/${MY_P}"
+ [[ "${PV}" != *_rc* ]] && KEYWORDS="amd64 ~arm arm64 ~loong ~ppc ppc64 ~riscv x86"
+fi
+
+DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
+HOMEPAGE="https://www.qemu.org https://www.linux-kvm.org"
+
+LICENSE="GPL-2 LGPL-2 BSD-2"
+SLOT="0"
+
+[[ ${QEMU_DOCS_PREBUILT} == 1 ]] && QEMU_DOC_USEFLAG="doc"
+
+IUSE="accessibility +aio alsa bpf bzip2 capstone +curl debug ${QEMU_DOC_USEFLAG}
+ +fdt fuse glusterfs +gnutls gtk infiniband iscsi io-uring
+ jack jemalloc +jpeg keyutils
+ lzo multipath
+ ncurses nfs nls numa opengl +oss pam +pin-upstream-blobs pipewire
+ plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
+ +slirp
+ smartcard snappy spice ssh static-user systemtap test udev usb
+ usbredir vde +vhost-net virgl virtfs +vnc vte xattr xen
+ zstd"
+
+COMMON_TARGETS="
+ aarch64
+ alpha
+ arm
+ cris
+ hppa
+ i386
+ loongarch64
+ m68k
+ microblaze
+ microblazeel
+ mips
+ mips64
+ mips64el
+ mipsel
+ nios2
+ or1k
+ ppc
+ ppc64
+ riscv32
+ riscv64
+ s390x
+ sh4
+ sh4eb
+ sparc
+ sparc64
+ x86_64
+ xtensa
+ xtensaeb
+"
+IUSE_SOFTMMU_TARGETS="
+ ${COMMON_TARGETS}
+ avr
+ rx
+ tricore
+"
+IUSE_USER_TARGETS="
+ ${COMMON_TARGETS}
+ aarch64_be
+ armeb
+ hexagon
+ mipsn32
+ mipsn32el
+ ppc64le
+ sparc32plus
+"
+
+use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
+use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
+IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
+
+RESTRICT="!test? ( test )"
+
+# Allow no targets to be built so that people can get a tools-only build.
+# Block USE flag configurations known to not work.
+REQUIRED_USE="
+ ${PYTHON_REQUIRED_USE}
+ qemu_softmmu_targets_arm? ( fdt )
+ qemu_softmmu_targets_microblaze? ( fdt )
+ qemu_softmmu_targets_mips64el? ( fdt )
+ qemu_softmmu_targets_ppc64? ( fdt )
+ qemu_softmmu_targets_ppc? ( fdt )
+ qemu_softmmu_targets_riscv32? ( fdt )
+ qemu_softmmu_targets_riscv64? ( fdt )
+ qemu_softmmu_targets_x86_64? ( fdt )
+ sdl-image? ( sdl )
+ static-user? ( !plugins )
+ virgl? ( opengl )
+ virtfs? ( xattr )
+ vnc? ( gnutls )
+ vte? ( gtk )
+ multipath? ( udev )
+ plugins? ( !static-user )
+"
+for smname in ${IUSE_SOFTMMU_TARGETS} ; do
+ REQUIRED_USE+=" qemu_softmmu_targets_${smname}? ( kernel_linux? ( seccomp ) )"
+done
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# and user/softmmu targets (qemu-*, qemu-system-*).
+#
+# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
+#
+# The attr lib isn't always linked in (although the USE flag is always
+# respected). This is because qemu supports using the C library's API
+# when available rather than always using the external library.
+ALL_DEPEND="
+ dev-libs/glib:2[static-libs(+)]
+ sys-libs/zlib[static-libs(+)]
+ python? ( ${PYTHON_DEPS} )
+ systemtap? ( dev-debug/systemtap )
+ xattr? ( sys-apps/attr[static-libs(+)] )
+"
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# softmmu targets (qemu-system-*).
+SOFTMMU_TOOLS_DEPEND="
+ >=x11-libs/pixman-0.28.0[static-libs(+)]
+ accessibility? (
+ app-accessibility/brltty[api]
+ app-accessibility/brltty[static-libs(+)]
+ )
+ aio? ( dev-libs/libaio[static-libs(+)] )
+ alsa? ( >=media-libs/alsa-lib-1.0.13 )
+ bpf? ( dev-libs/libbpf:= )
+ bzip2? ( app-arch/bzip2[static-libs(+)] )
+ capstone? ( dev-libs/capstone:=[static-libs(+)] )
+ curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
+ fdt? ( >=sys-apps/dtc-1.5.1[static-libs(+)] )
+ fuse? ( >=sys-fs/fuse-3.1:3[static-libs(+)] )
+ glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
+ gnutls? (
+ >=net-libs/gnutls-3.0:=[static-libs(+)]
+ dev-libs/nettle:=[static-libs(+)]
+ )
+ gtk? (
+ x11-libs/gtk+:3
+ vte? ( x11-libs/vte:2.91 )
+ )
+ infiniband? ( sys-cluster/rdma-core[static-libs(+)] )
+ iscsi? ( net-libs/libiscsi )
+ io-uring? ( sys-libs/liburing:=[static-libs(+)] )
+ jack? ( virtual/jack )
+ jemalloc? ( dev-libs/jemalloc )
+ jpeg? ( media-libs/libjpeg-turbo:=[static-libs(+)] )
+ kernel_linux? ( sys-libs/libcap-ng[static-libs(+)] )
+ keyutils? ( sys-apps/keyutils[static-libs(+)] )
+ lzo? ( dev-libs/lzo:2[static-libs(+)] )
+ multipath? ( sys-fs/multipath-tools )
+ ncurses? (
+ sys-libs/ncurses:=[unicode(+)]
+ sys-libs/ncurses:=[static-libs(+)]
+ )
+ nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
+ numa? ( sys-process/numactl[static-libs(+)] )
+ opengl? (
+ virtual/opengl
+ media-libs/libepoxy[static-libs(+)]
+ media-libs/mesa[static-libs(+)]
+ media-libs/mesa[egl(+),gbm(+)]
+ )
+ pam? ( sys-libs/pam )
+ pipewire? ( >=media-video/pipewire-0.3.60 )
+ png? ( >=media-libs/libpng-1.6.34:=[static-libs(+)] )
+ pulseaudio? ( media-libs/libpulse )
+ rbd? ( sys-cluster/ceph )
+ sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
+ sdl? (
+ media-libs/libsdl2[video]
+ media-libs/libsdl2[static-libs(+)]
+ )
+ sdl-image? ( media-libs/sdl2-image[static-libs(+)] )
+ seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
+ slirp? ( net-libs/libslirp[static-libs(+)] )
+ smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
+ snappy? ( app-arch/snappy:= )
+ spice? (
+ >=app-emulation/spice-protocol-0.14.0
+ >=app-emulation/spice-0.14.0[static-libs(+)]
+ )
+ ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
+ udev? ( virtual/libudev:= )
+ usb? ( >=virtual/libusb-1-r2:1[static-libs(+)] )
+ usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
+ vde? ( net-misc/vde[static-libs(+)] )
+ virgl? ( media-libs/virglrenderer[static-libs(+)] )
+ virtfs? ( sys-libs/libcap )
+ xen? ( app-emulation/xen-tools:= )
+ zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
+"
+
+EDK2_OVMF_VERSION="202202"
+SEABIOS_VERSION="1.16.0"
+
+X86_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ ~sys-firmware/ipxe-1.21.1[binary,qemu]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ ~sys-firmware/sgabios-0.1_pre10[binary]
+ )
+ !pin-upstream-blobs? (
+ || (
+ >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ >=sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ )
+ sys-firmware/ipxe[qemu]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ sys-firmware/sgabios
+ )
+"
+PPC_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ !pin-upstream-blobs? (
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ )
+"
+
+# See bug #913084 for pip dep
+BDEPEND="
+ $(python_gen_impl_dep)
+ dev-lang/perl
+ >=dev-build/meson-0.63.0
+ app-alternatives/ninja
+ dev-python/pip[${PYTHON_USEDEP}]
+ virtual/pkgconfig
+ doc? (
+ >=dev-python/sphinx-1.6.0[${PYTHON_USEDEP}]
+ dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
+ )
+ gtk? ( nls? ( sys-devel/gettext ) )
+ test? (
+ dev-libs/glib[utils]
+ app-alternatives/bc
+ )
+"
+CDEPEND="
+ ${ALL_DEPEND//\[static-libs(+)]}
+ ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
+ qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc? ( ${PPC_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc64? ( ${PPC_FIRMWARE_DEPEND} )
+"
+DEPEND="
+ ${CDEPEND}
+ kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
+ static-user? ( ${ALL_DEPEND} )
+"
+RDEPEND="
+ ${CDEPEND}
+ acct-group/kvm
+ selinux? (
+ sec-policy/selinux-qemu
+ sys-libs/libselinux
+ )
+"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-8.0.0-disable-keymap.patch
+ "${FILESDIR}"/${PN}-7.1.0-capstone-include-path.patch
+ "${FILESDIR}"/${PN}-8.1.0-also-build-virtfs-proxy-helper.patch
+ "${FILESDIR}"/${PN}-8.1.0-skip-tests.patch
+ "${FILESDIR}"/${PN}-8.1.0-find-sphinx.patch
+)
+
+QA_PREBUILT="
+ usr/share/qemu/hppa-firmware.img
+ usr/share/qemu/openbios-ppc
+ usr/share/qemu/openbios-sparc64
+ usr/share/qemu/openbios-sparc32
+ usr/share/qemu/opensbi-riscv64-generic-fw_dynamic.elf
+ usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.elf
+ usr/share/qemu/palcode-clipper
+ usr/share/qemu/s390-ccw.img
+ usr/share/qemu/s390-netboot.img
+ usr/share/qemu/u-boot.e500
+"
+
+QA_WX_LOAD="
+ usr/bin/qemu-i386
+ usr/bin/qemu-x86_64
+ usr/bin/qemu-alpha
+ usr/bin/qemu-arm
+ usr/bin/qemu-cris
+ usr/bin/qemu-m68k
+ usr/bin/qemu-microblaze
+ usr/bin/qemu-microblazeel
+ usr/bin/qemu-mips
+ usr/bin/qemu-mipsel
+ usr/bin/qemu-or1k
+ usr/bin/qemu-ppc
+ usr/bin/qemu-ppc64
+ usr/bin/qemu-sh4
+ usr/bin/qemu-sh4eb
+ usr/bin/qemu-sparc
+ usr/bin/qemu-sparc64
+ usr/bin/qemu-armeb
+ usr/bin/qemu-sparc32plus
+ usr/bin/qemu-s390x
+ usr/bin/qemu-unicore32
+"
+
+DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
+kernel module loaded before running kvm. The easiest way to ensure that the
+kernel module is loaded is to load it on boot.
+ For AMD CPUs the module is called 'kvm-amd'.
+ For Intel CPUs the module is called 'kvm-intel'.
+Please review /etc/conf.d/modules for how to load these.
+
+Make sure your user is in the 'kvm' group. Just run
+ $ gpasswd -a <USER> kvm
+then have <USER> re-login.
+
+For brand new installs, the default permissions on /dev/kvm might not let
+you access it. You can tell udev to reset ownership/perms:
+ $ udevadm trigger -c add /dev/kvm
+
+If you want to register binfmt handlers for qemu user targets:
+For openrc:
+ # rc-update add qemu-binfmt
+For systemd:
+ # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
+
+pkg_pretend() {
+ if use kernel_linux && kernel_is lt 2 6 25; then
+ eerror "This version of KVM requires a host kernel of 2.6.25 or higher."
+ elif use kernel_linux; then
+ if ! linux_config_exists; then
+ eerror "Unable to check your kernel for KVM support"
+ else
+ CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
+ ERROR_KVM="You must enable KVM in your kernel to continue"
+ ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
+ ERROR_KVM_AMD+=" your kernel configuration."
+ ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
+ ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
+ ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
+ ERROR_TUN+=" into your kernel or loaded as a module to use the"
+ ERROR_TUN+=" virtual network device if using -net tap."
+ ERROR_BRIDGE="You will also need support for 802.1d"
+ ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
+ use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
+ ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
+ ERROR_VHOST_NET+=" support"
+
+ if use amd64 || use x86 || use amd64-linux || use x86-linux; then
+ if grep -q AuthenticAMD /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_AMD"
+ elif grep -q GenuineIntel /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_INTEL"
+ fi
+ fi
+
+ use python && CONFIG_CHECK+=" ~DEBUG_FS"
+ ERROR_DEBUG_FS="debugFS support required for kvm_stat"
+
+ # Now do the actual checks setup above
+ check_extra_config
+ fi
+ fi
+
+ if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
+ eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
+ eerror "instances are still pointing to it. Please update your"
+ eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
+ eerror "and the right system binary (e.g. qemu-system-x86_64)."
+ die "update your virt configs to not use qemu-kvm"
+ fi
+}
+
+# Sanity check to make sure target lists are kept up-to-date.
+check_targets() {
+ local var=$1 mak=$2
+ local detected sorted
+
+ pushd "${S}"/configs/targets/ >/dev/null || die
+
+ # Force C locale until glibc is updated. #564936
+ detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
+ sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
+ if [[ ${sorted} != "${detected}" ]] ; then
+ eerror "The ebuild needs to be kept in sync."
+ eerror "${var}: ${sorted}"
+ eerror "$(printf '%-*s' ${#var} configure): ${detected}"
+ die "sync ${var} to the list of targets"
+ fi
+
+ popd >/dev/null
+}
+
+src_unpack() {
+ if [[ ${PV} == 9999 ]] ; then
+ git-r3_src_unpack
+ for file in ${A}; do
+ unpack "${file}"
+ done
+ cd "${WORKDIR}" || die
+ for proj in "${!SUBPROJECTS[@]}"; do
+ mv "${proj}-${SUBPROJECTS[${proj}]}" "${S}/subprojects/${proj}" || die
+ done
+ cd "${S}" || die
+ meson subprojects packagefiles --apply || die
+ else
+ default
+ fi
+}
+
+src_prepare() {
+ check_targets IUSE_SOFTMMU_TARGETS softmmu
+ check_targets IUSE_USER_TARGETS linux-user
+
+ default
+
+ # Use correct toolchain to fix cross-compiling
+ tc-export AR AS LD NM OBJCOPY PKG_CONFIG RANLIB STRINGS
+ export WINDRES=${CHOST}-windres
+
+ # Verbose builds
+ MAKEOPTS+=" V=1"
+
+ # Remove bundled modules
+ rm -r roms/*/ || die
+}
+
+##
+# configures qemu based on the build directory and the build type
+# we are using.
+#
+qemu_src_configure() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ local buildtype=$1
+ local builddir="${S}/${buildtype}-build"
+
+ mkdir "${builddir}" || die
+
+ local conf_opts=(
+ --prefix=/usr
+ --sysconfdir=/etc
+ --bindir=/usr/bin
+ --libdir=/usr/$(get_libdir)
+ --datadir=/usr/share
+ --docdir=/usr/share/doc/${PF}/html
+ --mandir=/usr/share/man
+ --localstatedir=/var
+ --disable-bsd-user
+ --disable-containers # bug #732972
+ --disable-guest-agent
+ --disable-strip
+ --disable-download
+
+ # bug #746752: TCG interpreter has a few limitations:
+ # - it does not support FPU
+ # - it's generally slower on non-self-modifying code
+ # It's advantage is support for host architectures
+ # where native codegeneration is not implemented.
+ # Gentoo has qemu keyworded only on targets with
+ # native code generation available. Avoid the interpreter.
+ --disable-tcg-interpreter
+
+ --disable-werror
+ # We support gnutls/nettle for crypto operations. It is possible
+ # to use gcrypt when gnutls/nettle are disabled (but not when they
+ # are enabled), but it's not really worth the hassle. Disable it
+ # all the time to avoid automatically detecting it. #568856
+ --disable-gcrypt
+ --cc="$(tc-getCC)"
+ --cxx="$(tc-getCXX)"
+ --objcc="$(tc-getCC)"
+ --host-cc="$(tc-getBUILD_CC)"
+
+ $(use_enable alsa)
+ $(use_enable debug debug-info)
+ $(use_enable debug debug-tcg)
+ $(use_enable jack)
+ $(use_enable nls gettext)
+ $(use_enable oss)
+ $(use_enable pipewire)
+ $(use_enable plugins)
+ $(use_enable pulseaudio pa)
+ $(use_enable selinux)
+ $(use_enable xattr attr)
+ )
+
+ # Disable options not used by user targets. This simplifies building
+ # static user targets (USE=static-user) considerably.
+ conf_notuser() {
+ if [[ ${buildtype} == "user" ]] ; then
+ echo "--disable-${2:-$1}"
+ else
+ use_enable "$@"
+ fi
+ }
+ # Enable option only for softmmu build, but not 'user' or 'tools'
+ conf_softmmu() {
+ if [[ ${buildtype} == "softmmu" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Enable option only for tools build, but not 'user' or 'softmmu'
+ conf_tools() {
+ if [[ ${buildtype} == "tools" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Special case for the malloc flag, because the --disable flag does
+ # not exist and trying like above will break configuring.
+ conf_malloc() {
+ if [[ ! ${buildtype} == "user" ]] ; then
+ usex "${1}" "--enable-malloc=${1}" ""
+ fi
+ }
+ conf_opts+=(
+ $(conf_notuser accessibility brlapi)
+ $(conf_notuser aio linux-aio)
+ $(conf_softmmu bpf)
+ $(conf_notuser bzip2)
+ $(conf_notuser capstone)
+ $(conf_notuser curl)
+ $(conf_tools doc docs)
+ $(conf_notuser fdt)
+ $(conf_notuser fuse)
+ $(conf_notuser glusterfs)
+ $(conf_notuser gnutls)
+ $(conf_notuser gnutls nettle)
+ $(conf_notuser gtk)
+ $(conf_notuser infiniband rdma)
+ $(conf_notuser iscsi libiscsi)
+ $(conf_notuser io-uring linux-io-uring)
+ $(conf_malloc jemalloc)
+ $(conf_notuser jpeg vnc-jpeg)
+ $(conf_notuser kernel_linux kvm)
+ $(conf_notuser keyutils libkeyutils)
+ $(conf_notuser lzo)
+ $(conf_notuser multipath mpath)
+ $(conf_notuser ncurses curses)
+ $(conf_notuser nfs libnfs)
+ $(conf_notuser numa)
+ $(conf_notuser opengl)
+ $(conf_notuser pam auth-pam)
+ $(conf_notuser png)
+ $(conf_notuser rbd)
+ $(conf_notuser sasl vnc-sasl)
+ $(conf_notuser sdl)
+ $(conf_softmmu sdl-image)
+ $(conf_notuser seccomp)
+ $(conf_notuser slirp)
+ $(conf_notuser smartcard)
+ $(conf_notuser snappy)
+ $(conf_notuser spice)
+ $(conf_notuser ssh libssh)
+ $(conf_notuser udev libudev)
+ $(conf_notuser usb libusb)
+ $(conf_notuser usbredir usb-redir)
+ $(conf_notuser vde)
+ $(conf_notuser vhost-net)
+ $(conf_notuser virgl virglrenderer)
+ $(conf_softmmu virtfs)
+ $(conf_notuser vnc)
+ $(conf_notuser vte)
+ $(conf_notuser xen)
+ $(conf_notuser xen xen-pci-passthrough)
+ # use prebuilt keymaps, bug #759604
+ --disable-xkbcommon
+ $(conf_notuser zstd)
+ )
+
+ if [[ ! ${buildtype} == "user" ]] ; then
+ # audio options
+ local audio_opts=(
+ # Note: backend order matters here: #716202
+ # We iterate from higher-level to lower level.
+ $(usex pulseaudio pa "")
+ $(usev pipewire)
+ $(usev jack)
+ $(usev sdl)
+ $(usev alsa)
+ $(usev oss)
+ )
+ conf_opts+=(
+ --audio-drv-list=$(IFS=,; echo "${audio_opts[*]}")
+ )
+ fi
+
+ case ${buildtype} in
+ user)
+ conf_opts+=(
+ --enable-linux-user
+ --disable-system
+ --disable-tools
+ --disable-cap-ng
+ --disable-seccomp
+ )
+ local static_flag="static-user"
+ ;;
+ softmmu)
+ conf_opts+=(
+ --disable-linux-user
+ --enable-system
+ --disable-tools
+ --enable-cap-ng
+ --enable-seccomp
+ )
+ local static_flag="none"
+ ;;
+ tools)
+ conf_opts+=(
+ --disable-linux-user
+ --disable-system
+ --enable-tools
+ --enable-cap-ng
+ )
+ local static_flag="none"
+ ;;
+ esac
+
+ local targets="${buildtype}_targets"
+ [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
+
+ # Add support for SystemTAP
+ use systemtap && conf_opts+=( --enable-trace-backends="dtrace" )
+
+ # We always want to attempt to build with PIE support as it results
+ # in a more secure binary. But it doesn't work with static or if
+ # the current GCC doesn't have PIE support.
+ if [[ ${static_flag} != "none" ]] && use ${static_flag}; then
+ conf_opts+=( --static --disable-pie )
+ else
+ tc-enables-pie && conf_opts+=( --enable-pie )
+ fi
+
+ # Meson will not use a cross-file unless cross_prefix is set.
+ tc-is-cross-compiler && conf_opts+=( --cross-prefix="${CHOST}-" )
+
+ # Plumb through equivalent of EXTRA_ECONF to allow experiments
+ # like bug #747928.
+ conf_opts+=( ${EXTRA_CONF_QEMU} )
+
+ echo "../configure ${conf_opts[*]}"
+ cd "${builddir}"
+ ../configure "${conf_opts[@]}" || die "configure failed"
+}
+
+src_configure() {
+ local target
+
+ python_setup
+
+ softmmu_targets= softmmu_bins=()
+ user_targets= user_bins=()
+
+ for target in ${IUSE_SOFTMMU_TARGETS} ; do
+ if use "qemu_softmmu_targets_${target}"; then
+ softmmu_targets+=",${target}-softmmu"
+ softmmu_bins+=( "qemu-system-${target}" )
+ fi
+ done
+
+ for target in ${IUSE_USER_TARGETS} ; do
+ if use "qemu_user_targets_${target}"; then
+ user_targets+=",${target}-linux-user"
+ user_bins+=( "qemu-${target}" )
+ fi
+ done
+
+ softmmu_targets=${softmmu_targets#,}
+ user_targets=${user_targets#,}
+
+ [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
+ [[ -n ${user_targets} ]] && qemu_src_configure "user"
+ qemu_src_configure "tools"
+}
+
+src_compile() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build" || die
+ default
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build" || die
+ default
+ fi
+
+ cd "${S}/tools-build" || die
+ default
+}
+
+src_test() {
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build" || die
+ pax-mark m */qemu-system-* #515550
+ emake check
+ fi
+}
+
+qemu_python_install() {
+ python_domodule "${S}/python/qemu"
+
+ python_doscript "${S}/scripts/kvm/vmxcap"
+ python_doscript "${S}/scripts/qmp/qmp-shell"
+ python_doscript "${S}/scripts/qmp/qemu-ga-client"
+}
+
+# Generate binfmt support files.
+# - /etc/init.d/qemu-binfmt script which registers the user handlers (openrc)
+# - /usr/share/qemu/binfmt.d/qemu.conf (for use with systemd-binfmt)
+generate_initd() {
+ local out="${T}/qemu-binfmt"
+ local out_systemd="${T}/qemu.conf"
+ local d="${T}/binfmt.d"
+
+ einfo "Generating qemu binfmt scripts and configuration files"
+
+ # Generate the debian fragments first.
+ mkdir -p "${d}"
+ "${S}"/scripts/qemu-binfmt-conf.sh \
+ --debian \
+ --exportdir "${d}" \
+ --qemu-path "${EPREFIX}/usr/bin" \
+ || die
+ # Then turn the fragments into a shell script we can source.
+ sed -E -i \
+ -e 's:^([^ ]+) (.*)$:\1="\2":' \
+ "${d}"/* || die
+
+ # Generate the init.d script by assembling the fragments from above.
+ local f qcpu package interpreter magic mask
+ cat "${FILESDIR}"/qemu-binfmt.initd.head >"${out}" || die
+ for f in "${d}"/qemu-* ; do
+ source "${f}"
+
+ # Normalize the cpu logic like we do in the init.d for the native cpu.
+ qcpu=${package#qemu-}
+ case ${qcpu} in
+ arm*) qcpu="arm";;
+ mips*) qcpu="mips";;
+ ppc*) qcpu="ppc";;
+ s390*) qcpu="s390";;
+ sh*) qcpu="sh";;
+ sparc*) qcpu="sparc";;
+ esac
+
+ # we use 'printf' here to be portable across 'sh'
+ # implementations: #679168
+ cat <<EOF >>"${out}"
+ if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
+ printf '%s\n' ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
+ fi
+EOF
+
+ echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >>"${out_systemd}"
+
+ done
+ cat "${FILESDIR}"/qemu-binfmt.initd.tail >>"${out}" || die
+}
+
+src_install() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build"
+ emake DESTDIR="${ED}" install
+
+ # Install binfmt handler init script for user targets.
+ generate_initd
+ doinitd "${T}/qemu-binfmt"
+
+ # Install binfmt/qemu.conf.
+ insinto "/usr/share/qemu/binfmt.d"
+ doins "${T}/qemu.conf"
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build"
+ emake DESTDIR="${ED}" install
+
+ # This might not exist if the test failed. #512010
+ [[ -e check-report.html ]] && dodoc check-report.html
+
+ if use kernel_linux; then
+ udev_newrules "${FILESDIR}"/65-kvm.rules-r2 65-kvm.rules
+ fi
+
+ if use python; then
+ python_foreach_impl qemu_python_install
+ fi
+ fi
+
+ cd "${S}/tools-build" || die
+ emake DESTDIR="${ED}" install
+
+ # If USE=doc, there'll be newly generated docs which we install instead.
+ if ! use doc && [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ doman "${WORKDIR}"/${PN}-${QEMU_DOCS_VERSION}-docs/docs/*.[0-8]
+ fi
+
+ # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
+ pushd "${ED}"/usr/bin >/dev/null || die
+ pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
+ popd >/dev/null || die
+
+ # Install config file example for qemu-bridge-helper
+ insinto "/etc/qemu"
+ doins "${FILESDIR}/bridge.conf"
+
+ cd "${S}" || die
+ dodoc MAINTAINERS
+ newdoc pc-bios/README README.pc-bios
+
+ # Disallow stripping of prebuilt firmware files.
+ dostrip -x ${QA_PREBUILT}
+
+ if [[ -n ${softmmu_targets} ]]; then
+ # Remove SeaBIOS since we're using the SeaBIOS packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
+ fi
+
+ # Remove vgabios since we're using the seavgabios packaged one
+ rm "${ED}/usr/share/qemu/vgabios.bin"
+ rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
+ rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
+ rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
+ rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
+ rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
+
+ # PPC/PPC64 loads vgabios-stdvga
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64; then
+ dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
+ dosym ../seavgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
+ dosym ../seavgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
+ dosym ../seavgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
+ dosym ../seavgabios/vgabios-virtio.bin /usr/share/qemu/vgabios-virtio.bin
+ dosym ../seavgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
+ fi
+
+ # Remove sgabios since we're using the sgabios packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
+ fi
+
+ # Remove iPXE since we're using the iPXE packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
+ dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
+ dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
+ dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
+ dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
+ dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
+ fi
+ fi
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_create_doc
+}
+
+firmware_abi_change() {
+ local pv
+ for pv in ${REPLACING_VERSIONS}; do
+ if ver_test ${pv} -lt ${FIRMWARE_ABI_VERSION}; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+pkg_postinst() {
+ if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
+ udev_reload
+ fi
+
+ xdg_icon_cache_update
+
+ [[ -z ${EPREFIX} ]] && [[ -f ${EROOT}/usr/libexec/qemu-bridge-helper ]] && \
+ fcaps cap_net_admin "${EROOT}"/usr/libexec/qemu-bridge-helper
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_print_elog
+
+ if use pin-upstream-blobs && firmware_abi_change; then
+ ewarn "This version of qemu pins new versions of firmware blobs:"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ ewarn " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ ewarn " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ ewarn " $(best_version sys-firmware/seabios-bin)"
+ else
+ ewarn " $(best_version sys-firmware/seabios)"
+ fi
+
+ ewarn " $(best_version sys-firmware/ipxe)"
+ ewarn " $(best_version sys-firmware/sgabios)"
+ ewarn "This might break resume of hibernated guests (started with a different"
+ ewarn "firmware version) and live migration to/from qemu versions with different"
+ ewarn "firmware. Please (cold) restart all running guests. For functional"
+ ewarn "guest migration ensure that all"
+ ewarn "hosts run at least"
+ ewarn " app-emulation/qemu-${FIRMWARE_ABI_VERSION}."
+ fi
+}
+
+pkg_info() {
+ echo "Using:"
+ echo " $(best_version app-emulation/spice-protocol)"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ echo " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ echo " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ echo " $(best_version sys-firmware/seabios-bin)"
+ else
+ echo " $(best_version sys-firmware/seabios)"
+ fi
+
+ echo " $(best_version sys-firmware/ipxe)"
+ echo " $(best_version sys-firmware/sgabios)"
+}
+
+pkg_postrm() {
+ xdg_icon_cache_update
+ udev_reload
+}
diff --git a/app-emulation/qemu/qemu-9.0.0.ebuild b/app-emulation/qemu/qemu-9.0.0.ebuild
new file mode 100644
index 000000000000..179ca305b449
--- /dev/null
+++ b/app-emulation/qemu/qemu-9.0.0.ebuild
@@ -0,0 +1,996 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+# Generate using https://github.com/thesamesam/sam-gentoo-scripts/blob/main/niche/generate-qemu-docs
+# Set to 1 if prebuilt, 0 if not
+# (the construct below is to allow overriding from env for script)
+QEMU_DOCS_PREBUILT=${QEMU_DOCS_PREBUILT:-1}
+QEMU_DOCS_PREBUILT_DEV=sam
+QEMU_DOCS_VERSION=$(ver_cut 1-3)
+# Default to generating docs (inc. man pages) if no prebuilt; overridden later
+# bug #830088
+QEMU_DOC_USEFLAG="+doc"
+
+PYTHON_COMPAT=( python3_{10..12} )
+PYTHON_REQ_USE="ncurses,readline"
+
+FIRMWARE_ABI_VERSION="7.2.0"
+
+inherit linux-info toolchain-funcs python-r1 udev fcaps readme.gentoo-r1 \
+ pax-utils xdg-utils
+
+if [[ ${PV} == *9999* ]]; then
+ QEMU_DOCS_PREBUILT=0
+
+ EGIT_REPO_URI="https://gitlab.com/qemu-project/qemu.git/"
+ EGIT_SUBMODULES=()
+ inherit git-r3
+ SRC_URI=""
+ declare -A SUBPROJECTS=(
+ [keycodemapdb]="f5772a62ec52591ff6870b7e8ef32482371f22c6"
+ [berkeley-softfloat-3]="b64af41c3276f97f0e181920400ee056b9c88037"
+ [berkeley-testfloat-3]="e7af9751d9f9fd3b47911f51a5cfd08af256a9ab"
+ )
+
+ for proj in "${!SUBPROJECTS[@]}"; do
+ c=${SUBPROJECTS[${proj}]}
+ SRC_URI+=" https://gitlab.com/qemu-project/${proj}/-/archive/${c}/${proj}-${c}.tar.bz2"
+ done
+else
+ MY_P="${PN}-${PV/_rc/-rc}"
+ SRC_URI="https://download.qemu.org/${MY_P}.tar.xz"
+
+ if [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ SRC_URI+=" !doc? ( https://dev.gentoo.org/~${QEMU_DOCS_PREBUILT_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${QEMU_DOCS_VERSION}-docs.tar.xz )"
+ fi
+
+ S="${WORKDIR}/${MY_P}"
+ [[ "${PV}" != *_rc* ]] && KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
+fi
+
+DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
+HOMEPAGE="https://www.qemu.org https://www.linux-kvm.org"
+
+LICENSE="GPL-2 LGPL-2 BSD-2"
+SLOT="0"
+
+[[ ${QEMU_DOCS_PREBUILT} == 1 ]] && QEMU_DOC_USEFLAG="doc"
+
+IUSE="accessibility +aio alsa bpf bzip2 capstone +curl debug ${QEMU_DOC_USEFLAG}
+ +fdt fuse glusterfs +gnutls gtk infiniband iscsi io-uring
+ jack jemalloc +jpeg keyutils
+ lzo multipath
+ ncurses nfs nls numa opengl +oss pam +pin-upstream-blobs pipewire
+ plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
+ +slirp
+ smartcard snappy spice ssh static-user systemtap test udev usb
+ usbredir vde +vhost-net virgl virtfs +vnc vte xattr xen
+ zstd"
+
+COMMON_TARGETS="
+ aarch64
+ alpha
+ arm
+ cris
+ hppa
+ i386
+ loongarch64
+ m68k
+ microblaze
+ microblazeel
+ mips
+ mips64
+ mips64el
+ mipsel
+ nios2
+ or1k
+ ppc
+ ppc64
+ riscv32
+ riscv64
+ s390x
+ sh4
+ sh4eb
+ sparc
+ sparc64
+ x86_64
+ xtensa
+ xtensaeb
+"
+IUSE_SOFTMMU_TARGETS="
+ ${COMMON_TARGETS}
+ avr
+ rx
+ tricore
+"
+IUSE_USER_TARGETS="
+ ${COMMON_TARGETS}
+ aarch64_be
+ armeb
+ hexagon
+ mipsn32
+ mipsn32el
+ ppc64le
+ sparc32plus
+"
+
+use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
+use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
+IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
+
+RESTRICT="!test? ( test )"
+
+# Allow no targets to be built so that people can get a tools-only build.
+# Block USE flag configurations known to not work.
+REQUIRED_USE="
+ ${PYTHON_REQUIRED_USE}
+ qemu_softmmu_targets_arm? ( fdt )
+ qemu_softmmu_targets_microblaze? ( fdt )
+ qemu_softmmu_targets_mips64el? ( fdt )
+ qemu_softmmu_targets_ppc64? ( fdt )
+ qemu_softmmu_targets_ppc? ( fdt )
+ qemu_softmmu_targets_riscv32? ( fdt )
+ qemu_softmmu_targets_riscv64? ( fdt )
+ qemu_softmmu_targets_x86_64? ( fdt )
+ sdl-image? ( sdl )
+ static-user? ( !plugins )
+ virgl? ( opengl )
+ virtfs? ( xattr )
+ vnc? ( gnutls )
+ vte? ( gtk )
+ multipath? ( udev )
+ plugins? ( !static-user )
+"
+for smname in ${IUSE_SOFTMMU_TARGETS} ; do
+ REQUIRED_USE+=" qemu_softmmu_targets_${smname}? ( kernel_linux? ( seccomp ) )"
+done
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# and user/softmmu targets (qemu-*, qemu-system-*).
+#
+# Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
+#
+# The attr lib isn't always linked in (although the USE flag is always
+# respected). This is because qemu supports using the C library's API
+# when available rather than always using the external library.
+ALL_DEPEND="
+ dev-libs/glib:2[static-libs(+)]
+ sys-libs/zlib[static-libs(+)]
+ python? ( ${PYTHON_DEPS} )
+ systemtap? ( dev-debug/systemtap )
+ xattr? ( sys-apps/attr[static-libs(+)] )
+"
+
+# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
+# softmmu targets (qemu-system-*).
+SOFTMMU_TOOLS_DEPEND="
+ >=x11-libs/pixman-0.28.0[static-libs(+)]
+ accessibility? (
+ app-accessibility/brltty[api]
+ app-accessibility/brltty[static-libs(+)]
+ )
+ aio? ( dev-libs/libaio[static-libs(+)] )
+ alsa? ( >=media-libs/alsa-lib-1.0.13 )
+ bpf? ( dev-libs/libbpf:= )
+ bzip2? ( app-arch/bzip2[static-libs(+)] )
+ capstone? ( dev-libs/capstone:=[static-libs(+)] )
+ curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
+ fdt? ( >=sys-apps/dtc-1.5.1[static-libs(+)] )
+ fuse? ( >=sys-fs/fuse-3.1:3[static-libs(+)] )
+ glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
+ gnutls? (
+ >=net-libs/gnutls-3.0:=[static-libs(+)]
+ dev-libs/nettle:=[static-libs(+)]
+ )
+ gtk? (
+ x11-libs/gtk+:3
+ vte? ( x11-libs/vte:2.91 )
+ )
+ infiniband? ( sys-cluster/rdma-core[static-libs(+)] )
+ iscsi? ( net-libs/libiscsi )
+ io-uring? ( sys-libs/liburing:=[static-libs(+)] )
+ jack? ( virtual/jack )
+ jemalloc? ( dev-libs/jemalloc )
+ jpeg? ( media-libs/libjpeg-turbo:=[static-libs(+)] )
+ kernel_linux? ( sys-libs/libcap-ng[static-libs(+)] )
+ keyutils? ( sys-apps/keyutils[static-libs(+)] )
+ lzo? ( dev-libs/lzo:2[static-libs(+)] )
+ multipath? ( sys-fs/multipath-tools )
+ ncurses? (
+ sys-libs/ncurses:=[unicode(+)]
+ sys-libs/ncurses:=[static-libs(+)]
+ )
+ nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
+ numa? ( sys-process/numactl[static-libs(+)] )
+ opengl? (
+ virtual/opengl
+ media-libs/libepoxy[static-libs(+)]
+ media-libs/mesa[static-libs(+)]
+ media-libs/mesa[egl(+),gbm(+)]
+ )
+ pam? ( sys-libs/pam )
+ pipewire? ( >=media-video/pipewire-0.3.60 )
+ png? ( >=media-libs/libpng-1.6.34:=[static-libs(+)] )
+ pulseaudio? ( media-libs/libpulse )
+ rbd? ( sys-cluster/ceph )
+ sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
+ sdl? (
+ media-libs/libsdl2[video]
+ media-libs/libsdl2[static-libs(+)]
+ )
+ sdl-image? ( media-libs/sdl2-image[static-libs(+)] )
+ seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
+ slirp? ( net-libs/libslirp[static-libs(+)] )
+ smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
+ snappy? ( app-arch/snappy:= )
+ spice? (
+ >=app-emulation/spice-protocol-0.14.0
+ >=app-emulation/spice-0.14.0[static-libs(+)]
+ )
+ ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
+ udev? ( virtual/libudev:= )
+ usb? ( >=virtual/libusb-1-r2:1[static-libs(+)] )
+ usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
+ vde? ( net-misc/vde[static-libs(+)] )
+ virgl? ( media-libs/virglrenderer[static-libs(+)] )
+ virtfs? ( sys-libs/libcap )
+ xen? ( app-emulation/xen-tools:= )
+ zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
+"
+
+EDK2_OVMF_VERSION="202202"
+SEABIOS_VERSION="1.16.0"
+
+X86_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ ~sys-firmware/ipxe-1.21.1[binary,qemu]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ ~sys-firmware/sgabios-0.1_pre10[binary]
+ )
+ !pin-upstream-blobs? (
+ || (
+ >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ >=sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ )
+ sys-firmware/ipxe[qemu]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ sys-firmware/sgabios
+ )
+"
+PPC_FIRMWARE_DEPEND="
+ pin-upstream-blobs? (
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ !pin-upstream-blobs? (
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
+ )
+"
+
+# See bug #913084 for pip dep
+BDEPEND="
+ $(python_gen_impl_dep)
+ dev-lang/perl
+ >=dev-build/meson-0.63.0
+ app-alternatives/ninja
+ dev-python/pip[${PYTHON_USEDEP}]
+ virtual/pkgconfig
+ doc? (
+ >=dev-python/sphinx-1.6.0[${PYTHON_USEDEP}]
+ dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
+ )
+ gtk? ( nls? ( sys-devel/gettext ) )
+ test? (
+ dev-libs/glib[utils]
+ app-alternatives/bc
+ )
+"
+CDEPEND="
+ ${ALL_DEPEND//\[static-libs(+)]}
+ ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
+ qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc? ( ${PPC_FIRMWARE_DEPEND} )
+ qemu_softmmu_targets_ppc64? ( ${PPC_FIRMWARE_DEPEND} )
+"
+DEPEND="
+ ${CDEPEND}
+ kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
+ static-user? ( ${ALL_DEPEND} )
+"
+RDEPEND="
+ ${CDEPEND}
+ acct-group/kvm
+ selinux? (
+ sec-policy/selinux-qemu
+ sys-libs/libselinux
+ )
+"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-9.0.0-disable-keymap.patch
+ "${FILESDIR}"/${PN}-9.0.0-capstone-include-path.patch
+ "${FILESDIR}"/${PN}-9.0.0-also-build-virtfs-proxy-helper.patch
+ "${FILESDIR}"/${PN}-8.1.0-skip-tests.patch
+ "${FILESDIR}"/${PN}-8.1.0-find-sphinx.patch
+
+)
+
+QA_PREBUILT="
+ usr/share/qemu/hppa-firmware.img
+ usr/share/qemu/hppa-firmware64.img
+ usr/share/qemu/openbios-ppc
+ usr/share/qemu/openbios-sparc64
+ usr/share/qemu/openbios-sparc32
+ usr/share/qemu/opensbi-riscv64-generic-fw_dynamic.elf
+ usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.elf
+ usr/share/qemu/palcode-clipper
+ usr/share/qemu/s390-ccw.img
+ usr/share/qemu/s390-netboot.img
+ usr/share/qemu/u-boot.e500
+"
+
+QA_WX_LOAD="
+ usr/bin/qemu-i386
+ usr/bin/qemu-x86_64
+ usr/bin/qemu-alpha
+ usr/bin/qemu-arm
+ usr/bin/qemu-cris
+ usr/bin/qemu-m68k
+ usr/bin/qemu-microblaze
+ usr/bin/qemu-microblazeel
+ usr/bin/qemu-mips
+ usr/bin/qemu-mipsel
+ usr/bin/qemu-or1k
+ usr/bin/qemu-ppc
+ usr/bin/qemu-ppc64
+ usr/bin/qemu-sh4
+ usr/bin/qemu-sh4eb
+ usr/bin/qemu-sparc
+ usr/bin/qemu-sparc64
+ usr/bin/qemu-armeb
+ usr/bin/qemu-sparc32plus
+ usr/bin/qemu-s390x
+ usr/bin/qemu-unicore32
+"
+
+DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
+kernel module loaded before running kvm. The easiest way to ensure that the
+kernel module is loaded is to load it on boot.
+ For AMD CPUs the module is called 'kvm-amd'.
+ For Intel CPUs the module is called 'kvm-intel'.
+Please review /etc/conf.d/modules for how to load these.
+
+Make sure your user is in the 'kvm' group. Just run
+ $ gpasswd -a <USER> kvm
+then have <USER> re-login.
+
+For brand new installs, the default permissions on /dev/kvm might not let
+you access it. You can tell udev to reset ownership/perms:
+ $ udevadm trigger -c add /dev/kvm
+
+If you want to register binfmt handlers for qemu user targets:
+For openrc:
+ # rc-update add qemu-binfmt
+For systemd:
+ # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
+
+pkg_pretend() {
+ if use kernel_linux && kernel_is lt 2 6 25; then
+ eerror "This version of KVM requires a host kernel of 2.6.25 or higher."
+ elif use kernel_linux; then
+ if ! linux_config_exists; then
+ eerror "Unable to check your kernel for KVM support"
+ else
+ CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
+ ERROR_KVM="You must enable KVM in your kernel to continue"
+ ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
+ ERROR_KVM_AMD+=" your kernel configuration."
+ ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
+ ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
+ ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
+ ERROR_TUN+=" into your kernel or loaded as a module to use the"
+ ERROR_TUN+=" virtual network device if using -net tap."
+ ERROR_BRIDGE="You will also need support for 802.1d"
+ ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
+ use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
+ ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
+ ERROR_VHOST_NET+=" support"
+ use test && CONFIG_CHECK+=" IP_MULTICAST"
+ ERROR_IP_MULTICAST="Test suite requires IP_MULTICAST"
+
+ if use amd64 || use x86 || use amd64-linux || use x86-linux; then
+ if grep -q AuthenticAMD /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_AMD"
+ elif grep -q GenuineIntel /proc/cpuinfo; then
+ CONFIG_CHECK+=" ~KVM_INTEL"
+ fi
+ fi
+
+ use python && CONFIG_CHECK+=" ~DEBUG_FS"
+ ERROR_DEBUG_FS="debugFS support required for kvm_stat"
+
+ # Now do the actual checks setup above
+ check_extra_config
+ fi
+ fi
+
+ if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
+ eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
+ eerror "instances are still pointing to it. Please update your"
+ eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
+ eerror "and the right system binary (e.g. qemu-system-x86_64)."
+ die "update your virt configs to not use qemu-kvm"
+ fi
+}
+
+# Sanity check to make sure target lists are kept up-to-date.
+check_targets() {
+ local var=$1 mak=$2
+ local detected sorted
+
+ pushd "${S}"/configs/targets/ >/dev/null || die
+
+ # Force C locale until glibc is updated. #564936
+ detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
+ sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
+ if [[ ${sorted} != "${detected}" ]] ; then
+ eerror "The ebuild needs to be kept in sync."
+ eerror "${var}: ${sorted}"
+ eerror "$(printf '%-*s' ${#var} configure): ${detected}"
+ die "sync ${var} to the list of targets"
+ fi
+
+ popd >/dev/null
+}
+
+src_unpack() {
+ if [[ ${PV} == 9999 ]] ; then
+ git-r3_src_unpack
+ for file in ${A}; do
+ unpack "${file}"
+ done
+ cd "${WORKDIR}" || die
+ for proj in "${!SUBPROJECTS[@]}"; do
+ mv "${proj}-${SUBPROJECTS[${proj}]}" "${S}/subprojects/${proj}" || die
+ done
+ cd "${S}" || die
+ meson subprojects packagefiles --apply || die
+ else
+ default
+ fi
+}
+
+src_prepare() {
+ check_targets IUSE_SOFTMMU_TARGETS softmmu
+ check_targets IUSE_USER_TARGETS linux-user
+
+ default
+
+ # Use correct toolchain to fix cross-compiling
+ tc-export AR AS LD NM OBJCOPY PKG_CONFIG RANLIB STRINGS
+ export WINDRES=${CHOST}-windres
+
+ # Verbose builds
+ MAKEOPTS+=" V=1"
+
+ # Remove bundled modules
+ rm -r roms/*/ || die
+}
+
+##
+# configures qemu based on the build directory and the build type
+# we are using.
+#
+qemu_src_configure() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ local buildtype=$1
+ local builddir="${S}/${buildtype}-build"
+
+ mkdir "${builddir}" || die
+
+ local conf_opts=(
+ --prefix=/usr
+ --sysconfdir=/etc
+ --bindir=/usr/bin
+ --libdir=/usr/$(get_libdir)
+ --datadir=/usr/share
+ --docdir=/usr/share/doc/${PF}/html
+ --mandir=/usr/share/man
+ --localstatedir=/var
+ --disable-bsd-user
+ --disable-containers # bug #732972
+ --disable-guest-agent
+ --disable-strip
+ --disable-download
+
+ # bug #746752: TCG interpreter has a few limitations:
+ # - it does not support FPU
+ # - it's generally slower on non-self-modifying code
+ # It's advantage is support for host architectures
+ # where native codegeneration is not implemented.
+ # Gentoo has qemu keyworded only on targets with
+ # native code generation available. Avoid the interpreter.
+ --disable-tcg-interpreter
+
+ --disable-werror
+ # We support gnutls/nettle for crypto operations. It is possible
+ # to use gcrypt when gnutls/nettle are disabled (but not when they
+ # are enabled), but it's not really worth the hassle. Disable it
+ # all the time to avoid automatically detecting it. #568856
+ --disable-gcrypt
+ --cc="$(tc-getCC)"
+ --cxx="$(tc-getCXX)"
+ --objcc="$(tc-getCC)"
+ --host-cc="$(tc-getBUILD_CC)"
+
+ $(use_enable alsa)
+ $(use_enable debug debug-info)
+ $(use_enable debug debug-tcg)
+ $(use_enable jack)
+ $(use_enable nls gettext)
+ $(use_enable oss)
+ $(use_enable pipewire)
+ $(use_enable plugins)
+ $(use_enable pulseaudio pa)
+ $(use_enable selinux)
+ $(use_enable xattr attr)
+ )
+
+ # Disable options not used by user targets. This simplifies building
+ # static user targets (USE=static-user) considerably.
+ conf_notuser() {
+ if [[ ${buildtype} == "user" ]] ; then
+ echo "--disable-${2:-$1}"
+ else
+ use_enable "$@"
+ fi
+ }
+ # Enable option only for softmmu build, but not 'user' or 'tools'
+ conf_softmmu() {
+ if [[ ${buildtype} == "softmmu" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Enable option only for tools build, but not 'user' or 'softmmu'
+ conf_tools() {
+ if [[ ${buildtype} == "tools" ]] ; then
+ use_enable "$@"
+ else
+ echo "--disable-${2:-$1}"
+ fi
+ }
+ # Special case for the malloc flag, because the --disable flag does
+ # not exist and trying like above will break configuring.
+ conf_malloc() {
+ if [[ ! ${buildtype} == "user" ]] ; then
+ usex "${1}" "--enable-malloc=${1}" ""
+ fi
+ }
+ conf_opts+=(
+ $(conf_notuser accessibility brlapi)
+ $(conf_notuser aio linux-aio)
+ $(conf_softmmu bpf)
+ $(conf_notuser bzip2)
+ $(conf_notuser capstone)
+ $(conf_notuser curl)
+ $(conf_tools doc docs)
+ $(conf_notuser fdt)
+ $(conf_notuser fuse)
+ $(conf_notuser glusterfs)
+ $(conf_notuser gnutls)
+ $(conf_notuser gnutls nettle)
+ $(conf_notuser gtk)
+ $(conf_notuser infiniband rdma)
+ $(conf_notuser iscsi libiscsi)
+ $(conf_notuser io-uring linux-io-uring)
+ $(conf_malloc jemalloc)
+ $(conf_notuser jpeg vnc-jpeg)
+ $(conf_notuser kernel_linux kvm)
+ $(conf_notuser keyutils libkeyutils)
+ $(conf_notuser lzo)
+ $(conf_notuser multipath mpath)
+ $(conf_notuser ncurses curses)
+ $(conf_notuser nfs libnfs)
+ $(conf_notuser numa)
+ $(conf_notuser opengl)
+ $(conf_notuser pam auth-pam)
+ $(conf_notuser png)
+ $(conf_notuser rbd)
+ $(conf_notuser sasl vnc-sasl)
+ $(conf_notuser sdl)
+ $(conf_softmmu sdl-image)
+ $(conf_notuser seccomp)
+ $(conf_notuser slirp)
+ $(conf_notuser smartcard)
+ $(conf_notuser snappy)
+ $(conf_notuser spice)
+ $(conf_notuser ssh libssh)
+ $(conf_notuser udev libudev)
+ $(conf_notuser usb libusb)
+ $(conf_notuser usbredir usb-redir)
+ $(conf_notuser vde)
+ $(conf_notuser vhost-net)
+ $(conf_notuser virgl virglrenderer)
+ $(conf_softmmu virtfs)
+ $(conf_notuser vnc)
+ $(conf_notuser vte)
+ $(conf_notuser xen)
+ $(conf_notuser xen xen-pci-passthrough)
+ # use prebuilt keymaps, bug #759604
+ --disable-xkbcommon
+ $(conf_notuser zstd)
+ )
+
+ if [[ ! ${buildtype} == "user" ]] ; then
+ # audio options
+ local audio_opts=(
+ # Note: backend order matters here: #716202
+ # We iterate from higher-level to lower level.
+ $(usex pulseaudio pa "")
+ $(usev pipewire)
+ $(usev jack)
+ $(usev sdl)
+ $(usev alsa)
+ $(usev oss)
+ )
+ conf_opts+=(
+ --audio-drv-list=$(IFS=,; echo "${audio_opts[*]}")
+ )
+ fi
+
+ case ${buildtype} in
+ user)
+ conf_opts+=(
+ --enable-linux-user
+ --disable-system
+ --disable-tools
+ --disable-cap-ng
+ --disable-seccomp
+ )
+ local static_flag="static-user"
+ ;;
+ softmmu)
+ conf_opts+=(
+ --disable-linux-user
+ --enable-system
+ --disable-tools
+ --enable-cap-ng
+ --enable-seccomp
+ )
+ local static_flag="none"
+ ;;
+ tools)
+ conf_opts+=(
+ --disable-linux-user
+ --disable-system
+ --enable-tools
+ --enable-cap-ng
+ )
+ local static_flag="none"
+ ;;
+ esac
+
+ local targets="${buildtype}_targets"
+ [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
+
+ # Add support for SystemTAP
+ use systemtap && conf_opts+=( --enable-trace-backends="dtrace" )
+
+ # We always want to attempt to build with PIE support as it results
+ # in a more secure binary. But it doesn't work with static or if
+ # the current GCC doesn't have PIE support.
+ if [[ ${static_flag} != "none" ]] && use ${static_flag}; then
+ conf_opts+=( --static --disable-pie )
+ else
+ tc-enables-pie && conf_opts+=( --enable-pie )
+ fi
+
+ # Meson will not use a cross-file unless cross_prefix is set.
+ tc-is-cross-compiler && conf_opts+=( --cross-prefix="${CHOST}-" )
+
+ # Plumb through equivalent of EXTRA_ECONF to allow experiments
+ # like bug #747928.
+ conf_opts+=( ${EXTRA_CONF_QEMU} )
+
+ echo "../configure ${conf_opts[*]}"
+ cd "${builddir}"
+ ../configure "${conf_opts[@]}" || die "configure failed"
+}
+
+src_configure() {
+ local target
+
+ python_setup
+
+ softmmu_targets= softmmu_bins=()
+ user_targets= user_bins=()
+
+ for target in ${IUSE_SOFTMMU_TARGETS} ; do
+ if use "qemu_softmmu_targets_${target}"; then
+ softmmu_targets+=",${target}-softmmu"
+ softmmu_bins+=( "qemu-system-${target}" )
+ fi
+ done
+
+ for target in ${IUSE_USER_TARGETS} ; do
+ if use "qemu_user_targets_${target}"; then
+ user_targets+=",${target}-linux-user"
+ user_bins+=( "qemu-${target}" )
+ fi
+ done
+
+ softmmu_targets=${softmmu_targets#,}
+ user_targets=${user_targets#,}
+
+ [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
+ [[ -n ${user_targets} ]] && qemu_src_configure "user"
+ qemu_src_configure "tools"
+}
+
+src_compile() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build" || die
+ default
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build" || die
+ default
+ fi
+
+ cd "${S}/tools-build" || die
+ default
+}
+
+src_test() {
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build" || die
+ pax-mark m */qemu-system-* #515550
+ emake check
+ fi
+}
+
+qemu_python_install() {
+ python_domodule "${S}/python/qemu"
+
+ python_doscript "${S}/scripts/kvm/vmxcap"
+ python_doscript "${S}/scripts/qmp/qmp-shell"
+ python_doscript "${S}/scripts/qmp/qemu-ga-client"
+}
+
+# Generate binfmt support files.
+# - /etc/init.d/qemu-binfmt script which registers the user handlers (openrc)
+# - /usr/share/qemu/binfmt.d/qemu.conf (for use with systemd-binfmt)
+generate_initd() {
+ local out="${T}/qemu-binfmt"
+ local out_systemd="${T}/qemu.conf"
+ local d="${T}/binfmt.d"
+
+ einfo "Generating qemu binfmt scripts and configuration files"
+
+ # Generate the debian fragments first.
+ mkdir -p "${d}"
+ "${S}"/scripts/qemu-binfmt-conf.sh \
+ --debian \
+ --exportdir "${d}" \
+ --qemu-path "${EPREFIX}/usr/bin" \
+ || die
+ # Then turn the fragments into a shell script we can source.
+ sed -E -i \
+ -e 's:^([^ ]+) (.*)$:\1="\2":' \
+ "${d}"/* || die
+
+ # Generate the init.d script by assembling the fragments from above.
+ local f qcpu package interpreter magic mask
+ cat "${FILESDIR}"/qemu-binfmt.initd.head >"${out}" || die
+ for f in "${d}"/qemu-* ; do
+ source "${f}"
+
+ # Normalize the cpu logic like we do in the init.d for the native cpu.
+ qcpu=${package#qemu-}
+ case ${qcpu} in
+ arm*) qcpu="arm";;
+ mips*) qcpu="mips";;
+ ppc*) qcpu="ppc";;
+ s390*) qcpu="s390";;
+ sh*) qcpu="sh";;
+ sparc*) qcpu="sparc";;
+ esac
+
+ # we use 'printf' here to be portable across 'sh'
+ # implementations: #679168
+ cat <<EOF >>"${out}"
+ if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
+ printf '%s\n' ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
+ fi
+EOF
+
+ echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >>"${out_systemd}"
+
+ done
+ cat "${FILESDIR}"/qemu-binfmt.initd.tail >>"${out}" || die
+}
+
+src_install() {
+ if [[ -n ${user_targets} ]]; then
+ cd "${S}/user-build"
+ emake DESTDIR="${ED}" install
+
+ # Install binfmt handler init script for user targets.
+ generate_initd
+ doinitd "${T}/qemu-binfmt"
+
+ # Install binfmt/qemu.conf.
+ insinto "/usr/share/qemu/binfmt.d"
+ doins "${T}/qemu.conf"
+ fi
+
+ if [[ -n ${softmmu_targets} ]]; then
+ cd "${S}/softmmu-build"
+ emake DESTDIR="${ED}" install
+
+ # This might not exist if the test failed. #512010
+ [[ -e check-report.html ]] && dodoc check-report.html
+
+ if use kernel_linux; then
+ udev_newrules "${FILESDIR}"/65-kvm.rules-r2 65-kvm.rules
+ fi
+
+ if use python; then
+ python_foreach_impl qemu_python_install
+ fi
+ fi
+
+ cd "${S}/tools-build" || die
+ emake DESTDIR="${ED}" install
+
+ # If USE=doc, there'll be newly generated docs which we install instead.
+ if ! use doc && [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ doman "${WORKDIR}"/${PN}-${QEMU_DOCS_VERSION}-docs/docs/*.[0-8]
+ fi
+
+ # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
+ pushd "${ED}"/usr/bin >/dev/null || die
+ pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
+ popd >/dev/null || die
+
+ # Install config file example for qemu-bridge-helper
+ insinto "/etc/qemu"
+ doins "${FILESDIR}/bridge.conf"
+
+ cd "${S}" || die
+ dodoc MAINTAINERS
+ newdoc pc-bios/README README.pc-bios
+
+ # Disallow stripping of prebuilt firmware files.
+ dostrip -x ${QA_PREBUILT}
+
+ if [[ -n ${softmmu_targets} ]]; then
+ # Remove SeaBIOS since we're using the SeaBIOS packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
+ fi
+
+ # Remove vgabios since we're using the seavgabios packaged one
+ rm "${ED}/usr/share/qemu/vgabios.bin"
+ rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
+ rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
+ rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
+ rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
+ rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
+
+ # PPC/PPC64 loads vgabios-stdvga
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64; then
+ dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
+ dosym ../seavgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
+ dosym ../seavgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
+ dosym ../seavgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
+ dosym ../seavgabios/vgabios-virtio.bin /usr/share/qemu/vgabios-virtio.bin
+ dosym ../seavgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
+ fi
+
+ # Remove sgabios since we're using the sgabios packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
+ fi
+
+ # Remove iPXE since we're using the iPXE packaged one
+ if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
+ dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
+ dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
+ dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
+ dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
+ dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
+ dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
+ fi
+ fi
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_create_doc
+}
+
+firmware_abi_change() {
+ local pv
+ for pv in ${REPLACING_VERSIONS}; do
+ if ver_test ${pv} -lt ${FIRMWARE_ABI_VERSION}; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+pkg_postinst() {
+ if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
+ udev_reload
+ fi
+
+ xdg_icon_cache_update
+
+ [[ -z ${EPREFIX} ]] && [[ -f ${EROOT}/usr/libexec/qemu-bridge-helper ]] && \
+ fcaps cap_net_admin "${EROOT}"/usr/libexec/qemu-bridge-helper
+
+ DISABLE_AUTOFORMATTING=true
+ readme.gentoo_print_elog
+
+ if use pin-upstream-blobs && firmware_abi_change; then
+ ewarn "This version of qemu pins new versions of firmware blobs:"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ ewarn " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ ewarn " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ ewarn " $(best_version sys-firmware/seabios-bin)"
+ else
+ ewarn " $(best_version sys-firmware/seabios)"
+ fi
+
+ ewarn " $(best_version sys-firmware/ipxe)"
+ ewarn " $(best_version sys-firmware/sgabios)"
+ ewarn "This might break resume of hibernated guests (started with a different"
+ ewarn "firmware version) and live migration to/from qemu versions with different"
+ ewarn "firmware. Please (cold) restart all running guests. For functional"
+ ewarn "guest migration ensure that all"
+ ewarn "hosts run at least"
+ ewarn " app-emulation/qemu-${FIRMWARE_ABI_VERSION}."
+ fi
+}
+
+pkg_info() {
+ echo "Using:"
+ echo " $(best_version app-emulation/spice-protocol)"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ echo " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ echo " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ echo " $(best_version sys-firmware/seabios-bin)"
+ else
+ echo " $(best_version sys-firmware/seabios)"
+ fi
+
+ echo " $(best_version sys-firmware/ipxe)"
+ echo " $(best_version sys-firmware/sgabios)"
+}
+
+pkg_postrm() {
+ xdg_icon_cache_update
+ udev_reload
+}
diff --git a/app-emulation/qemu/qemu-9999.ebuild b/app-emulation/qemu/qemu-9999.ebuild
index 336c80bd859c..02a65ccd518a 100644
--- a/app-emulation/qemu/qemu-9999.ebuild
+++ b/app-emulation/qemu/qemu-9999.ebuild
@@ -1,31 +1,53 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
-PYTHON_COMPAT=( python3_{8,9,10} )
+# Generate using https://github.com/thesamesam/sam-gentoo-scripts/blob/main/niche/generate-qemu-docs
+# Set to 1 if prebuilt, 0 if not
+# (the construct below is to allow overriding from env for script)
+QEMU_DOCS_PREBUILT=${QEMU_DOCS_PREBUILT:-0}
+QEMU_DOCS_PREBUILT_DEV=sam
+QEMU_DOCS_VERSION=$(ver_cut 1-3)
+# Default to generating docs (inc. man pages) if no prebuilt; overridden later
+# bug #830088
+QEMU_DOC_USEFLAG="+doc"
+
+PYTHON_COMPAT=( python3_{10..12} )
PYTHON_REQ_USE="ncurses,readline"
-FIRMWARE_ABI_VERSION="7.0.0"
+FIRMWARE_ABI_VERSION="7.2.0"
inherit linux-info toolchain-funcs python-r1 udev fcaps readme.gentoo-r1 \
pax-utils xdg-utils
if [[ ${PV} == *9999* ]]; then
+ QEMU_DOCS_PREBUILT=0
+
EGIT_REPO_URI="https://gitlab.com/qemu-project/qemu.git/"
- EGIT_SUBMODULES=(
- meson
- tests/fp/berkeley-softfloat-3
- tests/fp/berkeley-testfloat-3
- ui/keycodemapdb
- )
+ EGIT_SUBMODULES=()
inherit git-r3
SRC_URI=""
+ declare -A SUBPROJECTS=(
+ [keycodemapdb]="f5772a62ec52591ff6870b7e8ef32482371f22c6"
+ [berkeley-softfloat-3]="b64af41c3276f97f0e181920400ee056b9c88037"
+ [berkeley-testfloat-3]="e7af9751d9f9fd3b47911f51a5cfd08af256a9ab"
+ )
+
+ for proj in "${!SUBPROJECTS[@]}"; do
+ c=${SUBPROJECTS[${proj}]}
+ SRC_URI+=" https://gitlab.com/qemu-project/${proj}/-/archive/${c}/${proj}-${c}.tar.bz2"
+ done
else
MY_P="${PN}-${PV/_rc/-rc}"
SRC_URI="https://download.qemu.org/${MY_P}.tar.xz"
- KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
+
+ if [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ SRC_URI+=" !doc? ( https://dev.gentoo.org/~${QEMU_DOCS_PREBUILT_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${QEMU_DOCS_VERSION}-docs.tar.xz )"
+ fi
+
S="${WORKDIR}/${MY_P}"
+ [[ "${PV}" != *_rc* ]] && KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
fi
DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
@@ -34,15 +56,17 @@ HOMEPAGE="https://www.qemu.org https://www.linux-kvm.org"
LICENSE="GPL-2 LGPL-2 BSD-2"
SLOT="0"
-IUSE="accessibility +aio alsa bpf bzip2 capstone +caps +curl debug +doc
+[[ ${QEMU_DOCS_PREBUILT} == 1 ]] && QEMU_DOC_USEFLAG="doc"
+
+IUSE="accessibility +aio alsa bpf bzip2 capstone +curl debug ${QEMU_DOC_USEFLAG}
+fdt fuse glusterfs +gnutls gtk infiniband iscsi io-uring
- jack jemalloc +jpeg
+ jack jemalloc +jpeg keyutils
lzo multipath
- ncurses nfs nls numa opengl +oss pam +pin-upstream-blobs
+ ncurses nfs nls numa opengl +oss pam +pin-upstream-blobs pipewire
plugins +png pulseaudio python rbd sasl +seccomp sdl sdl-image selinux
+slirp
- smartcard snappy spice ssh static static-user systemtap test udev usb
- usbredir vde +vhost-net vhost-user-fs virgl virtfs +vnc vte xattr xen
+ smartcard snappy spice ssh static-user systemtap test udev usb
+ usbredir vde +vhost-net virgl virtfs +vnc vte xattr xen
zstd"
COMMON_TARGETS="
@@ -60,7 +84,6 @@ COMMON_TARGETS="
mips64
mips64el
mipsel
- nios2
or1k
ppc
ppc64
@@ -97,9 +120,11 @@ use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
RESTRICT="!test? ( test )"
+
# Allow no targets to be built so that people can get a tools-only build.
# Block USE flag configurations known to not work.
-REQUIRED_USE="${PYTHON_REQUIRED_USE}
+REQUIRED_USE="
+ ${PYTHON_REQUIRED_USE}
qemu_softmmu_targets_arm? ( fdt )
qemu_softmmu_targets_microblaze? ( fdt )
qemu_softmmu_targets_mips64el? ( fdt )
@@ -109,16 +134,17 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}
qemu_softmmu_targets_riscv64? ( fdt )
qemu_softmmu_targets_x86_64? ( fdt )
sdl-image? ( sdl )
- static? ( static-user !alsa !gtk !jack !opengl !pam !pulseaudio !plugins !rbd !snappy !udev )
static-user? ( !plugins )
- vhost-user-fs? ( caps seccomp )
virgl? ( opengl )
- virtfs? ( caps xattr )
+ virtfs? ( xattr )
vnc? ( gnutls )
vte? ( gtk )
multipath? ( udev )
- plugins? ( !static !static-user )
+ plugins? ( !static-user )
"
+for smname in ${IUSE_SOFTMMU_TARGETS} ; do
+ REQUIRED_USE+=" qemu_softmmu_targets_${smname}? ( kernel_linux? ( seccomp ) )"
+done
# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
# and user/softmmu targets (qemu-*, qemu-system-*).
@@ -129,11 +155,12 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}
# respected). This is because qemu supports using the C library's API
# when available rather than always using the external library.
ALL_DEPEND="
- >=dev-libs/glib-2.0[static-libs(+)]
+ dev-libs/glib:2[static-libs(+)]
sys-libs/zlib[static-libs(+)]
python? ( ${PYTHON_DEPS} )
- systemtap? ( dev-util/systemtap )
- xattr? ( sys-apps/attr[static-libs(+)] )"
+ systemtap? ( dev-debug/systemtap )
+ xattr? ( sys-apps/attr[static-libs(+)] )
+"
# Dependencies required for qemu tools (qemu-nbd, qemu-img, qemu-io, ...)
# softmmu targets (qemu-system-*).
@@ -147,15 +174,14 @@ SOFTMMU_TOOLS_DEPEND="
alsa? ( >=media-libs/alsa-lib-1.0.13 )
bpf? ( dev-libs/libbpf:= )
bzip2? ( app-arch/bzip2[static-libs(+)] )
- capstone? ( dev-libs/capstone:= )
- caps? ( sys-libs/libcap-ng[static-libs(+)] )
+ capstone? ( dev-libs/capstone:=[static-libs(+)] )
curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
fdt? ( >=sys-apps/dtc-1.5.1[static-libs(+)] )
fuse? ( >=sys-fs/fuse-3.1:3[static-libs(+)] )
glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
gnutls? (
- dev-libs/nettle:=[static-libs(+)]
>=net-libs/gnutls-3.0:=[static-libs(+)]
+ dev-libs/nettle:=[static-libs(+)]
)
gtk? (
x11-libs/gtk+:3
@@ -167,6 +193,8 @@ SOFTMMU_TOOLS_DEPEND="
jack? ( virtual/jack )
jemalloc? ( dev-libs/jemalloc )
jpeg? ( media-libs/libjpeg-turbo:=[static-libs(+)] )
+ kernel_linux? ( sys-libs/libcap-ng[static-libs(+)] )
+ keyutils? ( sys-apps/keyutils[static-libs(+)] )
lzo? ( dev-libs/lzo:2[static-libs(+)] )
multipath? ( sys-fs/multipath-tools )
ncurses? (
@@ -182,8 +210,9 @@ SOFTMMU_TOOLS_DEPEND="
media-libs/mesa[egl(+),gbm(+)]
)
pam? ( sys-libs/pam )
- png? ( media-libs/libpng:0=[static-libs(+)] )
- pulseaudio? ( media-sound/pulseaudio )
+ pipewire? ( >=media-video/pipewire-0.3.60 )
+ png? ( >=media-libs/libpng-1.6.34:=[static-libs(+)] )
+ pulseaudio? ( media-libs/libpulse )
rbd? ( sys-cluster/ceph )
sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
sdl? (
@@ -196,12 +225,12 @@ SOFTMMU_TOOLS_DEPEND="
smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
snappy? ( app-arch/snappy:= )
spice? (
- >=app-emulation/spice-protocol-0.12.3
- >=app-emulation/spice-0.12.0[static-libs(+)]
+ >=app-emulation/spice-protocol-0.14.0
+ >=app-emulation/spice-0.14.0[static-libs(+)]
)
ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
udev? ( virtual/libudev:= )
- usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
+ usb? ( >=virtual/libusb-1-r2:1[static-libs(+)] )
usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
vde? ( net-misc/vde[static-libs(+)] )
virgl? ( media-libs/virglrenderer[static-libs(+)] )
@@ -210,80 +239,93 @@ SOFTMMU_TOOLS_DEPEND="
zstd? ( >=app-arch/zstd-1.4.0[static-libs(+)] )
"
-EDK2_OVMF_VERSION="202105"
-SEABIOS_VERSION="1.14.0"
+EDK2_OVMF_VERSION="202202"
+SEABIOS_VERSION="1.16.0"
X86_FIRMWARE_DEPEND="
pin-upstream-blobs? (
- ~sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}[binary]
+ ~sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
~sys-firmware/ipxe-1.21.1[binary,qemu]
- ~sys-firmware/seabios-${SEABIOS_VERSION}[binary,seavgabios]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
~sys-firmware/sgabios-0.1_pre10[binary]
)
!pin-upstream-blobs? (
- >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ || (
+ >=sys-firmware/edk2-ovmf-${EDK2_OVMF_VERSION}
+ >=sys-firmware/edk2-ovmf-bin-${EDK2_OVMF_VERSION}
+ )
sys-firmware/ipxe[qemu]
- >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
sys-firmware/sgabios
- )"
+ )
+"
PPC_FIRMWARE_DEPEND="
pin-upstream-blobs? (
- ~sys-firmware/seabios-${SEABIOS_VERSION}[binary,seavgabios]
+ ~sys-firmware/seabios-bin-${SEABIOS_VERSION}
)
!pin-upstream-blobs? (
- >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ || (
+ >=sys-firmware/seabios-${SEABIOS_VERSION}[seavgabios]
+ >=sys-firmware/seabios-bin-${SEABIOS_VERSION}
+ )
)
"
+# See bug #913084 for pip dep
BDEPEND="
$(python_gen_impl_dep)
dev-lang/perl
- sys-apps/texinfo
+ >=dev-build/meson-0.63.0
+ app-alternatives/ninja
+ dev-python/pip[${PYTHON_USEDEP}]
virtual/pkgconfig
doc? (
- dev-python/sphinx[${PYTHON_USEDEP}]
- dev-python/sphinx_rtd_theme[${PYTHON_USEDEP}]
+ >=dev-python/sphinx-1.6.0[${PYTHON_USEDEP}]
+ dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
)
gtk? ( nls? ( sys-devel/gettext ) )
test? (
dev-libs/glib[utils]
- sys-devel/bc
+ app-alternatives/bc
)
"
CDEPEND="
- !static? (
- ${ALL_DEPEND//\[static-libs(+)]}
- ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
- )
+ ${ALL_DEPEND//\[static-libs(+)]}
+ ${SOFTMMU_TOOLS_DEPEND//\[static-libs(+)]}
qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
qemu_softmmu_targets_ppc? ( ${PPC_FIRMWARE_DEPEND} )
qemu_softmmu_targets_ppc64? ( ${PPC_FIRMWARE_DEPEND} )
"
-DEPEND="${CDEPEND}
+DEPEND="
+ ${CDEPEND}
kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
- static? (
- ${ALL_DEPEND}
- ${SOFTMMU_TOOLS_DEPEND}
- )
- static-user? ( ${ALL_DEPEND} )"
-RDEPEND="${CDEPEND}
+ static-user? ( ${ALL_DEPEND} )
+"
+RDEPEND="
+ ${CDEPEND}
acct-group/kvm
selinux? (
sec-policy/selinux-qemu
sys-libs/libselinux
- )"
+ )
+"
PATCHES=(
- "${FILESDIR}"/${PN}-2.11.1-capstone_include_path.patch
- "${FILESDIR}"/${PN}-5.2.0-disable-keymap.patch
- "${FILESDIR}"/${PN}-6.0.0-make.patch
- "${FILESDIR}"/${PN}-7.1.0-also-build-virtfs-proxy-helper.patch
- "${FILESDIR}"/${PN}-7.1.0-strings.patch
+ "${FILESDIR}"/${PN}-9.0.0-disable-keymap.patch
+ "${FILESDIR}"/${PN}-9.0.0-capstone-include-path.patch
+ "${FILESDIR}"/${PN}-9.0.0-also-build-virtfs-proxy-helper.patch
+ "${FILESDIR}"/${PN}-8.1.0-skip-tests.patch
+ "${FILESDIR}"/${PN}-8.1.0-find-sphinx.patch
+
)
QA_PREBUILT="
usr/share/qemu/hppa-firmware.img
+ usr/share/qemu/hppa-firmware64.img
usr/share/qemu/openbios-ppc
usr/share/qemu/openbios-sparc64
usr/share/qemu/openbios-sparc32
@@ -295,7 +337,8 @@ QA_PREBUILT="
usr/share/qemu/u-boot.e500
"
-QA_WX_LOAD="usr/bin/qemu-i386
+QA_WX_LOAD="
+ usr/bin/qemu-i386
usr/bin/qemu-x86_64
usr/bin/qemu-alpha
usr/bin/qemu-arm
@@ -360,6 +403,8 @@ pkg_pretend() {
use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
ERROR_VHOST_NET+=" support"
+ use test && CONFIG_CHECK+=" IP_MULTICAST"
+ ERROR_IP_MULTICAST="Test suite requires IP_MULTICAST"
if use amd64 || use x86 || use amd64-linux || use x86-linux; then
if grep -q AuthenticAMD /proc/cpuinfo; then
@@ -406,6 +451,23 @@ check_targets() {
popd >/dev/null
}
+src_unpack() {
+ if [[ ${PV} == 9999 ]] ; then
+ git-r3_src_unpack
+ for file in ${A}; do
+ unpack "${file}"
+ done
+ cd "${WORKDIR}" || die
+ for proj in "${!SUBPROJECTS[@]}"; do
+ mv "${proj}-${SUBPROJECTS[${proj}]}" "${S}/subprojects/${proj}" || die
+ done
+ cd "${S}" || die
+ meson subprojects packagefiles --apply || die
+ else
+ default
+ fi
+}
+
src_prepare() {
check_targets IUSE_SOFTMMU_TARGETS softmmu
check_targets IUSE_USER_TARGETS linux-user
@@ -419,13 +481,8 @@ src_prepare() {
# Verbose builds
MAKEOPTS+=" V=1"
- # We already force -D_FORTIFY_SOURCE=2 (or 3) in our toolchain, but
- # this setting (-U then -D..=2) will prevent us from trying out 3, so
- # drop it. No change to level of protection b/c we patch our toolchain.
- sed -i -e 's/-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2//' configure || die
-
- # Remove bundled copy of libfdt
- rm -r dtc || die
+ # Remove bundled modules
+ rm -r roms/*/ || die
}
##
@@ -453,7 +510,7 @@ qemu_src_configure() {
--disable-containers # bug #732972
--disable-guest-agent
--disable-strip
- --with-git-submodules=ignore
+ --disable-download
# bug #746752: TCG interpreter has a few limitations:
# - it does not support FPU
@@ -470,9 +527,9 @@ qemu_src_configure() {
# are enabled), but it's not really worth the hassle. Disable it
# all the time to avoid automatically detecting it. #568856
--disable-gcrypt
- --python="${PYTHON}"
--cc="$(tc-getCC)"
--cxx="$(tc-getCXX)"
+ --objcc="$(tc-getCC)"
--host-cc="$(tc-getBUILD_CC)"
$(use_enable alsa)
@@ -481,6 +538,7 @@ qemu_src_configure() {
$(use_enable jack)
$(use_enable nls gettext)
$(use_enable oss)
+ $(use_enable pipewire)
$(use_enable plugins)
$(use_enable pulseaudio pa)
$(use_enable selinux)
@@ -525,7 +583,6 @@ qemu_src_configure() {
$(conf_softmmu bpf)
$(conf_notuser bzip2)
$(conf_notuser capstone)
- $(conf_notuser caps cap-ng)
$(conf_notuser curl)
$(conf_tools doc docs)
$(conf_notuser fdt)
@@ -540,6 +597,7 @@ qemu_src_configure() {
$(conf_malloc jemalloc)
$(conf_notuser jpeg vnc-jpeg)
$(conf_notuser kernel_linux kvm)
+ $(conf_notuser keyutils libkeyutils)
$(conf_notuser lzo)
$(conf_notuser multipath mpath)
$(conf_notuser ncurses curses)
@@ -553,7 +611,7 @@ qemu_src_configure() {
$(conf_notuser sdl)
$(conf_softmmu sdl-image)
$(conf_notuser seccomp)
- $(conf_notuser slirp slirp system)
+ $(conf_notuser slirp)
$(conf_notuser smartcard)
$(conf_notuser snappy)
$(conf_notuser spice)
@@ -563,8 +621,6 @@ qemu_src_configure() {
$(conf_notuser usbredir usb-redir)
$(conf_notuser vde)
$(conf_notuser vhost-net)
- $(conf_notuser vhost-user-fs)
- $(conf_tools vhost-user-fs virtiofsd)
$(conf_notuser virgl virglrenderer)
$(conf_softmmu virtfs)
$(conf_notuser vnc)
@@ -582,6 +638,7 @@ qemu_src_configure() {
# Note: backend order matters here: #716202
# We iterate from higher-level to lower level.
$(usex pulseaudio pa "")
+ $(usev pipewire)
$(usev jack)
$(usev sdl)
$(usev alsa)
@@ -597,8 +654,9 @@ qemu_src_configure() {
conf_opts+=(
--enable-linux-user
--disable-system
- --disable-blobs
--disable-tools
+ --disable-cap-ng
+ --disable-seccomp
)
local static_flag="static-user"
;;
@@ -607,17 +665,19 @@ qemu_src_configure() {
--disable-linux-user
--enable-system
--disable-tools
+ --enable-cap-ng
+ --enable-seccomp
)
- local static_flag="static"
+ local static_flag="none"
;;
tools)
conf_opts+=(
--disable-linux-user
--disable-system
- --disable-blobs
--enable-tools
+ --enable-cap-ng
)
- local static_flag="static"
+ local static_flag="none"
;;
esac
@@ -625,12 +685,12 @@ qemu_src_configure() {
[[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
# Add support for SystemTAP
- use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
+ use systemtap && conf_opts+=( --enable-trace-backends="dtrace" )
# We always want to attempt to build with PIE support as it results
# in a more secure binary. But it doesn't work with static or if
# the current GCC doesn't have PIE support.
- if use ${static_flag}; then
+ if [[ ${static_flag} != "none" ]] && use ${static_flag}; then
conf_opts+=( --static --disable-pie )
else
tc-enables-pie && conf_opts+=( --enable-pie )
@@ -795,6 +855,11 @@ src_install() {
cd "${S}/tools-build" || die
emake DESTDIR="${ED}" install
+ # If USE=doc, there'll be newly generated docs which we install instead.
+ if ! use doc && [[ ${QEMU_DOCS_PREBUILT} == 1 ]] ; then
+ doman "${WORKDIR}"/${PN}-${QEMU_DOCS_VERSION}-docs/docs/*.[0-8]
+ fi
+
# Disable mprotect on the qemu binaries as they use JITs to be fast #459348
pushd "${ED}"/usr/bin >/dev/null || die
pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}" # bug 575594
@@ -805,7 +870,7 @@ src_install() {
doins "${FILESDIR}/bridge.conf"
cd "${S}" || die
- dodoc MAINTAINERS docs/specs/pci-ids.txt
+ dodoc MAINTAINERS
newdoc pc-bios/README README.pc-bios
# Disallow stripping of prebuilt firmware files.
@@ -813,10 +878,7 @@ src_install() {
if [[ -n ${softmmu_targets} ]]; then
# Remove SeaBIOS since we're using the SeaBIOS packaged one
- rm "${ED}/usr/share/qemu/bios.bin"
- rm "${ED}/usr/share/qemu/bios-256k.bin"
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
- dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin
fi
@@ -827,6 +889,7 @@ src_install() {
rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
rm "${ED}/usr/share/qemu/vgabios-virtio.bin"
rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
+
# PPC/PPC64 loads vgabios-stdvga
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64; then
dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin
@@ -838,13 +901,11 @@ src_install() {
fi
# Remove sgabios since we're using the sgabios packaged one
- rm "${ED}/usr/share/qemu/sgabios.bin"
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
fi
# Remove iPXE since we're using the iPXE packaged one
- rm "${ED}"/usr/share/qemu/pxe-*.rom
if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
@@ -884,9 +945,20 @@ pkg_postinst() {
if use pin-upstream-blobs && firmware_abi_change; then
ewarn "This version of qemu pins new versions of firmware blobs:"
- ewarn " $(best_version sys-firmware/edk2-ovmf)"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ ewarn " $(best_version sys-firmware/edk2-ovmf-bin)"
+ else
+ ewarn " $(best_version sys-firmware/edk2-ovmf)"
+ fi
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ ewarn " $(best_version sys-firmware/seabios-bin)"
+ else
+ ewarn " $(best_version sys-firmware/seabios)"
+ fi
+
ewarn " $(best_version sys-firmware/ipxe)"
- ewarn " $(best_version sys-firmware/seabios)"
ewarn " $(best_version sys-firmware/sgabios)"
ewarn "This might break resume of hibernated guests (started with a different"
ewarn "firmware version) and live migration to/from qemu versions with different"
@@ -900,22 +972,24 @@ pkg_postinst() {
pkg_info() {
echo "Using:"
echo " $(best_version app-emulation/spice-protocol)"
- echo " $(best_version sys-firmware/edk2-ovmf)"
- if has_version 'sys-firmware/edk2-ovmf[binary]'; then
- echo " USE=binary"
+
+ if has_version 'sys-firmware/edk2-ovmf-bin'; then
+ echo " $(best_version sys-firmware/edk2-ovmf-bin)"
else
- echo " USE=''"
+ echo " $(best_version sys-firmware/edk2-ovmf)"
fi
- echo " $(best_version sys-firmware/ipxe)"
- echo " $(best_version sys-firmware/seabios)"
- if has_version 'sys-firmware/seabios[binary]'; then
- echo " USE=binary"
+
+ if has_version 'sys-firmware/seabios-bin'; then
+ echo " $(best_version sys-firmware/seabios-bin)"
else
- echo " USE=''"
+ echo " $(best_version sys-firmware/seabios)"
fi
+
+ echo " $(best_version sys-firmware/ipxe)"
echo " $(best_version sys-firmware/sgabios)"
}
pkg_postrm() {
xdg_icon_cache_update
+ udev_reload
}