Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra/qemu: to make qemu installable for aarch64 #1959

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions extra/qemu-user-static/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Maintainer: David Runge <[email protected]>
# Contributor: Tobias Powalowski <[email protected]>
# Contributor: Sébastien "Seblu" Luttringer <[email protected]>
# Contributor: Qu Wenruo <[email protected]>

pkgbase=qemu
pkgname=(
qemu-user-static{,-binfmt}
)
pkgver=7.1.0
pkgrel=99
pkgdesc="QEMU static user mode emulation"
arch=(x86_64 aarch64)
url="https://www.qemu.org/"
license=(GPL2 LGPL2.1)
makedepends=(
meson
)
source=(
https://download.qemu.org/qemu-$pkgver.tar.xz{,.sig}
$pkgbase-7.1.0-io_uring.patch::https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/raw/
$pkgbase-7.1.0-block1.patch::https://gitlab.com/qemu-project/qemu/-/commit/a7c5f67a78569f8c275ea4ea9962e9c79b9d03cb.diff
$pkgbase-7.1.0-block2.patch::https://gitlab.com/qemu-project/qemu/-/commit/25474d90aa50bd32e0de395a33d8de42dd6f2aef.diff
)
sha512sums=('c60c5ff8ec99b7552e485768908920658fdd8035ff7a6fa370fb6881957dc8b7e5f18ff1a8f49bd6aa22909ede2a7c084986d8244f12074ccd33ebe40a0c411f'
'SKIP'
'306193b1ed6396acaf5d3d3957dd09954fadc7546c757cca113b35e6a0ad06e41efb94adcd9810d814858a7e2d5d3e535398128820e770b0bbdef2e5ab125cb0'
'2d1c76e2c1433867a0156bfb067a0df2229083b61215a87a317685c47f7921b0ce815901dccb005508cf0793b8c9dc37f76ef27b302fe78eb740df073710e672'
'4ad2aff54b9e7a85fc62c7dceceda5f946e7578dd1b9902a74383ffadce91d8ae7a4219e9ae3184fcba51fccea2f69fc040277c30b7566e79eb29e1604acd594')
b2sums=('e05f91ce4993c7591a2df08b5fb017f8b8ec2141ab7bfd55d14730ea6b793ac1091de539992058392a5522d4e58beee92a87752707be58e3619b8213ef9f35bf'
'SKIP'
'd8b392ef1cd629796a9221f13df43a3ea3a4c2d50a574888a65fa5f9ecffcc75134b0a33ec798be65706831043926ceb2d4b1a8751fedcd181271a986318e6ed'
'06d1b099ef1acf393f2866925bbb43a6ad93c28b976deb69c4859aca8f3bd4180e3d49ff43a3d75193af4dd890ee38243a661399517dd4bb3fb74493f7ecfe7f'
'5171ae60bbaeb7f277459c27d18ece0d7ea890a71c2cdd110ea84e15b77e3dd491b75965583a1daa859459afafa5310544f58846b38997f91e307ce86a70ab45')
validpgpkeys=('CEACC9E15534EBABB82D3FA03353C9CEF108B584') # Michael Roth <[email protected]>

_pick() {
local p="$1" f d; shift
for f; do
d="$srcdir/$p/${f#$pkgdir/}"
mkdir -p "$(dirname "$d")"
mv "$f" "$d"
rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
done
}

prepare() {
# fix issues with io_uring: https://gitlab.com/qemu-project/qemu/-/issues/1193
patch -Np1 -d $pkgbase-$pkgver -i ../$pkgbase-7.1.0-io_uring.patch

# fix issue with block alignment: https://bugs.archlinux.org/task/76220
patch -Np1 -d $pkgbase-$pkgver -i ../$pkgbase-7.1.0-block1.patch
patch -Np1 -d $pkgbase-$pkgver -i ../$pkgbase-7.1.0-block2.patch

# extract licenses for TCG
sed -n '1,23p' $pkgbase-$pkgver/tcg/tcg-internal.h > tcg.LICENSE.MIT
sed -n '1,23p' $pkgbase-$pkgver/tcg/arm/tcg-target.c.inc > tcg-arm.LICENSE.MIT
sed -n '1,23p' $pkgbase-$pkgver/tcg/tci/tcg-target.h > tci.LICENSE.MIT

# create build dir
mkdir -vp build-static
}

