qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/16] win32: do not mix SOCKET and fd space
@ 2023-02-21 12:47 marcandre.lureau
  2023-02-21 12:47 ` [PATCH v3 01/16] util: drop qemu_fork() marcandre.lureau
                   ` (16 more replies)
  0 siblings, 17 replies; 40+ messages in thread
From: marcandre.lureau @ 2023-02-21 12:47 UTC (permalink / raw)
  To: qemu-devel
  Cc: Samuel Thibault, Jason Wang, Paolo Bonzini, Michael Roth,
	qemu-arm, Laurent Vivier, Thomas Huth, Kevin Wolf, qemu-block,
	armbru, Peter Maydell, Stefan Hajnoczi, Daniel P. Berrangé,
	Stefan Weil, Fam Zheng, Stefan Berger, Joel Stanley, Hanna Reitz,
	Marc-André Lureau

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)

v3:
- fix closesocket() to prevent CloseHandle() from close()
- fix direct closesocket() usage (#undef closesocket before)
- add a test for &error_warn
- add r-b tags

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 (16):
  util: drop qemu_fork()
  tests: use closesocket()
  io: use closesocket()
  tests: add test-error-report
  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 +-
 tests/unit/test-error-report.c | 139 +++++++++++++++++++
 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             | 240 ++++++++++++++++++++++++++++-----
 util/qemu-sockets.c            |  22 +--
 .gitignore                     |   2 +
 subprojects/slirp.wrap         |   6 +
 tests/unit/meson.build         |   1 +
 29 files changed, 461 insertions(+), 225 deletions(-)
 create mode 100644 tests/unit/test-error-report.c
 create mode 100644 subprojects/slirp.wrap

-- 
2.39.2



^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2023-03-06 14:49 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-21 12:47 [PATCH v3 00/16] win32: do not mix SOCKET and fd space marcandre.lureau
2023-02-21 12:47 ` [PATCH v3 01/16] util: drop qemu_fork() marcandre.lureau
2023-02-21 12:47 ` [PATCH v3 02/16] tests: use closesocket() marcandre.lureau
2023-02-21 12:47 ` [PATCH v3 03/16] io: " marcandre.lureau
2023-02-21 12:47 ` [PATCH v3 04/16] tests: add test-error-report marcandre.lureau
2023-03-02 18:02   ` Stefan Berger
2023-02-21 12:47 ` [PATCH v3 05/16] error: add global &error_warn destination marcandre.lureau
2023-03-02 18:18   ` Stefan Berger
2023-02-21 12:47 ` [PATCH v3 06/16] win32/socket: introduce qemu_socket_select() helper marcandre.lureau
2023-03-02 18:23   ` Stefan Berger
2023-02-21 12:47 ` [PATCH v3 07/16] win32/socket: introduce qemu_socket_unselect() helper marcandre.lureau
2023-03-02 18:26   ` Stefan Berger
2023-02-21 12:47 ` [PATCH v3 08/16] aio: make aio_set_fd_poll() static to aio-posix.c marcandre.lureau
2023-03-02 18:29   ` Stefan Berger
2023-02-21 12:47 ` [PATCH v3 09/16] aio/win32: aio_set_fd_handler() only supports SOCKET marcandre.lureau
2023-03-02 18:37   ` Stefan Berger
2023-02-21 12:47 ` [PATCH v3 10/16] RFC: build-sys: add slirp.wrap marcandre.lureau
2023-02-21 14:14   ` Paolo Bonzini
2023-02-21 12:47 ` [PATCH v3 11/16] main-loop: remove qemu_fd_register(), win32/slirp/socket specific marcandre.lureau
2023-03-02 18:43   ` Stefan Berger
2023-02-21 12:47 ` [PATCH v3 12/16] slirp: unregister the win32 SOCKET marcandre.lureau
2023-03-02 18:45   ` Stefan Berger
2023-03-06  7:57     ` Marc-André Lureau
2023-02-21 12:47 ` [PATCH v3 13/16] slirp: open-code qemu_socket_(un)select() marcandre.lureau
2023-03-06 13:59   ` Stefan Berger
2023-03-06 14:03     ` Marc-André Lureau
2023-03-06 14:47       ` Stefan Berger
2023-03-06 14:16   ` Stefan Berger
2023-02-21 12:47 ` [PATCH v3 14/16] win32: avoid mixing SOCKET and file descriptor space marcandre.lureau
2023-03-02 20:53   ` Stefan Berger
2023-03-06  7:54     ` Marc-André Lureau
2023-03-06 14:26   ` Stefan Berger
2023-02-21 12:48 ` [PATCH v3 15/16] os-posix: remove useless ioctlsocket() define marcandre.lureau
2023-02-21 14:16   ` Paolo Bonzini
2023-02-21 12:48 ` [PATCH v3 16/16] win32: replace closesocket() with close() wrapper marcandre.lureau
2023-03-06 14:45   ` Stefan Berger
2023-03-02 14:09 ` [PATCH v3 00/16] win32: do not mix SOCKET and fd space Marc-André Lureau
2023-03-06  8:04   ` Paolo Bonzini
2023-03-06  8:08     ` Marc-André Lureau
2023-03-06 10:02       ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).