On 12/13/25 01:17, Yodel Eldar wrote:
On 12/12/2025 17:33, Yodel Eldar wrote:
Hi, Cédric!
On 10/12/2025 12:13, Cédric Le Goater wrote:
A recent change in glibc 2.42.9000 [1] changes the return type of
strstr() and other string functions to be 'const char *' when the
input is a 'const char *'. This breaks the build in :
../tests/vhost-user-bridge.c: In function ‘vubr_parse_host_port’:
../tests/vhost-user-bridge.c:749:15: error: initialization discards ‘const’
qualifier from pointer target type [-Werror=discarded-qualifiers]
749 | char *p = strchr(buf, ':');
| ^~~~~~
Fix this by using the glib g_strsplit() routine instead of strdup().
[1] https://sourceware.org/git/?
p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Suggested-by: Peter Maydell <[email protected]>
Signed-off-by: Cédric Le Goater <[email protected]>
---
tests/vhost-user-bridge.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
index
a5c711b1de8e9c164dd1614f4329b8e3c05d0402..ce4c3426d3938a0b54195f3e95bb1f1c3c4ae823
100644
--- a/tests/vhost-user-bridge.c
+++ b/tests/vhost-user-bridge.c
@@ -746,14 +746,12 @@ vubr_run(VubrDev *dev)
static int
vubr_parse_host_port(const char **host, const char **port, const char *buf)
{
- char *p = strchr(buf, ':');
-
- if (!p) {
+ g_auto(GStrv) tokens = g_strsplit(buf, ":", 2);
+ if (!tokens[0] || !tokens[1]) {
return -1;
}
- *p = '\0';
- *host = strdup(buf);
- *port = strdup(p + 1);
+ *host = g_steal_pointer(&tokens[0]);
+ *port = g_steal_pointer(&tokens[1]);
return 0;
}
Thanks for addressing this before the glibc change is widely propagated
among distros.
Acked-by: Yodel Eldar <[email protected]>
Tested-by: Yodel Eldar <[email protected]>
For testing, I built and installed glibc (76 commits ahead of cd748a63a)
in an x86_64 Linux container and built vhost-user-bridge on top of that.
Ran it with:
./build/tests/vhost-user-bridge -H
qemu-system-x86_64 \
-enable-kvm -m 4G \
-object memory-backend-ram,id=mem0,size=4G,share=on \
-numa node,memdev=mem0 -mem-prealloc \
-chardev socket,id=char0,path=/tmp/vubr.sock \
-netdev type=vhost-user,id=net0,chardev=char0,vhostforce=on \
-device virtio-net-pci,netdev=net0 \
-drive file=linux.qcow2
and visually inspected the logged traffic.
Thanks,
Yodel
P.S. To build vhost-user-bridge, I had to modify util/log.c as in
the PULL submission "<[email protected]>".
For completion, the commands used:
../configure --enable-tools --enable-vhost-user --disable-system \
--disable-user
ninja tests/vhost-user-bridge
Yodel
Thanks Yodel,
My plan is to send a small PR as soon as QEMU 10.2 is out and ask
Michael T. to include the changes in the stable branches.
C.