Commit 72dba1244d for qemu.org
commit 72dba1244df7487512bbca76285dafe11ff30c7d
Author: Yonggang Luo <luoyonggang@gmail.com>
Date: Fri Oct 9 02:41:18 2026 +0800
tests/qtest: fix PXE test build on MinGW
Replace the GNU-specific memmem() call with a bounded memcmp()
search. Preserve binary BIOS scanning across embedded NUL bytes
without relying on a function unavailable on MinGW.
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/20261008184119.142-2-luoyonggang@gmail.com
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
diff --git a/tests/qtest/pxe-test.c b/tests/qtest/pxe-test.c
index 61c92a2df4..37d74d7ee0 100644
--- a/tests/qtest/pxe-test.c
+++ b/tests/qtest/pxe-test.c
@@ -111,10 +111,18 @@ static bool s390_bios_has_string(const char *needle)
{
const char *contents;
gsize len;
- bool found;
+ size_t needle_len = strlen(needle);
+ bool found = false;
contents = s390_bios_load(&len);
- found = memmem(contents, len, needle, strlen(needle)) != NULL;
+ if (needle_len <= len) {
+ for (gsize i = 0; i <= len - needle_len; i++) {
+ if (memcmp(contents + i, needle, needle_len) == 0) {
+ found = true;
+ break;
+ }
+ }
+ }
g_test_message("\"%s\" %s in bios", needle, found ? "found" : "not found");
return found;