Fix const qualifier build errors with recent glibc
cover Fix const qualifier build errors with recent glibc
Hello,
More fixes for the build breakage due to the recent change in glibc 2.42.9000 :
https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Thanks,
C.
Cédric Le Goater (2):
i386: Fix const qualifier build errors with recent glibc tests/vhost-user-bridge.c: Fix const qualifier build errors with
recent glibc
hw/i386/x86-common.c | 2 +- tests/vhost-user-bridge.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/2 i386: Fix const qualifier build errors with recent glibc
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 :
../hw/i386/x86-common.c:827:11: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
827 | vmode = strstr(kernel_cmdline, "vga=");
| ^
Fix this by changing the type of the variables that store the result of these functions to 'const char *'.
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
--- hw/i386/x86-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/x86-common.c +1 -1
@@ -654,7 +654,7 @@ void x86_load_linux(X86MachineState *x86ms,uint8_t header[8192 ], *setup, *kernel;hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =0 ;FILE *f; -char *vmode; +const char *vmode;MachineState *machine =MACHINE (x86ms);struct setup_data *setup_data;const char *kernel_filename = machine->kernel_filename;
Signature · 1 line
2.52.0
Re: [PATCH 1/2] i386: Fix const qualifier build errors with recent glibc
Quoted 24 lines · Cédric Le Goater
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 :
../hw/i386/x86-common.c:827:11: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
827 | vmode =strstr(kernel_cmdline, "vga=");
| ^Fix this by changing the type of the variables that store the result of these functions to 'const char *'.
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Signed-off-by Cédric Le Goater <[email protected]>--- hw/i386/x86-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/x86-common.c +0
-0
hw/i386/x86-common.c void x86_load_linux(X86MachineState *x86ms,
Quoted 9 lines
hw/i386/x86-common.c +1
-2@@ -654,7 +654,7 @@ void x86_load_linux(X86MachineState *x86ms,uint8_t header[8192 ], *setup, *kernel;hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =0 ;FILE *f; -char *vmode; +const char *vmode;MachineState *machine =MACHINE (x86ms);struct setup_data *setup_data;const char *kernel_filename = machine->kernel_filename; --
thanks
-- PMM
Re: [PATCH 1/2] i386: Fix const qualifier build errors with recent glibc
In reply to Cédric Le GoaterQuoted 11 lines · Cédric Le Goater
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 :
../hw/i386/x86-common.c:827:11: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
827 | vmode =strstr(kernel_cmdline, "vga=");
| ^Fix this by changing the type of the variables that store the result of these functions to 'const char *'.
Quoted 6 lines
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Signed-off-by Cédric Le Goater <[email protected]>--- hw/i386/x86-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 2/2 tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
In reply to Cédric Le GoaterA 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
--- tests/vhost-user-bridge.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tests/vhost-user-bridge.c +4 -6
@@ -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 ; }
Signature · 1 line
2.52.0
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Quoted 11 lines · Cédric Le Goater
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 ofstrdup().
Quoted 7 lines
[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(-)
I should have added 'Not Tested' !
Thanks,
C.
Quoted 23 lines
tests/vhost-user-bridge.c +4
-6@@ -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 ; }
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Quoted 14 lines · Cédric Le Goater
Quoted 13 lines · Cédric Le Goater
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 ofstrdup().[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Quoted 7 lines
Quoted 5 lines
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(-)I should have added 'Not Tested' !
It seems to be going well:
$ build/tests/vhost-user-bridge -l 127.0.0.1:1234 -r 127.0.0.1:4321 ud socket: /tmp/vubr.sock (server) local: 127.0.0.1:1234 remote: 127.0.0.1:4321 Waiting for connections on UNIX socket /tmp/vubr.sock ... Added sock 3 for watching. max_sock: 3 Added sock 4 for watching. max_sock: 4 Waiting for data from udp backend on 127.0.0.1:1234...
C.
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
In reply to Cédric Le GoaterHi, Cédric!
Quoted 32 lines · Cédric Le Goater
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 ofstrdup().[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(-)tests/vhost-user-bridge.c +2
-3@@ -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 ]) {
tests/vhost-user-bridge.c vubr_run(VubrDev *dev) · line 757
Quoted 10 lines
tests/vhost-user-bridge.c +2
-3return -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.
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.qcow2and visually inspected the logged traffic.
Thanks,
Yodel
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Quoted 66 lines · Yodel Eldar
Hi, Cédric!
Quoted 33 lines · Cédric Le Goater
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 ofstrdup().[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(-)tests/vhost-user-bridge.c +0
-0@@ -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;Quoted 8 lines
}
- *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 anx86_64Linux 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
Quoted 5 lines
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
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Quoted 77 lines · Yodel Eldar
Quoted 66 lines · Yodel Eldar
Hi, Cédric!
Quoted 33 lines · Cédric Le Goater
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 ofstrdup().[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(-)tests/vhost-user-bridge.c +0
-0@@ -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;Quoted 8 lines
}
- *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 anx86_64Linux 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.qcow2Quoted 5 lines
and visually inspected the logged traffic.
Thanks,
Yodel
P.S. To build vhost-user-bridge, I had to modifyutil/log.cas in the PULL submission "<[email protected]>".
Quoted 9 lines
For completion, the commands used:
../configure --enable-tools --enable-vhost-user --disable-system \
--disable-userninja 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.
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Quoted 89 lines · Cédric Le Goater
Quoted 77 lines · Yodel Eldar
Quoted 66 lines · Yodel Eldar
Hi, Cédric!
Quoted 33 lines · Cédric Le Goater
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 ofstrdup().[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(-)tests/vhost-user-bridge.c +0
-0@@ -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;Quoted 8 lines
}
- *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 anx86_64Linux 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.qcow2Quoted 5 lines
and visually inspected the logged traffic.
Thanks,
Yodel
P.S. To build vhost-user-bridge, I had to modifyutil/log.cas in the PULL submission "<[email protected]>".Quoted 9 lines
For completion, the commands used:
../configure --enable-tools --enable-vhost-user --disable-system \
--disable-userninja tests/vhost-user-bridge
Yodel
Quoted 8 lines
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.
Glad to hear it!
Sorry for staggering my testing methodology over multiple emails, but I should add for clarification and completeness: to exercise your change to vubr_parse_host_port(), I passed various input into the -l and -r options of vhost-user-bridge; and, with:
tcpdump -i lo -n -X udp port 5678
while running:
./build/tests/vhost-user-bridge -H -l 127.0.0.1:4567 -r 127.0.0.1:5678
for example,
I was able to monitor the traffic (ARP requests) from port 4567 to 5678.
Yodel
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Hello Yodel,
Quoted 109 lines · Yodel Eldar
Quoted 89 lines · Cédric Le Goater
Quoted 77 lines · Yodel Eldar
Quoted 66 lines · Yodel Eldar
Hi, Cédric!
Quoted 33 lines · Cédric Le Goater
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 ofstrdup().[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(-)tests/vhost-user-bridge.c +0
-0@@ -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;Quoted 8 lines
}
- *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 anx86_64Linux 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.qcow2Quoted 5 lines
and visually inspected the logged traffic.
Thanks,
Yodel
P.S. To build vhost-user-bridge, I had to modifyutil/log.cas in the PULL submission "<[email protected]>".Quoted 9 lines
For completion, the commands used:
../configure --enable-tools --enable-vhost-user --disable-system \
--disable-userninja tests/vhost-user-bridge
Yodel
Quoted 8 lines
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.
Glad to hear it!
Sorry for staggering my testing methodology over multiple emails, but I should add for clarification and completeness: to exercise your change to
vubr_parse_host_port(), I passed various input into the -l and -r options of vhost-user-bridge; and, with:tcpdump -i lo -n -X udp port 5678
Quoted 8 lines
while running:
./build/tests/vhost-user-bridge -H -l 127.0.0.1:4567 -r 127.0.0.1:5678
for example,
I was able to monitor the traffic (ARP requests) from port 4567 to 5678.
Would you mind providing a test case under tests/ or tests/functional ?
Thanks,
C.
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Quoted 118 lines · Cédric Le Goater
Hello Yodel,
Quoted 115 lines · Yodel Eldar
Quoted 89 lines · Cédric Le Goater
Quoted 77 lines · Yodel Eldar
Quoted 66 lines · Yodel Eldar
Hi, Cédric!
Quoted 33 lines · Cédric Le Goater
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 ofstrdup().[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(-)tests/vhost-user-bridge.c +0
-0@@ -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;Quoted 8 lines
}
- *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 anx86_64Linux 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.qcow2Quoted 5 lines
and visually inspected the logged traffic.
Thanks,
Yodel
P.S. To build vhost-user-bridge, I had to modifyutil/log.cas in the PULL submission "<[email protected]>".Quoted 9 lines
For completion, the commands used:
../configure --enable-tools --enable-vhost-user --disable-system \
--disable-userninja tests/vhost-user-bridge
Yodel
Quoted 8 lines
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.
Glad to hear it!
Sorry for staggering my testing methodology over multiple emails, but I should add for clarification and completeness: to exercise your change to
vubr_parse_host_port(), I passed various input into the -l and -r options of vhost-user-bridge; and, with:tcpdump -i lo -n -X udp port 5678
while running:
./build/tests/vhost-user-bridge -H -l 127.0.0.1:4567 -r 127.0.0.1:5678
for example,
Quoted 10 lines
Quoted 2 lines
I was able to monitor the traffic (ARP requests) from port 4567 to 5678.
Would you mind providing a test case under tests/ or tests/functional ?
Thanks,
C.
Certainly, that's a great idea! Although, I'll need to get better acquainted with QEMU's testing framework... Would you be willing to answer the occasional question regarding scope, approach, conventions, etc. over IRC? There's a Co-authored-by tag with your name on it if you so choose :-)
Yodel
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
+ Thomas,
Quoted 128 lines · Yodel Eldar
Quoted 125 lines · Cédric Le Goater
Hello Yodel,
Quoted 109 lines · Yodel Eldar
Quoted 89 lines · Cédric Le Goater
Quoted 77 lines · Yodel Eldar
Quoted 66 lines · Yodel Eldar
Hi, Cédric!
Quoted 33 lines · Cédric Le Goater
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 ofstrdup().[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(-)tests/vhost-user-bridge.c +0
-0@@ -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;Quoted 8 lines
}
- *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 anx86_64Linux 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.qcow2Quoted 5 lines
and visually inspected the logged traffic.
Thanks,
Yodel
P.S. To build vhost-user-bridge, I had to modifyutil/log.cas in the PULL submission "<[email protected]>".Quoted 9 lines
For completion, the commands used:
../configure --enable-tools --enable-vhost-user --disable-system \
--disable-userninja tests/vhost-user-bridge
Yodel
Quoted 8 lines
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.
Glad to hear it!
Sorry for staggering my testing methodology over multiple emails, but I should add for clarification and completeness: to exercise your change to
vubr_parse_host_port(), I passed various input into the -l and -r options of vhost-user-bridge; and, with:tcpdump -i lo -n -X udp port 5678
Quoted 8 lines
while running:
./build/tests/vhost-user-bridge -H -l 127.0.0.1:4567 -r 127.0.0.1:5678
for example,
I was able to monitor the traffic (ARP requests) from port 4567 to 5678.
Would you mind providing a test case under tests/ or tests/functional ?
Thanks,
Quoted 8 lines
Quoted 3 lines
C.
Certainly, that's a great idea! Although, I'll need to get better acquainted with QEMU's testing framework... Would you be willing to answer the occasional question regarding scope, approach, conventions, etc. over IRC?
Sure. The #qemu channel is hosted on OFTC.
I think this test would qualify as a functional test. To run :
$ make check-functional
You could get some inspiration out of test_virtio_gpu.py I suppose. Check source [2].
See [3] to send patches.
Thanks,
C.
[1] https://www.qemu.org/docs/master/devel/testing/main.html#functional-tests-using-python
[2] https://gitlab.com/qemu-project/qemu/-/blob/master/tests/functional/x86_64/test_virtio_gpu.py?ref_type=heads
[3] https://www.qemu.org/docs/master/devel/submitting-a-patch.html
Quoted 5 lines
There's a Co-authored-by tag with your name on it if you so choose :-)
Yodel
Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Quoted 151 lines · Cédric Le Goater
+ Thomas,
Quoted 128 lines · Yodel Eldar
Quoted 125 lines · Cédric Le Goater
Hello Yodel,
Quoted 109 lines · Yodel Eldar
Quoted 89 lines · Cédric Le Goater
Quoted 77 lines · Yodel Eldar
Quoted 66 lines · Yodel Eldar
Hi, Cédric!
Quoted 33 lines · Cédric Le Goater
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 ofstrdup().[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(-)tests/vhost-user-bridge.c +0
-0@@ -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;Quoted 8 lines
}
- *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 anx86_64Linux 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.qcow2Quoted 5 lines
and visually inspected the logged traffic.
Thanks,
Yodel
P.S. To build vhost-user-bridge, I had to modifyutil/log.cas in the PULL submission "<[email protected]>".Quoted 9 lines
For completion, the commands used:
../configure --enable-tools --enable-vhost-user --disable-system \
--disable-userninja tests/vhost-user-bridge
Yodel
Quoted 8 lines
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.
Glad to hear it!
Sorry for staggering my testing methodology over multiple emails, but I should add for clarification and completeness: to exercise your change to
vubr_parse_host_port(), I passed various input into the -l and -r options of vhost-user-bridge; and, with:tcpdump -i lo -n -X udp port 5678
Quoted 8 lines
while running:
./build/tests/vhost-user-bridge -H -l 127.0.0.1:4567 -r 127.0.0.1:5678
for example,
I was able to monitor the traffic (ARP requests) from port 4567 to 5678.
Would you mind providing a test case under tests/ or tests/functional ?
Thanks,
Quoted 8 lines
Quoted 3 lines
C.
Certainly, that's a great idea! Although, I'll need to get better acquainted with QEMU's testing framework... Would you be willing to answer the occasional question regarding scope, approach, conventions, etc. over IRC?
Sure. The #qemu channel is hosted on OFTC.
I think this test would qualify as a functional test. To run :
$ make check-functionalYou could get some inspiration out of
test_virtio_gpu.pyI suppose. Check source [2].See [3] to send patches.
Quoted 9 lines
Thanks,
C.
[1] https://www.qemu.org/docs/master/devel/testing/main.html#functional- tests-using-python
[2] https://gitlab.com/qemu-project/qemu/-/blob/master/tests/functional/ x86_64/test_virtio_gpu.py?ref_type=heads
[3] https://www.qemu.org/docs/master/devel/submitting-a-patch.html
Thanks for the links!
Currently, the plan's to replace tcpdump with the -object filter-dump feature and look for the user-supplied hosts and ports in the output, though I suspect there's a better way to do that. This would essentially only exercise vubr_parse_host_port() as in my manual testing of your patch. Please let me know if you had another direction in mind.
My nick's "yodel" on OFTC, and I'll reach out if I hit a snag.
Thanks,
Yodel
Quoted 7 lines
Quoted 5 lines
There's a Co-authored-by tag with your name on it if you so choose :-)
Yodel