提交 fc920f70 编写于 作者: D Daniel P. Berrangé

src: convert all code to use virsocket.h

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
Reviewed-by: NPavel Hrdina <phrdina@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 a4642204
......@@ -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>]])
......
......@@ -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>
......
......@@ -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
......
......@@ -21,7 +21,6 @@
#pragma once
#include <netdb.h>
#include "internal.h"
#include "viruri.h"
......
......@@ -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");
......
......@@ -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
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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
......
......@@ -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"
......
......@@ -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"
......
......@@ -22,7 +22,6 @@
%#include "internal.h"
%#include "remote_protocol.h"
%#include <arpa/inet.h>
/*----- Protocol. -----*/
struct qemu_domain_monitor_command_args {
......
......@@ -37,7 +37,7 @@
%#include <libvirt/libvirt.h>
%#include "internal.h"
%#include "virxdrdefs.h"
%#include <arpa/inet.h>
%#include "virsocket.h"
/*----- Data types. -----*/
......
......@@ -20,7 +20,7 @@
%#include "internal.h"
%#include "virxdrdefs.h"
%#include <arpa/inet.h>
%#include "virsocket.h"
/*----- Data types. -----*/
......
......@@ -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>
......@@ -459,7 +453,7 @@ int virNetSocketNewListenTCP(const char *nodename,
}
#if HAVE_SYS_UN_H
#ifndef WIN32
int virNetSocketNewListenUNIX(const char *path,
mode_t mask,
uid_t user,
......@@ -645,7 +639,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
}
#ifdef HAVE_SYS_UN_H
#ifndef WIN32
int virNetSocketNewConnectUNIX(const char *path,
bool spawnDaemon,
const char *binary,
......@@ -1345,7 +1339,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 &&
......@@ -2273,7 +2267,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 &&
......
......@@ -20,7 +20,6 @@
#include <config.h>
#include <arpa/inet.h>
#ifdef __linux__
# include <linux/rtnetlink.h>
#endif
......
......@@ -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)
......
......@@ -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
......
......@@ -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. */
......
......@@ -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)
......
......@@ -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");
......
......@@ -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");
......
......@@ -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
......
......@@ -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
......
......@@ -24,8 +24,6 @@
#include "virbuffer.h"
#include "viralloc.h"
#include <netdb.h>
#define VIR_FROM_THIS VIR_FROM_NONE
/*
......
......@@ -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;
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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 *)
......
......@@ -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
......
......@@ -22,7 +22,6 @@
#ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
#endif
#include <netdb.h>
#include "testutils.h"
#include "virutil.h"
......
......@@ -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
......
......@@ -19,7 +19,6 @@
#include <config.h>
#include <fcntl.h>
#include <sys/socket.h>
#include "virnettlshelpers.h"
#include "viralloc.h"
......
......@@ -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
......
......@@ -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;
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册