qemu.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. SUMMARY = "Fast open source processor emulator"
  2. DESCRIPTION = "QEMU is a hosted virtual machine monitor: it emulates the \
  3. machine's processor through dynamic binary translation and provides a set \
  4. of different hardware and device models for the machine, enabling it to run \
  5. a variety of guest operating systems"
  6. HOMEPAGE = "http://qemu.org"
  7. LICENSE = "GPL-2.0-only & LGPL-2.1-only"
  8. RDEPENDS:${PN}-ptest = "bash"
  9. require qemu-targets.inc
  10. inherit pkgconfig ptest update-rc.d systemd
  11. LIC_FILES_CHKSUM = "file://COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \
  12. file://COPYING.LIB;endline=24;md5=8c5efda6cf1e1b03dcfd0e6c0d271c7f"
  13. SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
  14. file://powerpc_rom.bin \
  15. file://run-ptest \
  16. file://0001-qemu-Add-addition-environment-space-to-boot-loader-q.patch \
  17. file://0002-chardev-connect-socket-to-a-spawned-command.patch \
  18. file://0003-apic-fixup-fallthrough-to-PIC.patch \
  19. file://0004-configure-Add-pkg-config-handling-for-libgcrypt.patch \
  20. file://0005-qemu-Do-not-include-file-if-not-exists.patch \
  21. file://0006-qemu-Add-some-user-space-mmap-tweaks-to-address-musl.patch \
  22. file://0007-qemu-Determinism-fixes.patch \
  23. file://0008-tests-meson.build-use-relative-path-to-refer-to-file.patch \
  24. file://0009-Define-MAP_SYNC-and-MAP_SHARED_VALIDATE-on-needed-li.patch \
  25. file://0010-hw-pvrdma-Protect-against-buggy-or-malicious-guest-d.patch \
  26. file://0001-contrib-vhost-user-blk-Replace-lseek64-with-lseek.patch \
  27. file://0002-linux-user-Replace-use-of-lfs64-related-functions-an.patch \
  28. file://0001-configure-Fix-check-tcg-not-executing-any-tests.patch \
  29. file://0001-Revert-linux-user-add-more-compat-ioctl-definitions.patch \
  30. file://0002-Revert-linux-user-fix-compat-with-glibc-2.36-sys-mou.patch \
  31. file://qemu-guest-agent.init \
  32. file://qemu-guest-agent.udev \
  33. file://0001-Add-four-cache-csr-instruction.patch \
  34. file://0002-Fix-cache-instruction-bug.patch \
  35. file://0003-duhhe-bare-metal-sdk-support-based-on-sifive_u.patch \
  36. file://0004-display-system-call-name.patch \
  37. file://0005-Upgrade-CLINT-implementation-to-ACLINT-and-Misc.patch \
  38. file://0006-block-Handle-curl-7.55.0-7.85.0-version-changes.patch \
  39. "
  40. UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
  41. SRC_URI[sha256sum] = "5b49ce2687744dad494ae90a898c52204a3406e84d072482a1e1be854eeb2157"
  42. SRC_URI:append:class-target = " file://cross.patch"
  43. SRC_URI:append:class-nativesdk = " file://cross.patch"
  44. # Applies against virglrender < 0.6.0 and not qemu itself
  45. CVE_CHECK_IGNORE += "CVE-2017-5957"
  46. # The VNC server can expose host files uder some circumstances. We don't
  47. # enable it by default.
  48. CVE_CHECK_IGNORE += "CVE-2007-0998"
  49. # 'The issues identified by this CVE were determined to not constitute a vulnerability.'
  50. # https://bugzilla.redhat.com/show_bug.cgi?id=1609015#c11
  51. CVE_CHECK_IGNORE += "CVE-2018-18438"
  52. COMPATIBLE_HOST:mipsarchn32 = "null"
  53. COMPATIBLE_HOST:mipsarchn64 = "null"
  54. COMPATIBLE_HOST:riscv32 = "null"
  55. # Per https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03873.html
  56. # upstream states qemu doesn't work without optimization
  57. DEBUG_BUILD = "0"
  58. do_install:append() {
  59. # Prevent QA warnings about installed ${localstatedir}/run
  60. if [ -d ${D}${localstatedir}/run ]; then rmdir ${D}${localstatedir}/run; fi
  61. }
  62. do_install_ptest() {
  63. cp -rL ${B}/tests ${D}${PTEST_PATH}
  64. find ${D}${PTEST_PATH}/tests -type f -name "*.[Sshcodp]" | xargs -i rm -rf {}
  65. # Don't check the file genreated by configure
  66. sed -i -e "1s,#!/usr/bin/bash,#!${base_bindir}/bash," ${D}${PTEST_PATH}/tests/data/acpi/disassemle-aml.sh
  67. # Strip the paths from the QEMU variable, we can use PATH
  68. makfiles=$(find ${D}${PTEST_PATH} -name "*.mak")
  69. sed -i -e "s#^QEMU=.*/qemu-#QEMU=qemu-#g" $makfiles
  70. # Strip compiler flags as they break reproducibility
  71. sed -i -e "s,^CC=.*,CC=gcc," \
  72. -e "s,^CCAS=.*,CCAS=gcc," \
  73. -e "s,^LD=.*,LD=ld," $makfiles
  74. # Update SRC_PATH variable to the right place on target
  75. sed -i -e "s#^SRC_PATH=.*#SRC_PATH=${PTEST_PATH}#g" $makfiles
  76. # https://gitlab.com/qemu-project/qemu/-/issues/1403
  77. rm ${D}${PTEST_PATH}/tests/unit/test-io-channel-command
  78. }
  79. # QEMU_TARGETS is overridable variable
  80. QEMU_TARGETS ?= "arm aarch64 i386 loongarch64 mips mipsel mips64 mips64el ppc ppc64 ppc64le riscv32 riscv64 sh4 x86_64"
  81. EXTRA_OECONF = " \
  82. --prefix=${prefix} \
  83. --bindir=${bindir} \
  84. --includedir=${includedir} \
  85. --libdir=${libdir} \
  86. --mandir=${mandir} \
  87. --datadir=${datadir} \
  88. --docdir=${docdir}/${BPN} \
  89. --sysconfdir=${sysconfdir} \
  90. --libexecdir=${libexecdir} \
  91. --localstatedir=${localstatedir} \
  92. --with-suffix=${BPN} \
  93. --disable-strip \
  94. --disable-werror \
  95. --extra-cflags='${CFLAGS}' \
  96. --extra-ldflags='${LDFLAGS}' \
  97. --with-git=/bin/false \
  98. --with-git-submodules=ignore \
  99. --meson=meson \
  100. ${PACKAGECONFIG_CONFARGS} \
  101. "
  102. B = "${WORKDIR}/build"
  103. #EXTRA_OECONF:append = " --python=${HOSTTOOLS_DIR}/python3"
  104. do_configure:prepend:class-native() {
  105. # Append build host pkg-config paths for native target since the host may provide sdl
  106. BHOST_PKGCONFIG_PATH=$(PATH=/usr/bin:/bin pkg-config --variable pc_path pkg-config || echo "")
  107. if [ ! -z "$BHOST_PKGCONFIG_PATH" ]; then
  108. export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$BHOST_PKGCONFIG_PATH
  109. fi
  110. }
  111. do_configure() {
  112. ${S}/configure ${EXTRA_OECONF}
  113. }
  114. do_configure[cleandirs] += "${B}"
  115. do_install () {
  116. export STRIP=""
  117. oe_runmake 'DESTDIR=${D}' install
  118. # If we built the guest agent, also install startup/udev rules
  119. if [ -e "${D}${bindir}/qemu-ga" ]; then
  120. install -d ${D}${sysconfdir}/init.d/
  121. install -m 0755 ${WORKDIR}/qemu-guest-agent.init ${D}${sysconfdir}/init.d/qemu-guest-agent
  122. sed -i 's:@bindir@:${bindir}:' ${D}${sysconfdir}/init.d/qemu-guest-agent
  123. install -d ${D}${sysconfdir}/udev/rules.d/
  124. install -m 0644 ${WORKDIR}/qemu-guest-agent.udev ${D}${sysconfdir}/udev/rules.d/60-qemu-guest-agent.rules
  125. install -d ${D}${systemd_unitdir}/system/
  126. install -m 0644 ${S}/contrib/systemd/qemu-guest-agent.service ${D}${systemd_unitdir}/system
  127. sed -i -e 's,-/usr/bin/,-${bindir}/,g' ${D}${systemd_unitdir}/system/qemu-guest-agent.service
  128. fi
  129. }
  130. # The following fragment will create a wrapper for qemu-mips user emulation
  131. # binary in order to work around a segmentation fault issue. Basically, by
  132. # default, the reserved virtual address space for 32-on-64 bit is set to 4GB.
  133. # This will trigger a MMU access fault in the virtual CPU. With this change,
  134. # the qemu-mips works fine.
  135. # IMPORTANT: This piece needs to be removed once the root cause is fixed!
  136. do_install:append() {
  137. if [ -e "${D}/${bindir}/qemu-mips" ]; then
  138. create_wrapper ${D}/${bindir}/qemu-mips \
  139. QEMU_RESERVED_VA=0x0
  140. fi
  141. }
  142. # END of qemu-mips workaround
  143. # Disable kvm/virgl/mesa on targets that do not support it
  144. PACKAGECONFIG:remove:darwin = "kvm virglrenderer epoxy gtk+"
  145. PACKAGECONFIG:remove:mingw32 = "kvm virglrenderer epoxy gtk+"
  146. PACKAGECONFIG[sdl] = "--enable-sdl,--disable-sdl,libsdl2"
  147. PACKAGECONFIG[png] = "--enable-png,--disable-png,libpng"
  148. PACKAGECONFIG[virtfs] = "--enable-virtfs --enable-attr --enable-cap-ng,--disable-virtfs,libcap-ng attr,"
  149. PACKAGECONFIG[aio] = "--enable-linux-aio,--disable-linux-aio,libaio,"
  150. PACKAGECONFIG[uring] = "--enable-linux-io-uring,--disable-linux-io-uring,liburing"
  151. PACKAGECONFIG[xen] = "--enable-xen,--disable-xen,xen-tools,xen-tools-libxenstore xen-tools-libxenctrl xen-tools-libxenguest"
  152. PACKAGECONFIG[vnc-sasl] = "--enable-vnc --enable-vnc-sasl,--disable-vnc-sasl,cyrus-sasl,"
  153. PACKAGECONFIG[vnc-jpeg] = "--enable-vnc --enable-vnc-jpeg,--disable-vnc-jpeg,jpeg,"
  154. PACKAGECONFIG[libcurl] = "--enable-curl,--disable-curl,curl,"
  155. PACKAGECONFIG[nss] = "--enable-smartcard,--disable-smartcard,nss,"
  156. PACKAGECONFIG[curses] = "--enable-curses,--disable-curses,ncurses,"
  157. PACKAGECONFIG[gtk+] = "--enable-gtk,--disable-gtk,gtk+3 gettext-native"
  158. PACKAGECONFIG[vte] = "--enable-vte,--disable-vte,vte gettext-native"
  159. PACKAGECONFIG[libcap-ng] = "--enable-cap-ng,--disable-cap-ng,libcap-ng,"
  160. PACKAGECONFIG[ssh] = "--enable-libssh,--disable-libssh,libssh,"
  161. PACKAGECONFIG[gcrypt] = "--enable-gcrypt,--disable-gcrypt,libgcrypt,"
  162. PACKAGECONFIG[nettle] = "--enable-nettle,--disable-nettle,nettle"
  163. PACKAGECONFIG[libusb] = "--enable-libusb,--disable-libusb,libusb1"
  164. PACKAGECONFIG[fdt] = "--enable-fdt,--disable-fdt,dtc"
  165. PACKAGECONFIG[alsa] = "--audio-drv-list=default,,alsa-lib"
  166. PACKAGECONFIG[epoxy] = "--enable-opengl,--disable-opengl,libepoxy"
  167. PACKAGECONFIG[lzo] = "--enable-lzo,--disable-lzo,lzo"
  168. PACKAGECONFIG[numa] = "--enable-numa,--disable-numa,numactl"
  169. PACKAGECONFIG[gnutls] = "--enable-gnutls,--disable-gnutls,gnutls"
  170. PACKAGECONFIG[bzip2] = "--enable-bzip2,--disable-bzip2,bzip2"
  171. PACKAGECONFIG[libiscsi] = "--enable-libiscsi,--disable-libiscsi"
  172. PACKAGECONFIG[kvm] = "--enable-kvm,--disable-kvm"
  173. PACKAGECONFIG[virglrenderer] = "--enable-virglrenderer,--disable-virglrenderer,virglrenderer"
  174. # spice will be in meta-networking layer
  175. PACKAGECONFIG[spice] = "--enable-spice,--disable-spice,spice"
  176. # usbredir will be in meta-networking layer
  177. PACKAGECONFIG[usb-redir] = "--enable-usb-redir,--disable-usb-redir,usbredir"
  178. PACKAGECONFIG[snappy] = "--enable-snappy,--disable-snappy,snappy"
  179. PACKAGECONFIG[glusterfs] = "--enable-glusterfs,--disable-glusterfs,glusterfs"
  180. PACKAGECONFIG[xkbcommon] = "--enable-xkbcommon,--disable-xkbcommon,libxkbcommon"
  181. PACKAGECONFIG[libudev] = "--enable-libudev,--disable-libudev,eudev"
  182. PACKAGECONFIG[attr] = "--enable-attr,--disable-attr,attr,"
  183. PACKAGECONFIG[rbd] = "--enable-rbd,--disable-rbd,ceph,ceph"
  184. PACKAGECONFIG[vhost] = "--enable-vhost-net,--disable-vhost-net,,"
  185. PACKAGECONFIG[ust] = "--enable-trace-backend=ust,--enable-trace-backend=nop,lttng-ust,"
  186. PACKAGECONFIG[pie] = "--enable-pie,--disable-pie,,"
  187. PACKAGECONFIG[seccomp] = "--enable-seccomp,--disable-seccomp,libseccomp"
  188. # libnfs is currently provided by meta-kodi
  189. PACKAGECONFIG[libnfs] = "--enable-libnfs,--disable-libnfs,libnfs"
  190. PACKAGECONFIG[pmem] = "--enable-libpmem,--disable-libpmem,pmdk"
  191. PACKAGECONFIG[pulsedio] = "--enable-pa,--disable-pa,pulseaudio"
  192. PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux"
  193. PACKAGECONFIG[bpf] = "--enable-bpf,--disable-bpf,libbpf"
  194. PACKAGECONFIG[capstone] = "--enable-capstone,--disable-capstone"
  195. PACKAGECONFIG[rdma] = "--enable-rdma,--disable-rdma"
  196. PACKAGECONFIG[vde] = "--enable-vde,--disable-vde"
  197. PACKAGECONFIG[slirp] = "--enable-slirp,--disable-slirp,libslirp"
  198. PACKAGECONFIG[brlapi] = "--enable-brlapi,--disable-brlapi"
  199. PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack,"
  200. INSANE_SKIP:${PN} = "arch"
  201. FILES:${PN} += "${datadir}/icons"
  202. # Put the guest agent in a separate package
  203. PACKAGES =+ "${PN}-guest-agent"
  204. SUMMARY:${PN}-guest-agent = "QEMU guest agent"
  205. FILES:${PN}-guest-agent += " \
  206. ${bindir}/qemu-ga \
  207. ${sysconfdir}/udev/rules.d/60-qemu-guest-agent.rules \
  208. ${sysconfdir}/init.d/qemu-guest-agent \
  209. ${systemd_unitdir}/system/qemu-guest-agent.service \
  210. "
  211. INITSCRIPT_PACKAGES = "${PN}-guest-agent"
  212. INITSCRIPT_NAME:${PN}-guest-agent = "qemu-guest-agent"
  213. INITSCRIPT_PARAMS:${PN}-guest-agent = "defaults"
  214. SYSTEMD_PACKAGES = "${PN}-guest-agent"
  215. SYSTEMD_SERVICE:${PN}-guest-agent = "qemu-guest-agent.service"