Skip to content

Commit d62f4b6

Browse files
author
Michael Tokarev
committed
net/slirp: libslirp 4.9.0 compatibility
Update the code in net/slirp.c to be compatible with libslirp 4.9.0, which deprecated slirp_pollfds_fill() and started using slirp_os_socket type for sockets (which is a 64-bit integer on win64) for all callbacks starting with version 6 of the interface. Signed-off-by: Michael Tokarev <[email protected]> Reviewed-by: Samuel Thibault <[email protected]> Message-ID: <[email protected]> [thuth: Added some spaces to make checkpatch.pl happy] Signed-off-by: Thomas Huth <[email protected]> (cherry picked from commit f141caa) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 9a51650 commit d62f4b6

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

net/slirp.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,14 @@ static void net_slirp_timer_mod(void *timer, int64_t expire_timer,
247247
timer_mod(&t->timer, expire_timer);
248248
}
249249

250-
static void net_slirp_register_poll_fd(int fd, void *opaque)
250+
#if !SLIRP_CHECK_VERSION(4, 9, 0)
251+
# define slirp_os_socket int
252+
# define slirp_pollfds_fill_socket slirp_pollfds_fill
253+
# define register_poll_socket register_poll_fd
254+
# define unregister_poll_socket unregister_poll_fd
255+
#endif
256+
257+
static void net_slirp_register_poll_sock(slirp_os_socket fd, void *opaque)
251258
{
252259
#ifdef WIN32
253260
AioContext *ctxt = qemu_get_aio_context();
@@ -260,7 +267,7 @@ static void net_slirp_register_poll_fd(int fd, void *opaque)
260267
#endif
261268
}
262269

263-
static void net_slirp_unregister_poll_fd(int fd, void *opaque)
270+
static void net_slirp_unregister_poll_sock(slirp_os_socket fd, void *opaque)
264271
{
265272
#ifdef WIN32
266273
if (WSAEventSelect(fd, NULL, 0) != 0) {
@@ -286,8 +293,8 @@ static const SlirpCb slirp_cb = {
286293
#endif
287294
.timer_free = net_slirp_timer_free,
288295
.timer_mod = net_slirp_timer_mod,
289-
.register_poll_fd = net_slirp_register_poll_fd,
290-
.unregister_poll_fd = net_slirp_unregister_poll_fd,
296+
.register_poll_socket = net_slirp_register_poll_sock,
297+
.unregister_poll_socket = net_slirp_unregister_poll_sock,
291298
.notify = net_slirp_notify,
292299
};
293300

@@ -314,7 +321,7 @@ static int slirp_poll_to_gio(int events)
314321
return ret;
315322
}
316323

317-
static int net_slirp_add_poll(int fd, int events, void *opaque)
324+
static int net_slirp_add_poll(slirp_os_socket fd, int events, void *opaque)
318325
{
319326
GArray *pollfds = opaque;
320327
GPollFD pfd = {
@@ -363,8 +370,8 @@ static void net_slirp_poll_notify(Notifier *notifier, void *data)
363370

364371
switch (poll->state) {
365372
case MAIN_LOOP_POLL_FILL:
366-
slirp_pollfds_fill(s->slirp, &poll->timeout,
367-
net_slirp_add_poll, poll->pollfds);
373+
slirp_pollfds_fill_socket(s->slirp, &poll->timeout,
374+
net_slirp_add_poll, poll->pollfds);
368375
break;
369376
case MAIN_LOOP_POLL_OK:
370377
case MAIN_LOOP_POLL_ERR:
@@ -629,7 +636,9 @@ static int net_slirp_init(NetClientState *peer, const char *model,
629636

630637
s = DO_UPCAST(SlirpState, nc, nc);
631638

632-
cfg.version = SLIRP_CHECK_VERSION(4,7,0) ? 4 : 1;
639+
cfg.version =
640+
SLIRP_CHECK_VERSION(4, 9, 0) ? 6 :
641+
SLIRP_CHECK_VERSION(4, 7, 0) ? 4 : 1;
633642
cfg.restricted = restricted;
634643
cfg.in_enabled = ipv4;
635644
cfg.vnetwork = net;

0 commit comments

Comments
 (0)