util/oslib-win32: Do not treat null @errp as &error_warn

qemu_socket_select() and its wrapper qemu_socket_unselect() treat a
null @errp as &error_warn.  This is wildly inappropriate.  A caller
passing null @errp specifies that errors are to be ignored.  If
warnings are wanted, the caller must pass &error_warn.

Change callers to do that, and drop the inappropriate treatment of
null @errp.

This assumes that warnings are wanted.  I'm not familiar with the
calling code, so I can't say whether it will work when the socket is
invalid, or WSAEventSelect() fails.  If it doesn't, then this should
be an error instead of a warning.  Invalid socket might even be a
programming error.

These warnings were introduced in commit f5fd677ae7 (win32/socket:
introduce qemu_socket_select() helper).  I considered reverting to
silence, but Daniel Berrangé asked for the warnings to be preserved.

Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250923091000.3180122-9-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
This commit is contained in:
Markus Armbruster 2025-09-23 11:09:55 +02:00
parent b46b8cf29c
commit 5bd58f04b8
4 changed files with 5 additions and 9 deletions

View file

@ -454,7 +454,7 @@ static void qio_channel_socket_finalize(Object *obj)
}
}
#ifdef WIN32
qemu_socket_unselect(ioc->fd, NULL);
qemu_socket_unselect(ioc->fd, &error_warn);
#endif
close(ioc->fd);
ioc->fd = -1;
@ -929,7 +929,7 @@ qio_channel_socket_close(QIOChannel *ioc,
if (sioc->fd != -1) {
#ifdef WIN32
qemu_socket_unselect(sioc->fd, NULL);
qemu_socket_unselect(sioc->fd, &error_warn);
#endif
if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN)) {
socket_listen_cleanup(sioc->fd, errp);

View file

@ -283,7 +283,7 @@ GSource *qio_channel_create_socket_watch(QIOChannel *ioc,
qemu_socket_select(sockfd, ioc->event,
FD_READ | FD_ACCEPT | FD_CLOSE |
FD_CONNECT | FD_WRITE | FD_OOB, NULL);
FD_CONNECT | FD_WRITE | FD_OOB, &error_warn);
source = g_source_new(&qio_channel_socket_source_funcs,
sizeof(QIOChannelSocketSource));