[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/20] net/slirp: libslirp 4.9.0 compatibility
From: |
Thomas Huth |
Subject: |
[PULL 20/20] net/slirp: libslirp 4.9.0 compatibility |
Date: |
Thu, 30 Jan 2025 14:15:34 +0100 |
From: Michael Tokarev <mjt@tls.msk.ru>
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 <mjt@tls.msk.ru>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-ID: <20250130123253.864681-1-mjt@tls.msk.ru>
[thuth: Added some spaces to make checkpatch.pl happy]
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
net/slirp.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c
index 49dc62f776..97d08ed1fb 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -247,7 +247,14 @@ 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)
+#if !SLIRP_CHECK_VERSION(4, 9, 0)
+# define slirp_os_socket int
+# define slirp_pollfds_fill_socket slirp_pollfds_fill
+# define register_poll_socket register_poll_fd
+# define unregister_poll_socket unregister_poll_fd
+#endif
+
+static void net_slirp_register_poll_sock(slirp_os_socket fd, void *opaque)
{
#ifdef WIN32
AioContext *ctxt = qemu_get_aio_context();
@@ -260,7 +267,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_sock(slirp_os_socket fd, void *opaque)
{
#ifdef WIN32
if (WSAEventSelect(fd, NULL, 0) != 0) {
@@ -286,8 +293,8 @@ static const SlirpCb slirp_cb = {
#endif
.timer_free = net_slirp_timer_free,
.timer_mod = net_slirp_timer_mod,
- .register_poll_fd = net_slirp_register_poll_fd,
- .unregister_poll_fd = net_slirp_unregister_poll_fd,
+ .register_poll_socket = net_slirp_register_poll_sock,
+ .unregister_poll_socket = net_slirp_unregister_poll_sock,
.notify = net_slirp_notify,
};
@@ -314,7 +321,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 = {
@@ -363,8 +370,8 @@ static void net_slirp_poll_notify(Notifier *notifier, void
*data)
switch (poll->state) {
case MAIN_LOOP_POLL_FILL:
- slirp_pollfds_fill(s->slirp, &poll->timeout,
- net_slirp_add_poll, poll->pollfds);
+ slirp_pollfds_fill_socket(s->slirp, &poll->timeout,
+ net_slirp_add_poll, poll->pollfds);
break;
case MAIN_LOOP_POLL_OK:
case MAIN_LOOP_POLL_ERR:
@@ -629,7 +636,9 @@ static int net_slirp_init(NetClientState *peer, const char
*model,
s = DO_UPCAST(SlirpState, nc, nc);
- cfg.version = SLIRP_CHECK_VERSION(4,7,0) ? 4 : 1;
+ cfg.version =
+ SLIRP_CHECK_VERSION(4, 9, 0) ? 6 :
+ SLIRP_CHECK_VERSION(4, 7, 0) ? 4 : 1;
cfg.restricted = restricted;
cfg.in_enabled = ipv4;
cfg.vnetwork = net;
--
2.48.1
- [PULL 04/20] tests/functional: Fix the aarch64_tcg_plugins test, (continued)
- [PULL 04/20] tests/functional: Fix the aarch64_tcg_plugins test, Thomas Huth, 2025/01/30
- [PULL 05/20] tests/functional: Add a ppc64 mac99 test, Thomas Huth, 2025/01/30
- [PULL 09/20] tests/tcg/s390x: Test modifying code using the MVC instruction, Thomas Huth, 2025/01/30
- [PULL 14/20] tests/functional: Extend PPC 40p test with Linux boot, Thomas Huth, 2025/01/30
- [PULL 15/20] tests/functional: Add a decorator for skipping long running tests, Thomas Huth, 2025/01/30
- [PULL 16/20] tests/functional: Add the ReplayKernelBase class, Thomas Huth, 2025/01/30
- [PULL 11/20] virtio-balloon-pci: Allow setting nvectors, so we can use MSI-X, Thomas Huth, 2025/01/30
- [PULL 13/20] s390x/s390-virtio-ccw: Support plugging PCI-based virtio memory devices, Thomas Huth, 2025/01/30
- [PULL 17/20] tests/functional/test_mipsel_malta: Convert the mipsel replay tests, Thomas Huth, 2025/01/30
- [PULL 10/20] hw/s390x/s390-virtio-ccw: Fix a record/replay deadlock, Thomas Huth, 2025/01/30
- [PULL 20/20] net/slirp: libslirp 4.9.0 compatibility,
Thomas Huth <=
- [PULL 08/20] target/s390x: Fix MVC not always invalidating translation blocks, Thomas Huth, 2025/01/30
- [PULL 12/20] virtio-mem-pci: Allow setting nvectors, so we can use MSI-X, Thomas Huth, 2025/01/30
- [PULL 18/20] tests/functional/test_mips64el_malta: Convert the mips64el replay tests, Thomas Huth, 2025/01/30
- [PULL 19/20] tests/functional/test_mips_malta: Convert the mips big endian replay tests, Thomas Huth, 2025/01/30
- [PULL 07/20] target/s390x: Fix PPNO execution with icount, Thomas Huth, 2025/01/30