build() {
cd build-static
../$pkgbase-$pkgver/configure \
--prefix=/usr \
--sysconfdir=/etc \
--libexecdir=/usr/lib/qemu \
--enable-attr \
--enable-linux-user \
--enable-tcg \
--disable-bpf \
--disable-bsd-user \
--disable-capstone \
--disable-docs \
--disable-fdt \
--disable-gcrypt \
--disable-glusterfs \
--disable-gnutls \
--disable-gtk \
--disable-install-blobs \
--disable-kvm \
--disable-libiscsi \
--disable-libnfs \
--disable-libssh \
--disable-linux-io-uring \
--disable-nettle \
--disable-opengl \
--disable-qom-cast-debug \
--disable-sdl \
--disable-system \
--disable-tools \
--disable-tpm \
--disable-vde \
--disable-vhost-crypto \
--disable-vhost-kernel \
--disable-vhost-net \
--disable-vhost-user \
--disable-vnc \
--disable-werror \
--disable-xen \
--disable-zstd \
--static
ninja

}

package_qemu-user-static() {
pkgdesc="QEMU static user mode emulation"
depends=(glibc)
optdepends=('qemu-user-static-binfmt: for binary format rules')

meson install -C build-static --destdir "$pkgdir"

# rename static binaries to prevent name conflicts
for _src in "$pkgdir/usr/bin/qemu-"*; do
mv -v "$_src" "$pkgdir/usr/bin/$(basename "$_src")-static"
done
rm -rf $pkgdir/usr/lib $pkgdir/usr/share
}

package_qemu-user-static-binfmt() {
pkgdesc="Binary format rules for QEMU static user mode emulation"
depends=(qemu-user-static=$pkgver-$pkgrel)
provides=(qemu-user-binfmt-provider)
conflicts=(qemu-user-binfmt-provider)

meson install -C build-static --destdir "$pkgdir"
install -vdm 755 "$pkgdir/usr/lib/binfmt.d/"
$pkgbase-$pkgver/scripts/qemu-binfmt-conf.sh --systemd ALL --exportdir "$pkgdir/usr/lib/binfmt.d/" --qemu-path "/usr/bin"

# modify and rename binfmt.d configs to prevent name conflicts
for _conf in "$pkgdir/usr/lib/binfmt.d/"*; do
cat "$_conf" | tr -d '\n' | sed "s/:$/-static:F/" > "${_conf//.conf/-static.conf}"
done
rm -rf $pkgdir/usr/bin $pkgdir/usr/share
}
76 changes: 76 additions & 0 deletions extra/qemu-user-static/qemu-7.1.0-block1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
diff --git a/block/file-posix.c b/block/file-posix.c
index 256de1f456a77bb617aa9366f8028081313a5994..989dfc4586c2dbdf5e7b6d4a977b0e2e819195a4 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2061,6 +2061,27 @@ static int coroutine_fn raw_thread_pool_submit(BlockDriverState *bs,
return thread_pool_submit_co(pool, func, arg);
}

