osdep: implement qemu_socketpair() for win32

Manually implement a socketpair() function, using UNIX sockets and
simple peer credential checking.

QEMU doesn't make much use of socketpair, beside vhost-user which is not
available for win32 at this point. However, I intend to use it for
writing some new portable tests.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230306122751.2355515-5-marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2023-03-06 16:27:44 +04:00
parent e387ef472f
commit 0a237f4de4
2 changed files with 110 additions and 2 deletions

View file

@ -15,7 +15,6 @@ int inet_aton(const char *cp, struct in_addr *ia);
bool fd_is_socket(int fd);
int qemu_socket(int domain, int type, int protocol);
#ifndef WIN32
/**
* qemu_socketpair:
* @domain: specifies a communication domain, such as PF_UNIX
@ -30,7 +29,6 @@ int qemu_socket(int domain, int type, int protocol);
* Return 0 on success.
*/
int qemu_socketpair(int domain, int type, int protocol, int sv[2]);
#endif
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
/*