-From 871bc03884e8dd4a4b50d05022e347e72f4733d9 Mon Sep 17 00:00:00 2001
+From f0ada26ef03a37aa4b8c97246b93ab3bdf1db580 Mon Sep 17 00:00:00 2001
Date: Mon, 11 May 2020 10:46:09 +0800
-Subject: [PATCH] configure: allow disable fortify_source
+Subject: [PATCH 1/4] configure: allow disable fortify_source
Tell build system of qemu to not add _FORTIFY_SOURCE options and let the
OpenWrt base build system decide flavor of fortify_source to use
--- /dev/null
+From b2cd62027dbf41c3cd5354ed1a5f73c5e26b1811 Mon Sep 17 00:00:00 2001
+Date: Mon, 30 Mar 2020 12:48:58 +0800
+Subject: [PATCH 2/4] util/mmap-alloc: fix missing MAP_SYNC
+
+Quote musl-libc commit 9b57db3f958 ("add MAP_SYNC and
+MAP_SHARED_VALIDATE from linux v4.15")
+
+ > for synchronous page faults, new in linux commit
+ > 1c9725974074a047f6080eecc62c50a8e840d050 and
+ > b6fb293f2497a9841d94f6b57bd2bb2cd222da43
+ > note that only targets that use asm-generic/mman.h have this new
+ > flag defined, so undef it on other targets (mips*, powerpc*).
+
+Fixes 119906afa5c ("util/mmap-alloc: support MAP_SYNC in
+qemu_ram_mmap()")
+
+---
+ util/mmap-alloc.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+--- a/util/mmap-alloc.c
++++ b/util/mmap-alloc.c
+@@ -12,9 +12,6 @@
+
+ #ifdef CONFIG_LINUX
+ #include <linux/mman.h>
+-#else /* !CONFIG_LINUX */
+-#define MAP_SYNC 0x0
+-#define MAP_SHARED_VALIDATE 0x0
+ #endif /* CONFIG_LINUX */
+
+ #include "qemu/osdep.h"
+@@ -57,6 +54,13 @@ QemuFsType qemu_fd_getfs(int fd)
+ #endif
+ }
+
++#ifndef MAP_SYNC
++#define MAP_SYNC 0x0
++#endif
++#ifndef MAP_SHARED_VALIDATE
++#define MAP_SHARED_VALIDATE 0x0
++#endif
++
+ size_t qemu_fd_getpagesize(int fd)
+ {
+ #ifdef CONFIG_LINUX
--- /dev/null
+From 3e7a53edd1ffc948e1f46b3493e0c0381e437980 Mon Sep 17 00:00:00 2001
+Date: Tue, 27 May 2025 09:53:37 +0200
+Subject: [PATCH 3/4] qga: invoke separate applets for guest shutdown modes
+
+Origin: community/qemu: fix qemu-guest-agent patch
+https://gitlab.alpinelinux.org/alpine/aports/-/blob/b720d51ec844d4754dd5b29084350aa1f5c9a74d/community/qemu/guest-agent-shutdown.patch
+---
+ qga/commands-posix.c | 30 ++++--------------------------
+ 1 file changed, 4 insertions(+), 26 deletions(-)
+
+--- a/qga/commands-posix.c
++++ b/qga/commands-posix.c
+@@ -218,43 +218,21 @@ void qmp_guest_shutdown(const char *mode
+ const char *shutdown_flag;
+ Error *local_err = NULL;
+
+-#ifdef CONFIG_SOLARIS
+- const char *powerdown_flag = "-i5";
+- const char *halt_flag = "-i0";
+- const char *reboot_flag = "-i6";
+-#elif defined(CONFIG_BSD)
+- const char *powerdown_flag = "-p";
+- const char *halt_flag = "-h";
+- const char *reboot_flag = "-r";
+-#else
+- const char *powerdown_flag = "-P";
+- const char *halt_flag = "-H";
+- const char *reboot_flag = "-r";
+-#endif
++ const char *argv[] = {NULL, NULL};
+
+ slog("guest-shutdown called, mode: %s", mode);
+ if (!mode || strcmp(mode, "powerdown") == 0) {
+- shutdown_flag = powerdown_flag;
++ argv[0] = "poweroff";
+ } else if (strcmp(mode, "halt") == 0) {
+- shutdown_flag = halt_flag;
++ argv[0] = "halt";
+ } else if (strcmp(mode, "reboot") == 0) {
+- shutdown_flag = reboot_flag;
++ argv[0] = "reboot";
+ } else {
+ error_setg(errp,
+ "mode is invalid (valid values are: halt|powerdown|reboot");
+ return;
+ }
+
+- const char *argv[] = {"/sbin/shutdown",
+-#ifdef CONFIG_SOLARIS
+- shutdown_flag, "-g0", "-y",
+-#elif defined(CONFIG_BSD)
+- shutdown_flag, "+0",
+-#else
+- "-h", shutdown_flag, "+0",
+-#endif
+- "hypervisor initiated shutdown", (char *) NULL};
+-
+ ga_run_command(argv, NULL, "shutdown", &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
--- /dev/null
+From a41fe59d9ed66f807f3410408699b0b0b8afea3d Mon Sep 17 00:00:00 2001
+Date: Tue, 27 May 2025 09:57:50 +0200
+Subject: [PATCH 4/4] fix meson cross-build compiler sanity check
+
+---
+ configure | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/configure
++++ b/configure
+@@ -1845,6 +1845,7 @@ if test "$skip_meson" = no; then
+
+ echo "# Automatically generated by configure - do not modify" > $cross
+ echo "[properties]" >> $cross
++ echo "needs_exe_wrapper = true" >> $cross
+
+ # unroll any custom device configs
+ for a in $device_archs; do
+++ /dev/null
-From e1e0a76305927290d75b4aae56f1ed89d83da741 Mon Sep 17 00:00:00 2001
-Date: Mon, 30 Mar 2020 12:48:58 +0800
-Subject: [PATCH] util/mmap-alloc: fix missing MAP_SYNC
-
-Quote musl-libc commit 9b57db3f958 ("add MAP_SYNC and
-MAP_SHARED_VALIDATE from linux v4.15")
-
- > for synchronous page faults, new in linux commit
- > 1c9725974074a047f6080eecc62c50a8e840d050 and
- > b6fb293f2497a9841d94f6b57bd2bb2cd222da43
- > note that only targets that use asm-generic/mman.h have this new
- > flag defined, so undef it on other targets (mips*, powerpc*).
-
-Fixes 119906afa5c ("util/mmap-alloc: support MAP_SYNC in
-qemu_ram_mmap()")
-
----
- util/mmap-alloc.c | 10 +++++++---
- 1 file changed, 7 insertions(+), 3 deletions(-)
-
---- a/util/mmap-alloc.c
-+++ b/util/mmap-alloc.c
-@@ -12,9 +12,6 @@
-
- #ifdef CONFIG_LINUX
- #include <linux/mman.h>
--#else /* !CONFIG_LINUX */
--#define MAP_SYNC 0x0
--#define MAP_SHARED_VALIDATE 0x0
- #endif /* CONFIG_LINUX */
-
- #include "qemu/osdep.h"
-@@ -57,6 +54,13 @@ QemuFsType qemu_fd_getfs(int fd)
- #endif
- }
-
-+#ifndef MAP_SYNC
-+#define MAP_SYNC 0x0
-+#endif
-+#ifndef MAP_SHARED_VALIDATE
-+#define MAP_SHARED_VALIDATE 0x0
-+#endif
-+
- size_t qemu_fd_getpagesize(int fd)
- {
- #ifdef CONFIG_LINUX
+++ /dev/null
-Origin: community/qemu: fix qemu-guest-agent patch
-https://gitlab.alpinelinux.org/alpine/aports/-/blob/b720d51ec844d4754dd5b29084350aa1f5c9a74d/community/qemu/guest-agent-shutdown.patch
----
---- a/qga/commands-posix.c
-+++ b/qga/commands-posix.c
-@@ -218,43 +218,21 @@ void qmp_guest_shutdown(const char *mode
- const char *shutdown_flag;
- Error *local_err = NULL;
-
--#ifdef CONFIG_SOLARIS
-- const char *powerdown_flag = "-i5";
-- const char *halt_flag = "-i0";
-- const char *reboot_flag = "-i6";
--#elif defined(CONFIG_BSD)
-- const char *powerdown_flag = "-p";
-- const char *halt_flag = "-h";
-- const char *reboot_flag = "-r";
--#else
-- const char *powerdown_flag = "-P";
-- const char *halt_flag = "-H";
-- const char *reboot_flag = "-r";
--#endif
-+ const char *argv[] = {NULL, NULL};
-
- slog("guest-shutdown called, mode: %s", mode);
- if (!mode || strcmp(mode, "powerdown") == 0) {
-- shutdown_flag = powerdown_flag;
-+ argv[0] = "poweroff";
- } else if (strcmp(mode, "halt") == 0) {
-- shutdown_flag = halt_flag;
-+ argv[0] = "halt";
- } else if (strcmp(mode, "reboot") == 0) {
-- shutdown_flag = reboot_flag;
-+ argv[0] = "reboot";
- } else {
- error_setg(errp,
- "mode is invalid (valid values are: halt|powerdown|reboot");
- return;
- }
-
-- const char *argv[] = {"/sbin/shutdown",
--#ifdef CONFIG_SOLARIS
-- shutdown_flag, "-g0", "-y",
--#elif defined(CONFIG_BSD)
-- shutdown_flag, "+0",
--#else
-- "-h", shutdown_flag, "+0",
--#endif
-- "hypervisor initiated shutdown", (char *) NULL};
--
- ga_run_command(argv, NULL, "shutdown", &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+++ /dev/null
---- a/meson.build
-+++ b/meson.build
-@@ -3828,10 +3828,6 @@ subdir('common-user')
- subdir('bsd-user')
- subdir('linux-user')
-
--# needed for fuzzing binaries
--subdir('tests/qtest/libqos')
--subdir('tests/qtest/fuzz')
--
- # accel modules
- target_modules += { 'accel' : { 'qtest': qtest_module_ss }}
-
-@@ -4456,10 +4452,6 @@ subdir('scripts')
- subdir('tools')
- subdir('pc-bios')
- subdir('docs')
--subdir('tests')
--if gtk.found()
-- subdir('po')
--endif
-
- if host_machine.system() == 'windows'
- nsis_cmd = [
+++ /dev/null
---- a/configure
-+++ b/configure
-@@ -1845,6 +1845,7 @@ if test "$skip_meson" = no; then
-
- echo "# Automatically generated by configure - do not modify" > $cross
- echo "[properties]" >> $cross
-+ echo "needs_exe_wrapper = true" >> $cross
-
- # unroll any custom device configs
- for a in $device_archs; do