From 0ff365c7f043f4972a8952cf77172ab97d089ad9 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 21 Aug 2025 03:08:18 +0300 Subject: [PATCH] ports: Add qemu port --- ports/qemu/build.sh | 17 ++++++++ .../patches/0001-add-banan_os-target.patch | 12 ++++++ .../qemu/patches/0002-implement-daemon.patch | 43 +++++++++++++++++++ .../0003-disable-unsupported-signals.patch | 24 +++++++++++ .../0004-disable-unsupported-protocols.patch | 22 ++++++++++ .../qemu/patches/0005-include-sys-ioctl.patch | 32 ++++++++++++++ 6 files changed, 150 insertions(+) create mode 100755 ports/qemu/build.sh create mode 100644 ports/qemu/patches/0001-add-banan_os-target.patch create mode 100644 ports/qemu/patches/0002-implement-daemon.patch create mode 100644 ports/qemu/patches/0003-disable-unsupported-signals.patch create mode 100644 ports/qemu/patches/0004-disable-unsupported-protocols.patch create mode 100644 ports/qemu/patches/0005-include-sys-ioctl.patch diff --git a/ports/qemu/build.sh b/ports/qemu/build.sh new file mode 100755 index 00000000..8bca262a --- /dev/null +++ b/ports/qemu/build.sh @@ -0,0 +1,17 @@ +#!/bin/bash ../install.sh + +NAME='qemu' +VERSION='10.0.2' +DOWNLOAD_URL="https://download.qemu.org/qemu-$VERSION.tar.xz#ef786f2398cb5184600f69aef4d5d691efd44576a3cff4126d38d4c6fec87759" +DEPENDENCIES=('glib' 'SDL2') +MAKE_BUILD_TARGETS=('qemu-system-x86_64') +CONFIGURE_OPTIONS=( + '--cross-prefix=' + '--target-list=x86_64-softmmu' + '--disable-tpm' + '--disable-docs' +) + +pre_configure() { + echo '' > tests/meson.build +} diff --git a/ports/qemu/patches/0001-add-banan_os-target.patch b/ports/qemu/patches/0001-add-banan_os-target.patch new file mode 100644 index 00000000..ce2ee410 --- /dev/null +++ b/ports/qemu/patches/0001-add-banan_os-target.patch @@ -0,0 +1,12 @@ +diff -ruN qemu-10.0.2/configure qemu-10.0.2-banan_os/configure +--- qemu-10.0.2/configure 2025-05-29 01:05:46.000000000 +0300 ++++ qemu-10.0.2-banan_os/configure 2025-05-31 00:03:10.361102831 +0300 +@@ -360,6 +360,8 @@ + host_os=netbsd + elif check_define __APPLE__; then + host_os=darwin ++elif check_define __banan_os__; then ++ host_os=banan_os + else + # This is a fatal error, but don't report it yet, because we + # might be going to just print the --help text, or it might diff --git a/ports/qemu/patches/0002-implement-daemon.patch b/ports/qemu/patches/0002-implement-daemon.patch new file mode 100644 index 00000000..133958aa --- /dev/null +++ b/ports/qemu/patches/0002-implement-daemon.patch @@ -0,0 +1,43 @@ +diff -ru qemu-10.0.2/util/oslib-posix.c qemu-10.0.2-x86_64/util/oslib-posix.c +--- qemu-10.0.2/util/oslib-posix.c 2025-05-29 01:05:47.000000000 +0300 ++++ qemu-10.0.2-x86_64/util/oslib-posix.c 2025-08-18 02:38:04.839116456 +0300 +@@ -128,7 +128,39 @@ + + int qemu_daemon(int nochdir, int noclose) + { ++#if defined(__banan_os__) ++ const pid_t pid = fork(); ++ if (pid == -1) { ++ return -1; ++ } ++ if (pid > 0) { ++ exit(0); ++ } ++ ++ if (setsid() == -1) { ++ return -1; ++ } ++ ++ if (nochdir == 0) { ++ if (chdir("/") == -1) { ++ return -1; ++ } ++ } ++ ++ if (noclose == 0) { ++ int fd = open("/dev/null", O_RDWR); ++ if (fd == -1) { ++ return -1; ++ } ++ dup2(fd, STDIN_FILENO); ++ dup2(fd, STDOUT_FILENO); ++ dup2(fd, STDERR_FILENO); ++ } ++ ++ return 0; ++#else + return daemon(nochdir, noclose); ++#endif + } + + bool qemu_write_pidfile(const char *path, Error **errp) diff --git a/ports/qemu/patches/0003-disable-unsupported-signals.patch b/ports/qemu/patches/0003-disable-unsupported-signals.patch new file mode 100644 index 00000000..7dd6a00f --- /dev/null +++ b/ports/qemu/patches/0003-disable-unsupported-signals.patch @@ -0,0 +1,24 @@ +diff -ru qemu-10.0.2/util/main-loop.c qemu-10.0.2-x86_64/util/main-loop.c +--- qemu-10.0.2/util/main-loop.c 2025-05-29 01:05:47.000000000 +0300 ++++ qemu-10.0.2-x86_64/util/main-loop.c 2025-08-09 18:35:25.670990547 +0300 +@@ -95,8 +95,10 @@ + * not catch it reliably. + */ + sigemptyset(&set); ++#if !defined(__banan_os__) + sigaddset(&set, SIG_IPI); + sigaddset(&set, SIGIO); ++#endif + sigaddset(&set, SIGALRM); + sigaddset(&set, SIGBUS); + /* SIGINT cannot be handled via signalfd, so that ^C can be used +@@ -106,7 +108,9 @@ + */ + pthread_sigmask(SIG_BLOCK, &set, NULL); + ++#if !defined(__banan_os__) + sigdelset(&set, SIG_IPI); ++#endif + sigfd = qemu_signalfd(&set); + if (sigfd == -1) { + error_setg_errno(errp, errno, "failed to create signalfd"); diff --git a/ports/qemu/patches/0004-disable-unsupported-protocols.patch b/ports/qemu/patches/0004-disable-unsupported-protocols.patch new file mode 100644 index 00000000..c02e1f7c --- /dev/null +++ b/ports/qemu/patches/0004-disable-unsupported-protocols.patch @@ -0,0 +1,22 @@ +diff -ru qemu-10.0.2/net/colo.c qemu-10.0.2-x86_64/net/colo.c +--- qemu-10.0.2/net/colo.c 2025-05-29 01:05:46.000000000 +0300 ++++ qemu-10.0.2-x86_64/net/colo.c 2025-08-09 19:24:57.624758915 +0300 +@@ -123,14 +123,18 @@ + case IPPROTO_TCP: + case IPPROTO_UDP: + case IPPROTO_DCCP: ++#if !defined(__banan_os__) + case IPPROTO_ESP: ++#endif + case IPPROTO_SCTP: + case IPPROTO_UDPLITE: + tmp_ports = *(uint32_t *)(pkt->transport_header); + break; ++#if !defined(__banan_os__) + case IPPROTO_AH: + tmp_ports = *(uint32_t *)(pkt->transport_header + 4); + break; ++#endif + default: + break; + } diff --git a/ports/qemu/patches/0005-include-sys-ioctl.patch b/ports/qemu/patches/0005-include-sys-ioctl.patch new file mode 100644 index 00000000..ea710d39 --- /dev/null +++ b/ports/qemu/patches/0005-include-sys-ioctl.patch @@ -0,0 +1,32 @@ +diff -ru qemu-10.0.2/block/file-posix.c qemu-10.0.2-x86_64/block/file-posix.c +--- qemu-10.0.2/block/file-posix.c 2025-05-29 01:05:46.000000000 +0300 ++++ qemu-10.0.2-x86_64/block/file-posix.c 2025-08-09 19:00:18.062695074 +0300 +@@ -110,6 +110,10 @@ + #include + #endif + ++#ifdef __banan_os__ ++#include ++#endif ++ + /* OS X does not have O_DSYNC */ + #ifndef O_DSYNC + #ifdef O_SYNC +Only in qemu-10.0.2-x86_64: build +Only in qemu-10.0.2-x86_64: .cache +diff -ru qemu-10.0.2/chardev/char-pty.c qemu-10.0.2-x86_64/chardev/char-pty.c +--- qemu-10.0.2/chardev/char-pty.c 2025-05-29 01:05:46.000000000 +0300 ++++ qemu-10.0.2-x86_64/chardev/char-pty.c 2025-08-09 19:03:07.909515897 +0300 +@@ -236,7 +236,11 @@ + # include + #endif + +-#ifdef __sun__ ++#if defined(__banan_os__) ++# include ++#endif ++ ++#if defined(__sun__) || defined(__banan_os__) + + #if !defined(HAVE_OPENPTY) + /* Once illumos has openpty(), this is going to be removed. */