From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7A6CD5B16C for ; Sun, 14 Dec 2025 19:23:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vUrgN-00019n-Hp; Sun, 14 Dec 2025 14:23:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vUrgM-00019c-AK for qemu-devel@nongnu.org; Sun, 14 Dec 2025 14:23:02 -0500 Received: from m228-31.mailgun.net ([159.135.228.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vUrgI-0007Iw-Ql for qemu-devel@nongnu.org; Sun, 14 Dec 2025 14:23:00 -0500 X-Mailgun-Sid: WyI4ZDFlNiIsInFlbXUtZGV2ZWxAbm9uZ251Lm9yZyIsIjk3NjA3ZSJd Received: from mail.yodel.dev (mail.yodel.dev [35.209.39.246]) by da8a8db7b5954afcd9c1e508bd3b001198cc248763ec78d2e6ee4baad63e3fda with SMTP id 693f0e8f6c5e919f061598c9; Sun, 14 Dec 2025 19:22:55 GMT X-Mailgun-Sending-Ip: 159.135.228.31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yodel.dev; s=rsa2048; t=1765740174; bh=Q3Msfk2OxNhcaYW46Wji0OsMnSf5y0Y5G7hgLP/X01c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References: X-Mailgun-Dkim:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:From:Reply-to:Subject:Date:Message-id:To: Cc:Mime-version:Content-type:Content-transfer-encoding:In-reply-to: References; b=G92zX3LXZ98+A+oxT3w/+OxWYF/cJ6gKUow8Yj2Tt0K3RHbIWnRUgmzr7cG0FWZmP yGTmve2VLOOkcdgFff0F+dd4dtLYadpt7Q7dkkJb7FulQdMfee97mF3DlGCfwmIu8l SGG2/KhliSmMejfTreUScXsuL1VXA3laB6GecObO1ZxFUNoM8kmD6O8PXiRsZhU2fk qaj+LO2MeOUnbt0udlEfbeaxFky6ICEhthKzd4WKWGGYx2b8YeuSf2L1uVwfG0oImx w/3O+KspPOOnf2ZwpiVEr/Xa3Kss9IKJq+eXgt6Wt2nAZq46JOqRxNjV6Y5qcjGmjd /WXivL1aNdfhA== Message-ID: <37773ad3-7eee-4c55-91f3-4e92e098c29f@yodel.dev> Date: Sun, 14 Dec 2025 13:22:51 -0600 MIME-Version: 1.0 Subject: Re: [PATCH 2/2] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc To: =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Cc: =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Paolo Bonzini , Richard Henderson , Michael Tokarev , Thomas Huth References: <20251210181306.926334-1-clg@redhat.com> <20251210181306.926334-3-clg@redhat.com> <2a9859fa-1617-4d26-a618-acb63fbe0bb6@yodel.dev> <82fbb148-153b-4d1c-bbe1-89f73318de5a@yodel.dev> <11454796-30d2-4a57-85a5-d42ff0dce2e6@redhat.com> <9247eb0c-1867-497d-97d0-ad1621d6c24d@yodel.dev> Content-Language: en-US X-Mailgun-Dkim: no X-Mailgun-Dkim: no From: Yodel Eldar Autocrypt: addr=yodel.eldar@yodel.dev; keydata= xjMEZxqXdhYJKwYBBAHaRw8BAQdAkletQdG3CLyANZyuf2t7Z9PK4b6HiT+DdSPUB2mHzmPN I1lvZGVsIEVsZGFyIDx5b2RlbC5lbGRhckB5b2RlbC5kZXY+wpkEExYKAEECGwMFCQOcG00F CwkIBwIGFQoJCAsCBBYCAwECHgECF4AWIQTTzRjNQG27imap+N+V7k+3NmVNrAUCaNWASwIZ AQAKCRCV7k+3NmVNrNnSAPoDjQXa6v7ZzdQSaLdRfAQy/5SsUucv+zp3WAP4pXdgJQEAzMMC Ctx4l6b13Fs2hZdRXEnF/4BZ9t1K68nwzZOV3QnOOARnGpd2EgorBgEEAZdVAQUBAQdAKPIy 3W/DKFsm1e+31zoqmOY0pqz8vjIM846wM6lEY2QDAQgHwn4EGBYIACYCGwwWIQTTzRjNQG27 imap+N+V7k+3NmVNrAUCaNWG7QUJA5wi9wAKCRCV7k+3NmVNrPusAQCQDQwETy7VT6UhHPho TkrQnsNqQfFU3tXqCTiViToktQD7B/U2/to97hQIJCWbK6yd3T+KPZJPMcHMg2XRyedUvgA= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=159.135.228.31; envelope-from=bounce+0e9322.97607e-qemu-devel=nongnu.org@yodel.dev; helo=m228-31.mailgun.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 14/12/2025 11:47, Cédric Le Goater wrote: > + Thomas, > > On 12/14/25 17:18, Yodel Eldar wrote: >> >> >> On 14/12/2025 02:56, Cédric Le Goater wrote: >>> Hello Yodel, >>> >>> On 12/13/25 21:15, Yodel Eldar wrote: >>>> >>>> On 13/12/2025 00:59, Cédric Le Goater wrote: >>>>> 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 >>>>>>>> Signed-off-by: Cédric Le Goater >>>>>>>> --- >>>>>>>>   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 >>>>>>> Tested-by: Yodel Eldar >>>>>>> >>>>>>> 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 "<20251209200537.84097-9-philmd@linaro.org>". >>>>>> >>>>>> 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. >>>>> >>>>> >>>> >>>> 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. >>>> >>> >>> 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? > > 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 > > 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 >> There's a Co-authored-by tag with your name on it if >> you so choose :-) >> >> Yodel >> > >