This is the case on MacOS for example. The issue is that AF_VSOCK is defined in
sys/socket.h, but struct sockaddr_vm is not, so the safeguard lower in the file
does not work. Thankfully sys/vsock.h has the sockaddr_vm definition, so
including that fixes the build issue.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
configure.ac | 2 +-
lib/connect.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 0dce57a3f502..065ede6342b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,7 +96,7 @@ AC_CHECK_HEADERS([\
stdatomic.h \
sys/endian.h])
-AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [#include <sys/socket.h>])
+AC_CHECK_HEADERS([linux/vm_sockets.h sys/vsock.h], [], [], [#include
<sys/socket.h>])
dnl posix_fadvise helps to optimise linear reads and writes (optional).
AC_CHECK_FUNCS([posix_fadvise])
diff --git a/lib/connect.c b/lib/connect.c
index 99781cd20dae..500806303404 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -33,6 +33,8 @@
#ifdef HAVE_LINUX_VM_SOCKETS_H
#include <linux/vm_sockets.h>
+#elif HAVE_SYS_VSOCK_H
+#include <sys/vsock.h>
#endif
#include "internal.h"
--
2.32.0