net/slirp: Clean up error reporting

net_slirp_register_poll_sock() and net_slirp_unregister_poll_sock()
report WSAEventSelect() failure with error_setg(&error_warn, ...).
error_setg_win32(&error_warn, ...) is undesirable just like
error_setg(&error_fatal, ...) and error_setg(&error_abort, ...)  are.
Replace by warn_report().

The failures should probably be errors, but these functions implement
callbacks that cannot fail, exit(1) would be too harsh, and silent
failure we don't want.  Thus, warnings.

Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20250923091000.3180122-7-armbru@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
This commit is contained in:
Markus Armbruster 2025-09-23 11:09:53 +02:00
parent 789f1adefb
commit 3cacecb9f8

View file

@ -258,11 +258,13 @@ static void net_slirp_register_poll_sock(slirp_os_socket fd, void *opaque)
{
#ifdef WIN32
AioContext *ctxt = qemu_get_aio_context();
g_autofree char *msg = NULL;
if (WSAEventSelect(fd, event_notifier_get_handle(&ctxt->notifier),
FD_READ | FD_ACCEPT | FD_CLOSE |
FD_CONNECT | FD_WRITE | FD_OOB) != 0) {
error_setg_win32(&error_warn, WSAGetLastError(), "failed to WSAEventSelect()");
msg = g_win32_error_message(WSAGetLastError());
warn_report("failed to WSAEventSelect(): %s", msg);
}
#endif
}
@ -270,8 +272,11 @@ static void net_slirp_register_poll_sock(slirp_os_socket fd, void *opaque)
static void net_slirp_unregister_poll_sock(slirp_os_socket fd, void *opaque)
{
#ifdef WIN32
g_autofree char *msg = NULL;
if (WSAEventSelect(fd, NULL, 0) != 0) {
error_setg_win32(&error_warn, WSAGetLastError(), "failed to WSAEventSelect()");
msg = g_win32_error_message(WSAGetLastError());
warn_report("failed to WSAEventSelect(): %s", msg);
}
#endif
}