util/qemu-sockets: Enable unix socket support on Windows

Support for the unix socket has existed both in BSD and Linux for the
longest time, but not on Windows. Since Windows 10 build 17063 [1],
the native support for the unix socket has come to Windows. Starting
this build, two Win32 processes can use the AF_UNIX address family
over Winsock API to communicate with each other.

[1] https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/

Signed-off-by: Xuzhou Cheng <xuzhou.cheng@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220802075200.907360-3-bmeng.cn@gmail.com>
This commit is contained in:
Bin Meng 2022-08-02 15:51:58 +08:00 committed by Marc-André Lureau
parent 93fac696d2
commit d409373b9d
3 changed files with 20 additions and 25 deletions

View file

@ -30,6 +30,23 @@
#include <windows.h>
#include <ws2tcpip.h>
#ifdef HAVE_AFUNIX_H
#include <afunix.h>
#else
/*
* Fallback definitions of things we need in afunix.h, if not available from
* the used Windows SDK or MinGW headers.
*/
#define UNIX_PATH_MAX 108
typedef struct sockaddr_un {
ADDRESS_FAMILY sun_family;
char sun_path[UNIX_PATH_MAX];
} SOCKADDR_UN, *PSOCKADDR_UN;
#define SIO_AF_UNIX_GETPEERPID _WSAIOR(IOC_VENDOR, 256)
#endif
#ifdef __cplusplus
extern "C" {
#endif