* [PATCH] net/slirp: introduce slirp_os_socket to stay compatible with libslirp past 4.8.0
@ 2024-10-05 7:07 Michael Tokarev
2024-10-09 23:06 ` Samuel Thibault
0 siblings, 1 reply; 6+ messages in thread
From: Michael Tokarev @ 2024-10-05 7:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Samuel Thibault, Michael Tokarev
libslirp introduced new typedef after 4.8.0, slirp_os_socket, which
is defined to SOCKET on windows, which, in turn, is a 64bit number.
qemu uses int, so callback function prorotypes changed. Introduce
slirp_os_socket locally if SLIRP_INVALID_SOCKET is not defined (this
define has been introduced together wiht slirp_os_socket type), for
libslirp <= 4.8.0, and use it in callback function definitions.
Link: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/72f85005a2307fd0961543e3cea861ad7a4d201e
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2603
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
net/slirp.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c
index eb9a456ed4..fa07268cf4 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -98,6 +98,10 @@ typedef struct SlirpState {
GSList *fwd;
} SlirpState;
+#ifndef SLIRP_INVALID_SOCKET /* after 4.8.0 */
+typedef int slirp_os_socket;
+#endif
+
static struct slirp_config_str *slirp_configs;
static QTAILQ_HEAD(, SlirpState) slirp_stacks =
QTAILQ_HEAD_INITIALIZER(slirp_stacks);
@@ -247,7 +251,7 @@ static void net_slirp_timer_mod(void *timer, int64_t expire_timer,
timer_mod(&t->timer, expire_timer);
}
-static void net_slirp_register_poll_fd(int fd, void *opaque)
+static void net_slirp_register_poll_fd(slirp_os_socket fd, void *opaque)
{
#ifdef WIN32
AioContext *ctxt = qemu_get_aio_context();
@@ -260,7 +264,7 @@ static void net_slirp_register_poll_fd(int fd, void *opaque)
#endif
}
-static void net_slirp_unregister_poll_fd(int fd, void *opaque)
+static void net_slirp_unregister_poll_fd(slirp_os_socket fd, void *opaque)
{
#ifdef WIN32
if (WSAEventSelect(fd, NULL, 0) != 0) {
@@ -314,7 +318,7 @@ static int slirp_poll_to_gio(int events)
return ret;
}
-static int net_slirp_add_poll(int fd, int events, void *opaque)
+static int net_slirp_add_poll(slirp_os_socket fd, int events, void *opaque)
{
GArray *pollfds = opaque;
GPollFD pfd = {
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] net/slirp: introduce slirp_os_socket to stay compatible with libslirp past 4.8.0
2024-10-05 7:07 [PATCH] net/slirp: introduce slirp_os_socket to stay compatible with libslirp past 4.8.0 Michael Tokarev
@ 2024-10-09 23:06 ` Samuel Thibault
2025-01-30 2:13 ` Samuel Thibault
0 siblings, 1 reply; 6+ messages in thread
From: Samuel Thibault @ 2024-10-09 23:06 UTC (permalink / raw)
To: Michael Tokarev; +Cc: qemu-devel
Hello,
Michael Tokarev, le sam. 05 oct. 2024 10:07:53 +0300, a ecrit:
> libslirp introduced new typedef after 4.8.0, slirp_os_socket, which
> is defined to SOCKET on windows, which, in turn, is a 64bit number.
> qemu uses int, so callback function prorotypes changed.
I have fixed the code in upstream libslirp, to avoid breaking the API
and ABI, and instead provide new functions & methods so that
qemu/libslirp can upgrade smoothly.
> Introduce
> slirp_os_socket locally if SLIRP_INVALID_SOCKET is not defined (this
> define has been introduced together wiht slirp_os_socket type), for
> libslirp <= 4.8.0, and use it in callback function definitions.
>
> Link: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/72f85005a2307fd0961543e3cea861ad7a4d201e
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2603
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
> net/slirp.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/net/slirp.c b/net/slirp.c
> index eb9a456ed4..fa07268cf4 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -98,6 +98,10 @@ typedef struct SlirpState {
> GSList *fwd;
> } SlirpState;
>
> +#ifndef SLIRP_INVALID_SOCKET /* after 4.8.0 */
You can instead use SLIRP_CONFIG_VERSION_MAX >= 6, and if so set
cfg.version to 6 and use the new fields and functions.
> +typedef int slirp_os_socket;
> +#endif
> +
> static struct slirp_config_str *slirp_configs;
> static QTAILQ_HEAD(, SlirpState) slirp_stacks =
> QTAILQ_HEAD_INITIALIZER(slirp_stacks);
> @@ -247,7 +251,7 @@ static void net_slirp_timer_mod(void *timer, int64_t expire_timer,
> timer_mod(&t->timer, expire_timer);
> }
>
> -static void net_slirp_register_poll_fd(int fd, void *opaque)
> +static void net_slirp_register_poll_fd(slirp_os_socket fd, void *opaque)
> {
> #ifdef WIN32
> AioContext *ctxt = qemu_get_aio_context();
> @@ -260,7 +264,7 @@ static void net_slirp_register_poll_fd(int fd, void *opaque)
> #endif
> }
>
> -static void net_slirp_unregister_poll_fd(int fd, void *opaque)
> +static void net_slirp_unregister_poll_fd(slirp_os_socket fd, void *opaque)
> {
> #ifdef WIN32
> if (WSAEventSelect(fd, NULL, 0) != 0) {
> @@ -314,7 +318,7 @@ static int slirp_poll_to_gio(int events)
> return ret;
> }
>
> -static int net_slirp_add_poll(int fd, int events, void *opaque)
> +static int net_slirp_add_poll(slirp_os_socket fd, int events, void *opaque)
> {
> GArray *pollfds = opaque;
> GPollFD pfd = {
> --
> 2.39.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/slirp: introduce slirp_os_socket to stay compatible with libslirp past 4.8.0
2024-10-09 23:06 ` Samuel Thibault
@ 2025-01-30 2:13 ` Samuel Thibault
2025-01-30 10:09 ` Thomas Huth
0 siblings, 1 reply; 6+ messages in thread
From: Samuel Thibault @ 2025-01-30 2:13 UTC (permalink / raw)
To: Michael Tokarev; +Cc: qemu-devel
Hello,
Samuel Thibault, le jeu. 10 oct. 2024 01:06:47 +0200, a ecrit:
> Michael Tokarev, le sam. 05 oct. 2024 10:07:53 +0300, a ecrit:
> > libslirp introduced new typedef after 4.8.0, slirp_os_socket, which
> > is defined to SOCKET on windows, which, in turn, is a 64bit number.
> > qemu uses int, so callback function prorotypes changed.
>
> I have fixed the code in upstream libslirp, to avoid breaking the API
> and ABI, and instead provide new functions & methods so that
> qemu/libslirp can upgrade smoothly.
It is now released in version 4.9.0 of libslirp.
Samuel
> > Introduce
> > slirp_os_socket locally if SLIRP_INVALID_SOCKET is not defined (this
> > define has been introduced together wiht slirp_os_socket type), for
> > libslirp <= 4.8.0, and use it in callback function definitions.
> >
> > Link: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/72f85005a2307fd0961543e3cea861ad7a4d201e
> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2603
> > Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> > ---
> > net/slirp.c | 10 +++++++---
> > 1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/slirp.c b/net/slirp.c
> > index eb9a456ed4..fa07268cf4 100644
> > --- a/net/slirp.c
> > +++ b/net/slirp.c
> > @@ -98,6 +98,10 @@ typedef struct SlirpState {
> > GSList *fwd;
> > } SlirpState;
> >
> > +#ifndef SLIRP_INVALID_SOCKET /* after 4.8.0 */
>
> You can instead use SLIRP_CONFIG_VERSION_MAX >= 6, and if so set
> cfg.version to 6 and use the new fields and functions.
>
> > +typedef int slirp_os_socket;
> > +#endif
> > +
> > static struct slirp_config_str *slirp_configs;
> > static QTAILQ_HEAD(, SlirpState) slirp_stacks =
> > QTAILQ_HEAD_INITIALIZER(slirp_stacks);
> > @@ -247,7 +251,7 @@ static void net_slirp_timer_mod(void *timer, int64_t expire_timer,
> > timer_mod(&t->timer, expire_timer);
> > }
> >
> > -static void net_slirp_register_poll_fd(int fd, void *opaque)
> > +static void net_slirp_register_poll_fd(slirp_os_socket fd, void *opaque)
> > {
> > #ifdef WIN32
> > AioContext *ctxt = qemu_get_aio_context();
> > @@ -260,7 +264,7 @@ static void net_slirp_register_poll_fd(int fd, void *opaque)
> > #endif
> > }
> >
> > -static void net_slirp_unregister_poll_fd(int fd, void *opaque)
> > +static void net_slirp_unregister_poll_fd(slirp_os_socket fd, void *opaque)
> > {
> > #ifdef WIN32
> > if (WSAEventSelect(fd, NULL, 0) != 0) {
> > @@ -314,7 +318,7 @@ static int slirp_poll_to_gio(int events)
> > return ret;
> > }
> >
> > -static int net_slirp_add_poll(int fd, int events, void *opaque)
> > +static int net_slirp_add_poll(slirp_os_socket fd, int events, void *opaque)
> > {
> > GArray *pollfds = opaque;
> > GPollFD pfd = {
> > --
> > 2.39.5
--
Samuel
c> ah (on trouve fluide glacial sur le net, ou il faut aller dans le monde reel ?)
s> dans le monde reel
c> zut
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/slirp: introduce slirp_os_socket to stay compatible with libslirp past 4.8.0
2025-01-30 2:13 ` Samuel Thibault
@ 2025-01-30 10:09 ` Thomas Huth
2025-01-30 10:12 ` Michael Tokarev
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Huth @ 2025-01-30 10:09 UTC (permalink / raw)
To: Samuel Thibault, Michael Tokarev; +Cc: qemu-devel, Stefan Hajnoczi
On 30/01/2025 03.13, Samuel Thibault wrote:
> Hello,
>
> Samuel Thibault, le jeu. 10 oct. 2024 01:06:47 +0200, a ecrit:
>> Michael Tokarev, le sam. 05 oct. 2024 10:07:53 +0300, a ecrit:
>>> libslirp introduced new typedef after 4.8.0, slirp_os_socket, which
>>> is defined to SOCKET on windows, which, in turn, is a 64bit number.
>>> qemu uses int, so callback function prorotypes changed.
>>
>> I have fixed the code in upstream libslirp, to avoid breaking the API
>> and ABI, and instead provide new functions & methods so that
>> qemu/libslirp can upgrade smoothly.
>
> It is now released in version 4.9.0 of libslirp.
Seems like 4.9.0 breaks the CI:
https://gitlab.com/thuth/qemu/-/jobs/8994301595#L4373
Could you please have a look?
Thanks,
Thomas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/slirp: introduce slirp_os_socket to stay compatible with libslirp past 4.8.0
2025-01-30 10:09 ` Thomas Huth
@ 2025-01-30 10:12 ` Michael Tokarev
2025-01-30 10:15 ` Samuel Thibault
0 siblings, 1 reply; 6+ messages in thread
From: Michael Tokarev @ 2025-01-30 10:12 UTC (permalink / raw)
To: Thomas Huth, Samuel Thibault; +Cc: qemu-devel, Stefan Hajnoczi
30.01.2025 13:09, Thomas Huth wrote:
> On 30/01/2025 03.13, Samuel Thibault wrote:
>> Hello,
>>
>> Samuel Thibault, le jeu. 10 oct. 2024 01:06:47 +0200, a ecrit:
>>> Michael Tokarev, le sam. 05 oct. 2024 10:07:53 +0300, a ecrit:
>>>> libslirp introduced new typedef after 4.8.0, slirp_os_socket, which
>>>> is defined to SOCKET on windows, which, in turn, is a 64bit number.
>>>> qemu uses int, so callback function prorotypes changed.
>>>
>>> I have fixed the code in upstream libslirp, to avoid breaking the API
>>> and ABI, and instead provide new functions & methods so that
>>> qemu/libslirp can upgrade smoothly.
>>
>> It is now released in version 4.9.0 of libslirp.
>
> Seems like 4.9.0 breaks the CI:
>
> https://gitlab.com/thuth/qemu/-/jobs/8994301595#L4373
Yes, it's because the old method used by qemu is now deprecated,
and we build with -Werror.
The prob here is that apparently we don't have a good way to use
slirp on win64. Because the new slirp callback uses SOCKET type
instead of int, and SOCKET is 64bit on win64, and qemu main loop
is based on GPollFD which uses int.
/mjt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/slirp: introduce slirp_os_socket to stay compatible with libslirp past 4.8.0
2025-01-30 10:12 ` Michael Tokarev
@ 2025-01-30 10:15 ` Samuel Thibault
0 siblings, 0 replies; 6+ messages in thread
From: Samuel Thibault @ 2025-01-30 10:15 UTC (permalink / raw)
To: Michael Tokarev; +Cc: Thomas Huth, qemu-devel, Stefan Hajnoczi
Michael Tokarev, le jeu. 30 janv. 2025 13:12:39 +0300, a ecrit:
> 30.01.2025 13:09, Thomas Huth wrote:
> > On 30/01/2025 03.13, Samuel Thibault wrote:
> > > Hello,
> > >
> > > Samuel Thibault, le jeu. 10 oct. 2024 01:06:47 +0200, a ecrit:
> > > > Michael Tokarev, le sam. 05 oct. 2024 10:07:53 +0300, a ecrit:
> > > > > libslirp introduced new typedef after 4.8.0, slirp_os_socket, which
> > > > > is defined to SOCKET on windows, which, in turn, is a 64bit number.
> > > > > qemu uses int, so callback function prorotypes changed.
> > > >
> > > > I have fixed the code in upstream libslirp, to avoid breaking the API
> > > > and ABI, and instead provide new functions & methods so that
> > > > qemu/libslirp can upgrade smoothly.
> > >
> > > It is now released in version 4.9.0 of libslirp.
> >
> > Seems like 4.9.0 breaks the CI:
> >
> > https://gitlab.com/thuth/qemu/-/jobs/8994301595#L4373
>
> Yes, it's because the old method used by qemu is now deprecated,
> and we build with -Werror.
>
> The prob here is that apparently we don't have a good way to use
> slirp on win64. Because the new slirp callback uses SOCKET type
> instead of int, and SOCKET is 64bit on win64, and qemu main loop
> is based on GPollFD which uses int.
? GPollFD uses a gint64 on win64.
Samuel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-30 10:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-05 7:07 [PATCH] net/slirp: introduce slirp_os_socket to stay compatible with libslirp past 4.8.0 Michael Tokarev
2024-10-09 23:06 ` Samuel Thibault
2025-01-30 2:13 ` Samuel Thibault
2025-01-30 10:09 ` Thomas Huth
2025-01-30 10:12 ` Michael Tokarev
2025-01-30 10:15 ` Samuel Thibault
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).