[PATCH v2 00/15] win32: do not mix SOCKET and fd space

marcandre.lureau@redhat.com posted 15 patches 1 year, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230220214859.3792171-1-marcandre.lureau@redhat.com
Maintainers: Stefan Berger <stefanb@linux.vnet.ibm.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>, Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>, Jason Wang <jasowang@redhat.com>, Samuel Thibault <samuel.thibault@ens-lyon.org>, 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/block/aio.h         |   8 --
include/qapi/error.h        |   6 ++
include/qemu/main-loop.h    |   2 -
include/qemu/osdep.h        |  14 ---
include/sysemu/os-posix.h   |   3 -
include/sysemu/os-win32.h   |  15 ++-
backends/tpm/tpm_emulator.c |   6 +-
crypto/afalg.c              |   6 +-
hw/hyperv/syndbg.c          |   4 +-
io/channel-socket.c         |   8 +-
io/channel-watch.c          |  10 +-
net/dgram.c                 |  14 +--
net/slirp.c                 |  16 ++-
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/aio-posix.c            |   6 +-
util/aio-win32.c            |  23 ++--
util/error.c                |  10 +-
util/main-loop.c            |  11 --
util/oslib-posix.c          |  70 -------------
util/oslib-win32.c          | 202 ++++++++++++++++++++++++++++++------
util/qemu-sockets.c         |  22 ++--
.gitignore                  |   2 +
subprojects/slirp.wrap      |   6 ++
27 files changed, 289 insertions(+), 219 deletions(-)
create mode 100644 subprojects/slirp.wrap
[PATCH v2 00/15] 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)

v2:
- add clean up patch "util: drop qemu_fork()"
- add a "&error_warn", to help with basic error reporting
- fix errno handling after _get_osfhandle()
- introduce qemu_socket_(un)select() helpers
- add patch "aio_set_fd_handler() only supports SOCKET"
- add meson slirp.wrap RFC
- various misc cleanups
- add r-b tags

Marc-André Lureau (15):
  util: drop qemu_fork()
  tests: use closesocket()
  io: use closesocket()
  error: add global &error_warn destination
  win32/socket: introduce qemu_socket_select() helper
  win32/socket: introduce qemu_socket_unselect() helper
  aio: make aio_set_fd_poll() static to aio-posix.c
  aio/win32: aio_set_fd_handler() only supports SOCKET
  RFC: build-sys: add slirp.wrap
  main-loop: remove qemu_fd_register(), win32/slirp/socket specific
  slirp: unregister the win32 SOCKET
  slirp: open-code qemu_socket_(un)select()
  win32: avoid mixing SOCKET and file descriptor space
  os-posix: remove useless ioctlsocket() define
  win32: replace closesocket() with close() wrapper

 include/block/aio.h         |   8 --
 include/qapi/error.h        |   6 ++
 include/qemu/main-loop.h    |   2 -
 include/qemu/osdep.h        |  14 ---
 include/sysemu/os-posix.h   |   3 -
 include/sysemu/os-win32.h   |  15 ++-
 backends/tpm/tpm_emulator.c |   6 +-
 crypto/afalg.c              |   6 +-
 hw/hyperv/syndbg.c          |   4 +-
 io/channel-socket.c         |   8 +-
 io/channel-watch.c          |  10 +-
 net/dgram.c                 |  14 +--
 net/slirp.c                 |  16 ++-
 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/aio-posix.c            |   6 +-
 util/aio-win32.c            |  23 ++--
 util/error.c                |  10 +-
 util/main-loop.c            |  11 --
 util/oslib-posix.c          |  70 -------------
 util/oslib-win32.c          | 202 ++++++++++++++++++++++++++++++------
 util/qemu-sockets.c         |  22 ++--
 .gitignore                  |   2 +
 subprojects/slirp.wrap      |   6 ++
 27 files changed, 289 insertions(+), 219 deletions(-)
 create mode 100644 subprojects/slirp.wrap

-- 
2.39.1