There are a large number of different header files that
are related to the sockets APIs. The virsocket.h header
includes all of the relevant headers for Windows and UNIX
in one convenient place. If virsocketaddr.h is already
included, then there's no need for virsocket.h
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
configure.ac | 8 +++++---
src/conf/network_conf.c | 2 --
src/esx/esx_util.c | 3 +--
src/esx/esx_util.h | 1 -
src/libxl/libxl_conf.c | 2 --
src/lxc/lxc_controller.c | 4 +---
src/lxc/lxc_driver.c | 4 +---
src/nwfilter/nwfilter_dhcpsnoop.c | 3 ---
src/nwfilter/nwfilter_learnipaddr.c | 4 +---
src/qemu/qemu_agent.c | 4 +---
src/qemu/qemu_conf.c | 3 +--
src/qemu/qemu_driver.c | 3 +--
src/qemu/qemu_migration.c | 3 +--
src/qemu/qemu_monitor.c | 3 +--
src/qemu/qemu_monitor_json.c | 4 +---
src/remote/qemu_protocol.x | 1 -
src/remote/remote_protocol.x | 2 +-
src/rpc/virnetprotocol.x | 2 +-
src/rpc/virnetsocket.c | 14 ++++----------
src/util/virarptable.c | 1 -
src/util/virfdstream.c | 8 ++------
src/util/virfile.c | 3 +--
src/util/virlog.c | 6 +-----
src/util/virnetdevbridge.c | 6 +-----
src/util/virnetdevmacvlan.c | 3 +--
src/util/virnetdevvportprofile.c | 3 +--
src/util/virnetlink.c | 3 +--
src/util/virsocket.h | 3 ++-
src/util/virsocketaddr.c | 2 --
src/util/virsocketaddr.h | 10 ++--------
src/util/virsystemd.c | 9 ++-------
src/util/virutil.c | 13 -------------
src/vbox/vbox_MSCOMGlue.c | 6 +-----
tests/libxlmock.c | 2 +-
tests/nsstest.c | 3 +--
tests/virnetsockettest.c | 1 -
tests/virnettlscontexttest.c | 3 +--
tests/virnettlshelpers.c | 1 -
tests/virnettlssessiontest.c | 3 +--
tests/virportallocatormock.c | 5 +----
tests/virtestmock.c | 9 ++-------
41 files changed, 43 insertions(+), 130 deletions(-)
diff --git a/configure.ac b/configure.ac
index adfd950260..b1f75fa751 100644
--- a/configure.ac
+++ b/configure.ac
@@ -231,9 +231,13 @@ AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" =
"yes"])
AM_CONDITIONAL([WITH_FREEBSD], [test "$with_freebsd" = "yes"])
AM_CONDITIONAL([WITH_MACOS], [test "$with_macos" = "yes"])
-# We don't support the daemon yet
if test "$with_win" = "yes" ; then
+ # We don't support the daemon yet
with_libvirtd=no
+
+ # For AI_ADDRCONFIG
+ AC_DEFINE([_WIN32_WINNT], [0x0600], [Win Vista / Server 2008])
+ AC_DEFINE([WINVER], [0x0600], [Win Vista / Server 2008])
fi
# The daemon requires remote support. Likewise, if we are not using
@@ -382,7 +386,6 @@ AC_CHECK_HEADERS([\
linux/magic.h \
mntent.h \
net/ethernet.h \
- netinet/tcp.h \
net/if.h \
pty.h \
pwd.h \
@@ -393,7 +396,6 @@ AC_CHECK_HEADERS([\
sys/syscall.h \
sys/sysctl.h \
sys/ucred.h \
- sys/un.h \
])
dnl Check whether endian provides handy macros.
AC_CHECK_DECLS([htole64], [], [], [[#include <endian.h>]])
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 27e83b7d85..1f14a964a2 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -22,8 +22,6 @@
#include <config.h>
#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index c265528056..89d136248f 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -23,8 +23,6 @@
#include <config.h>
-#include <netdb.h>
-
#include "internal.h"
#include "datatypes.h"
#include "viralloc.h"
@@ -34,6 +32,7 @@
#include "esx_private.h"
#include "esx_util.h"
#include "virstring.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_ESX
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index d80093dcb5..97b6d82a2b 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -21,7 +21,6 @@
#pragma once
-#include <netdb.h>
#include "internal.h"
#include "viruri.h"
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index e41e84e3e2..b4462a6291 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -24,7 +24,6 @@
#include <libxl.h>
#include <sys/types.h>
-#include <sys/socket.h>
#include "internal.h"
#include "virlog.h"
@@ -48,7 +47,6 @@
#include "virnetdevvportprofile.h"
#include "virenum.h"
-
#define VIR_FROM_THIS VIR_FROM_LIBXL
VIR_LOG_INIT("libxl.libxl_conf");
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 42c631ed0b..558a964fca 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -23,7 +23,6 @@
#include <sys/epoll.h>
#include <sys/wait.h>
-#include <sys/socket.h>
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
@@ -31,8 +30,6 @@
# include <sys/sysmacros.h>
#endif
-#include <sys/types.h>
-#include <sys/un.h>
#include <sys/personality.h>
#include <unistd.h>
#include <fcntl.h>
@@ -69,6 +66,7 @@
#include "rpc/virnetdaemon.h"
#include "virstring.h"
#include "virgettext.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_LXC
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index bf1f8f8190..931730eabc 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -31,10 +31,7 @@
# include <sys/sysmacros.h>
#endif
-#include <sys/types.h>
-#include <sys/socket.h>
#include <sys/stat.h>
-#include <sys/un.h>
#include <sys/poll.h>
#include <unistd.h>
#include <wait.h>
@@ -75,6 +72,7 @@
#include "viraccessapichecklxc.h"
#include "virhostdev.h"
#include "netdev_bandwidth_conf.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_LXC
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 629f974177..10567e9cd3 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -43,9 +43,6 @@
#include <fcntl.h>
#include <poll.h>
-#include <arpa/inet.h>
-#include <netinet/ip.h>
-#include <netinet/udp.h>
#include <net/if.h>
#include "viralloc.h"
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 5791724cf4..f2d5e60d43 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -31,10 +31,7 @@
#include <sys/ioctl.h>
#include <poll.h>
-#include <arpa/inet.h>
#include <net/ethernet.h>
-#include <netinet/ip.h>
-#include <netinet/udp.h>
#include <net/if_arp.h>
#include "internal.h"
@@ -53,6 +50,7 @@
#include "nwfilter_ipaddrmap.h"
#include "nwfilter_learnipaddr.h"
#include "virstring.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index b6556ffbaf..4374235d34 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -21,9 +21,6 @@
#include <config.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
#include <poll.h>
#include <unistd.h>
#include <fcntl.h>
@@ -41,6 +38,7 @@
#include "virobject.h"
#include "virstring.h"
#include "virenum.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b62dd1df52..8bc323345a 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -26,7 +26,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
-#include <arpa/inet.h>
#include "virerror.h"
#include "qemu_conf.h"
@@ -44,7 +43,7 @@
#include "cpu/cpu.h"
#include "domain_nwfilter.h"
#include "virfile.h"
-#include "virsocketaddr.h"
+#include "virsocket.h"
#include "virstring.h"
#include "viratomic.h"
#include "storage_conf.h"
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2f66d7cd9a..d7b2528c80 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -32,8 +32,6 @@
#include <signal.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
-#include <sys/un.h>
-
#include "qemu_driver.h"
#include "qemu_agent.h"
@@ -104,6 +102,7 @@
#include "virdomainsnapshotobjlist.h"
#include "virenum.h"
#include "virdomaincheckpointobjlist.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 29d228a8d9..5a7586fab9 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -21,8 +21,6 @@
#include <config.h>
-#include <netdb.h>
-#include <sys/socket.h>
#include <sys/time.h>
#include <fcntl.h>
#include <poll.h>
@@ -62,6 +60,7 @@
#include "virprocess.h"
#include "nwfilter_conf.h"
#include "virdomainsnapshotobjlist.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index ccd20b3740..421dd9554f 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -22,8 +22,6 @@
#include <config.h>
#include <poll.h>
-#include <sys/socket.h>
-#include <sys/un.h>
#include <unistd.h>
#include <fcntl.h>
@@ -41,6 +39,7 @@
#include "virprobe.h"
#include "virstring.h"
#include "virtime.h"
+#include "virsocket.h"
#ifdef WITH_DTRACE_PROBES
# include "libvirt_qemu_probes.h"
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e5164d218a..b74633441f 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -21,9 +21,6 @@
#include <config.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
#include <poll.h>
#include <unistd.h>
#include <sys/time.h>
@@ -41,6 +38,7 @@
#include "virstring.h"
#include "cpu/cpu_x86.h"
#include "virenum.h"
+#include "virsocket.h"
#ifdef WITH_DTRACE_PROBES
# include "libvirt_qemu_probes.h"
diff --git a/src/remote/qemu_protocol.x b/src/remote/qemu_protocol.x
index 423e8fadaf..8ff5dc8568 100644
--- a/src/remote/qemu_protocol.x
+++ b/src/remote/qemu_protocol.x
@@ -22,7 +22,6 @@
%#include "internal.h"
%#include "remote_protocol.h"
-%#include <arpa/inet.h>
/*----- Protocol. -----*/
struct qemu_domain_monitor_command_args {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 79cdb13a90..1f7963510a 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -37,7 +37,7 @@
%#include <libvirt/libvirt.h>
%#include "internal.h"
%#include "virxdrdefs.h"
-%#include <arpa/inet.h>
+%#include "virsocket.h"
/*----- Data types. -----*/
diff --git a/src/rpc/virnetprotocol.x b/src/rpc/virnetprotocol.x
index 99f4f2e539..2d9b23ca18 100644
--- a/src/rpc/virnetprotocol.x
+++ b/src/rpc/virnetprotocol.x
@@ -20,7 +20,7 @@
%#include "internal.h"
%#include "virxdrdefs.h"
-%#include <arpa/inet.h>
+%#include "virsocket.h"
/*----- Data types. -----*/
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 906b5165eb..8f3833e2ff 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -22,7 +22,6 @@
#include <config.h>
#include <sys/stat.h>
-#include <sys/socket.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
@@ -30,11 +29,6 @@
#ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
#endif
-#include <netdb.h>
-
-#ifdef HAVE_NETINET_TCP_H
-# include <netinet/tcp.h>
-#endif
#ifdef HAVE_SYS_UCRED_H
# include <sys/ucred.h>
@@ -461,7 +455,7 @@ int virNetSocketNewListenTCP(const char *nodename,
}
-#if HAVE_SYS_UN_H
+#ifndef WIN32
int virNetSocketNewListenUNIX(const char *path,
mode_t mask,
uid_t user,
@@ -647,7 +641,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
}
-#ifdef HAVE_SYS_UN_H
+#ifndef WIN32
int virNetSocketNewConnectUNIX(const char *path,
bool spawnDaemon,
const char *binary,
@@ -1349,7 +1343,7 @@ void virNetSocketDispose(void *obj)
sock->watch = -1;
}
-#ifdef HAVE_SYS_UN_H
+#ifndef WIN32
/* If a server socket, then unlink UNIX path */
if (sock->unlinkUNIX &&
sock->localAddr.data.sa.sa_family == AF_UNIX &&
@@ -2289,7 +2283,7 @@ void virNetSocketClose(virNetSocketPtr sock)
sock->fd = -1;
}
-#ifdef HAVE_SYS_UN_H
+#ifndef WIN32
/* If a server socket, then unlink UNIX path */
if (sock->unlinkUNIX &&
sock->localAddr.data.sa.sa_family == AF_UNIX &&
diff --git a/src/util/virarptable.c b/src/util/virarptable.c
index 265f60d645..c4b46604a9 100644
--- a/src/util/virarptable.c
+++ b/src/util/virarptable.c
@@ -20,7 +20,6 @@
#include <config.h>
-#include <arpa/inet.h>
#ifdef __linux__
# include <linux/rtnetlink.h>
#endif
diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c
index 58b77aa6fa..c094876dee 100644
--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -25,12 +25,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include <sys/socket.h>
#include <sys/wait.h>
-#if HAVE_SYS_UN_H
-# include <sys/un.h>
-#endif
-#include <netinet/in.h>
#ifndef WIN32
# include <termios.h>
#endif
@@ -46,6 +41,7 @@
#include "virstring.h"
#include "virtime.h"
#include "virprocess.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_STREAMS
@@ -1163,7 +1159,7 @@ int virFDStreamOpen(virStreamPtr st,
}
-#if HAVE_SYS_UN_H
+#ifndef WIN32
int virFDStreamConnectUNIX(virStreamPtr st,
const char *path,
bool abstract)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index d08eae5a1d..0b51040638 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -42,8 +42,6 @@
# include <libutil.h>
#endif /* !HAVE_LIBUTIL_H */
#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/socket.h>
#include <sys/wait.h>
#if defined(HAVE_SYS_MOUNT_H)
# include <sys/mount.h>
@@ -90,6 +88,7 @@
#include "virprocess.h"
#include "virstring.h"
#include "virutil.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 8c17d666de..e4944d1258 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -24,17 +24,12 @@
#include <stdarg.h>
#include <time.h>
#include <sys/time.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#if HAVE_SYSLOG_H
# include <syslog.h>
#endif
-#include <sys/socket.h>
-#if HAVE_SYS_UN_H
-# include <sys/un.h>
-#endif
#include "virerror.h"
#include "virlog.h"
@@ -46,6 +41,7 @@
#include "virtime.h"
#include "virstring.h"
#include "configmake.h"
+#include "virsocket.h"
/* Journald output is only supported on Linux new enough to expose
* htole64. */
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index 5a0fb5f42f..769289ae0b 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -26,15 +26,11 @@
#include "viralloc.h"
#include "virlog.h"
#include "virstring.h"
+#include "virsocket.h"
-#ifndef WIN32
-# include <sys/ioctl.h>
-#endif
-#include <sys/socket.h>
#ifdef HAVE_NET_IF
# include <net/if.h>
#endif
-#include <netinet/in.h>
#ifdef __linux__
# if defined(HAVE_LIBNL)
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 3ca568fb44..dcea93a5fe 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -42,8 +42,6 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode,
#if WITH_MACVTAP
# include <fcntl.h>
-# include <sys/socket.h>
-# include <sys/ioctl.h>
# include <net/if.h>
# include <linux/if_tun.h>
@@ -61,6 +59,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode,
# include "virnetdev.h"
# include "virpidfile.h"
# include "virbitmap.h"
+# include "virsocket.h"
VIR_LOG_INIT("util.netdevmacvlan");
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index 5ca96132c4..475a0d9cbc 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -49,8 +49,6 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp,
#if WITH_VIRTUALPORT
# include <fcntl.h>
-# include <sys/socket.h>
-# include <sys/ioctl.h>
# include <net/if.h>
# include <linux/if_tun.h>
@@ -59,6 +57,7 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp,
# include "virfile.h"
# include "virlog.h"
# include "virnetdev.h"
+# include "virsocket.h"
VIR_LOG_INIT("util.netdevvportprofile");
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 710b4f5f51..2ce3d0fae9 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -24,8 +24,6 @@
#include <config.h>
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
#include "virnetlink.h"
#include "virnetdev.h"
@@ -34,6 +32,7 @@
#include "virmacaddr.h"
#include "virerror.h"
#include "viralloc.h"
+#include "virsocket.h"
#define VIR_FROM_THIS VIR_FROM_NET
diff --git a/src/util/virsocket.h b/src/util/virsocket.h
index e1e7d08bb4..6d323e0a12 100644
--- a/src/util/virsocket.h
+++ b/src/util/virsocket.h
@@ -79,13 +79,14 @@ int vir_socket(int domain, int type, int protocol);
#else
# include <sys/socket.h>
-# include <unistd.h>
# include <sys/ioctl.h>
# include <arpa/inet.h>
+# include <netinet/ip.h>
# include <netinet/in.h>
# include <netinet/udp.h>
# include <netinet/tcp.h>
# include <sys/un.h>
+# include <netdb.h>
# define closesocket close
# define ioctlsocket ioctl
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index f90022827e..4cad329d15 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -24,8 +24,6 @@
#include "virbuffer.h"
#include "viralloc.h"
-#include <netdb.h>
-
#define VIR_FROM_THIS VIR_FROM_NONE
/*
diff --git a/src/util/virsocketaddr.h b/src/util/virsocketaddr.h
index 66aee2abcd..d06e751f73 100644
--- a/src/util/virsocketaddr.h
+++ b/src/util/virsocketaddr.h
@@ -18,13 +18,7 @@
#pragma once
-#include <netinet/in.h>
-#include <sys/socket.h>
-#ifdef HAVE_SYS_UN_H
-# include <sys/un.h>
-#endif
-
-#include "internal.h"
+#include "virsocket.h"
#define VIR_LOOPBACK_IPV4_ADDR "127.0.0.1"
@@ -34,7 +28,7 @@ typedef struct {
struct sockaddr_storage stor;
struct sockaddr_in inet4;
struct sockaddr_in6 inet6;
-#ifdef HAVE_SYS_UN_H
+#ifndef WIN32
struct sockaddr_un un;
#endif
} data;
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 96d43e5440..a9ff782fb8 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -21,11 +21,6 @@
#include <config.h>
-#include <sys/socket.h>
-#ifdef HAVE_SYS_UN_H
-# include <sys/un.h>
-#endif
-
#define LIBVIRT_VIRSYSTEMDPRIV_H_ALLOW
#include "virsystemdpriv.h"
@@ -515,7 +510,7 @@ int virSystemdTerminateMachine(const char *name)
void
virSystemdNotifyStartup(void)
{
-#ifdef HAVE_SYS_UN_H
+#ifndef WIN32
const char *path;
const char *msg = "READY=1";
int fd;
@@ -559,7 +554,7 @@ virSystemdNotifyStartup(void)
VIR_WARN("Failed to notify systemd");
VIR_FORCE_CLOSE(fd);
-#endif /* HAVE_SYS_UN_H */
+#endif /* !WIN32 */
}
static int
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 4bc0aef35f..ad05ef5fc1 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -44,7 +44,6 @@
# include <libdevmapper.h>
#endif
-#include <netdb.h>
#ifdef HAVE_GETPWUID_R
# include <pwd.h>
# include <grp.h>
@@ -54,18 +53,6 @@
# include <sys/prctl.h>
#endif
-#ifdef WIN32
-# ifdef HAVE_WINSOCK2_H
-# include <winsock2.h>
-# endif
-# include <windows.h>
-# include <shlobj.h>
-#endif
-
-#ifdef HAVE_SYS_UN_H
-# include <sys/un.h>
-#endif
-
#include "virerror.h"
#include "virlog.h"
#include "virbuffer.h"
diff --git a/src/vbox/vbox_MSCOMGlue.c b/src/vbox/vbox_MSCOMGlue.c
index 5cc3f5c7c8..18dbb0ffe1 100644
--- a/src/vbox/vbox_MSCOMGlue.c
+++ b/src/vbox/vbox_MSCOMGlue.c
@@ -22,11 +22,6 @@
#include <config.h>
-#ifdef HAVE_WINSOCK2_H
-# include <winsock2.h>
-#endif
-#include <windows.h>
-
#define nsCID CLSID
#include "internal.h"
@@ -35,6 +30,7 @@
#include "virerror.h"
#include "virstring.h"
#include "virutil.h"
+#include "virsocket.h"
#include "vbox_MSCOMGlue.h"
#define VIR_FROM_THIS VIR_FROM_VBOX
diff --git a/tests/libxlmock.c b/tests/libxlmock.c
index 38302b2ae8..b995b34cc5 100644
--- a/tests/libxlmock.c
+++ b/tests/libxlmock.c
@@ -27,9 +27,9 @@
# include <libxl.h>
# include <xenstore.h>
# include <xenctrl.h>
-# include <sys/socket.h>
# include "virfile.h"
+# include "virsocket.h"
VIR_MOCK_IMPL_RET_VOID(xs_daemon_open,
struct xs_handle *)
diff --git a/tests/nsstest.c b/tests/nsstest.c
index d146100747..514b4f7195 100644
--- a/tests/nsstest.c
+++ b/tests/nsstest.c
@@ -22,9 +22,8 @@
#ifdef NSS
-# include <arpa/inet.h>
# include "libvirt_nss.h"
-# include "virsocketaddr.h"
+# include "virsocket.h"
# define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 42a3971d41..af11a0f6e8 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -22,7 +22,6 @@
#ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
#endif
-#include <netdb.h>
#include "testutils.h"
#include "virutil.h"
diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
index 8013f9eda8..328b1340d6 100644
--- a/tests/virnettlscontexttest.c
+++ b/tests/virnettlscontexttest.c
@@ -19,7 +19,6 @@
#include <config.h>
#include <fcntl.h>
-#include <sys/socket.h>
#include "testutils.h"
#include "virnettlshelpers.h"
@@ -29,7 +28,7 @@
#include "virlog.h"
#include "virfile.h"
#include "vircommand.h"
-#include "virsocketaddr.h"
+#include "virsocket.h"
#if !defined WIN32 && HAVE_LIBTASN1_H && LIBGNUTLS_VERSION_NUMBER >=
0x020600
diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c
index a6aacf4cc3..5aaf98e345 100644
--- a/tests/virnettlshelpers.c
+++ b/tests/virnettlshelpers.c
@@ -19,7 +19,6 @@
#include <config.h>
#include <fcntl.h>
-#include <sys/socket.h>
#include "virnettlshelpers.h"
#include "viralloc.h"
diff --git a/tests/virnettlssessiontest.c b/tests/virnettlssessiontest.c
index 4f1b2aa8d2..6807581d70 100644
--- a/tests/virnettlssessiontest.c
+++ b/tests/virnettlssessiontest.c
@@ -19,7 +19,6 @@
#include <config.h>
#include <fcntl.h>
-#include <sys/socket.h>
#include "testutils.h"
#include "virnettlshelpers.h"
@@ -29,7 +28,7 @@
#include "virlog.h"
#include "virfile.h"
#include "vircommand.h"
-#include "virsocketaddr.h"
+#include "virsocket.h"
#if !defined WIN32 && HAVE_LIBTASN1_H && LIBGNUTLS_VERSION_NUMBER >=
0x020600
diff --git a/tests/virportallocatormock.c b/tests/virportallocatormock.c
index e715f34e04..28fe89200e 100644
--- a/tests/virportallocatormock.c
+++ b/tests/virportallocatormock.c
@@ -23,10 +23,7 @@
#endif
#if defined(__linux__) && defined(RTLD_NEXT)
-# include "internal.h"
-# include <sys/socket.h>
-# include <arpa/inet.h>
-# include <netinet/in.h>
+# include "virsocket.h"
# include <unistd.h>
static bool host_has_ipv6;
diff --git a/tests/virtestmock.c b/tests/virtestmock.c
index 046898dbe1..e5dccae2a8 100644
--- a/tests/virtestmock.c
+++ b/tests/virtestmock.c
@@ -20,16 +20,11 @@
#include "virmock.h"
#include <unistd.h>
-#include <sys/types.h>
#include <fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
-#include <sys/socket.h>
-#ifdef HAVE_SYS_UN_H
-# include <sys/un.h>
-#endif
-#include "internal.h"
+#include "virsocket.h"
#include "configmake.h"
#include "virstring.h"
#include "viralloc.h"
@@ -202,7 +197,7 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t
addrlen)
{
init_syms();
-#ifdef HAVE_SYS_UN_H
+#ifndef WIN32
if (addrlen == sizeof(struct sockaddr_un)) {
struct sockaddr_un *tmp = (struct sockaddr_un *) addr;
if (tmp->sun_family == AF_UNIX)
--
2.24.1