+/*
+ * Check if all memory in this vector is sector aligned.
+ */
+static bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
+{
+ int i;
+ size_t alignment = bdrv_min_mem_align(bs);
+ IO_CODE();
+
+ for (i = 0; i < qiov->niov; i++) {
+ if ((uintptr_t) qiov->iov[i].iov_base % alignment) {
+ return false;
+ }
+ if (qiov->iov[i].iov_len % alignment) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
static int coroutine_fn raw_co_prw(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov, int type)
{
diff --git a/block/io.c b/block/io.c
index 51d8f943a4b79a2d13c9f139ff666d542b6e7e62..c3200bcdffe2eefe7266f863bd7ac31246f2af5a 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3227,27 +3227,6 @@ void *qemu_try_blockalign0(BlockDriverState *bs, size_t size)
return mem;
}

-/*
- * Check if all memory in this vector is sector aligned.
- */
-bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
-{
- int i;
- size_t alignment = bdrv_min_mem_align(bs);
- IO_CODE();
-
- for (i = 0; i < qiov->niov; i++) {
- if ((uintptr_t) qiov->iov[i].iov_base % alignment) {
- return false;
- }
- if (qiov->iov[i].iov_len % alignment) {
- return false;
- }
- }
-
- return true;
-}
-
void bdrv_io_plug(BlockDriverState *bs)
{
BdrvChild *child;
diff --git a/include/block/block-io.h b/include/block/block-io.h
index fd25ffa9be83c28ed98e20caa470de2c27d28f1a..492f95fc05744dabb170aa2fe76f1d656a8cc124 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -150,7 +150,6 @@ void *qemu_blockalign(BlockDriverState *bs, size_t size);
void *qemu_blockalign0(BlockDriverState *bs, size_t size);
void *qemu_try_blockalign(BlockDriverState *bs, size_t size);
void *qemu_try_blockalign0(BlockDriverState *bs, size_t size);
-bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov);

void bdrv_enable_copy_on_read(BlockDriverState *bs);
void bdrv_disable_copy_on_read(BlockDriverState *bs);
20 changes: 20 additions & 0 deletions extra/qemu-user-static/qemu-7.1.0-block2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/block/file-posix.c b/block/file-posix.c
index 989dfc4586c2dbdf5e7b6d4a977b0e2e819195a4..66fdb07820c01fc0df29d9eede506af2d6b6a870 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2068,13 +2068,14 @@ static bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov)
{
int i;
size_t alignment = bdrv_min_mem_align(bs);
+ size_t len = bs->bl.request_alignment;
IO_CODE();

for (i = 0; i < qiov->niov; i++) {
if ((uintptr_t) qiov->iov[i].iov_base % alignment) {
return false;
}
- if (qiov->iov[i].iov_len % alignment) {
+ if (qiov->iov[i].iov_len % len) {
return false;
}
}
51 changes: 51 additions & 0 deletions extra/qemu-user-static/qemu-7.1.0-io_uring.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
diff --git a/block/io_uring.c b/block/io_uring.c
index a1760152e0..973e15d876 100644
--- a/block/io_uring.c
+++ b/block/io_uring.c
@@ -11,7 +11,6 @@
#include "qemu/osdep.h"
#include <liburing.h>
#include "block/aio.h"
-#include "qemu/error-report.h"
#include "qemu/queue.h"
#include "block/block.h"
#include "block/raw-aio.h"
@@ -19,7 +18,6 @@
#include "qapi/error.h"
#include "trace.h"

-
/* io_uring ring size */
#define MAX_ENTRIES 128

@@ -432,17 +430,8 @@ LuringState *luring_init(Error **errp)
}

ioq_init(&s->io_q);
-#ifdef CONFIG_LIBURING_REGISTER_RING_FD
- if (io_uring_register_ring_fd(&s->ring) < 0) {
- /*
- * Only warn about this error: we will fallback to the non-optimized
- * io_uring operations.
- */
- warn_report("failed to register linux io_uring ring file descriptor");
- }
-#endif
-
return s;
+
}

void luring_cleanup(LuringState *s)
diff --git a/meson.build b/meson.build
index 3885fc1076..63cfb844cf 100644
--- a/meson.build
+++ b/meson.build
@@ -1793,7 +1793,6 @@ config_host_data.set('CONFIG_LIBNFS', libnfs.found())
config_host_data.set('CONFIG_LIBSSH', libssh.found())
config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
-config_host_data.set('CONFIG_LIBURING_REGISTER_RING_FD', cc.has_function('io_uring_register_ring_fd', prefix: '#include <liburing.h>', dependencies:linux_io_uring))
config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
config_host_data.set('CONFIG_NUMA', numa.found())
config_host_data.set('CONFIG_OPENGL', opengl.found())
Loading