[PATCH 0/4] win32: do not mix SOCKET and fd space

marcandre.lureau@redhat.com posted 4 patches 1 year, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230212204942.1905959-1-marcandre.lureau@redhat.com
Maintainers: Stefan Berger <stefanb@linux.vnet.ibm.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>, Jason Wang <jasowang@redhat.com>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Joel Stanley <joel@jms.id.au>, Peter Maydell <peter.maydell@linaro.org>
There is a newer version of this series
include/sysemu/os-posix.h   |   1 -
include/sysemu/os-win32.h   |   8 +-
backends/tpm/tpm_emulator.c |   6 +-
crypto/afalg.c              |   6 +-
hw/hyperv/syndbg.c          |   4 +-
io/channel-socket.c         |  22 +++--
io/channel-watch.c          |  17 ++--
net/dgram.c                 |  14 +--
net/socket.c                |  22 ++---
tests/qtest/libqtest.c      |   8 +-
tests/qtest/microbit-test.c |   2 +-
tests/qtest/netdev-socket.c |  10 +--
tests/unit/socket-helpers.c |   2 +-
util/oslib-win32.c          | 169 ++++++++++++++++++++++++++++++------
util/qemu-sockets.c         |  22 ++---
15 files changed, 221 insertions(+), 92 deletions(-)
[PATCH 0/4] win32: do not mix SOCKET and fd space
Posted by marcandre.lureau@redhat.com 1 year, 2 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Hi,

A win32 SOCKET handle is often cast to an int file descriptor, as this is what
other OS use for sockets. When necessary, QEMU eventually queries whether it's a
socket with the help of fd_is_socket(). However, there is no guarantee of
conflict between the fd and SOCKET space. Such conflict would have surprising
consequences. We can fix this by using FDs only.

After fixing a few missed closesocket(), this patch series makes the win32
socket API wrappers take FDs. It finally get rid of closesocket() usage by using
a close() wrapper instead. (note that fdopen/fclose would not be enough either
to close the underlying socket appropriately)

Marc-André Lureau (4):
  tests: use closesocket()
  io: use closesocket()
  win32: stop mixing SOCKET and file descriptor space
  win32: replace closesocket() with close() wrapper

 include/sysemu/os-posix.h   |   1 -
 include/sysemu/os-win32.h   |   8 +-
 backends/tpm/tpm_emulator.c |   6 +-
 crypto/afalg.c              |   6 +-
 hw/hyperv/syndbg.c          |   4 +-
 io/channel-socket.c         |  22 +++--
 io/channel-watch.c          |  17 ++--
 net/dgram.c                 |  14 +--
 net/socket.c                |  22 ++---
 tests/qtest/libqtest.c      |   8 +-
 tests/qtest/microbit-test.c |   2 +-
 tests/qtest/netdev-socket.c |  10 +--
 tests/unit/socket-helpers.c |   2 +-
 util/oslib-win32.c          | 169 ++++++++++++++++++++++++++++++------
 util/qemu-sockets.c         |  22 ++---
 15 files changed, 221 insertions(+), 92 deletions(-)

-- 
2.39.1