mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
Miscellaneous fixes for building on Windows (MinGW).
* configure.in: xdr functions may require -lxdr. * configure.in, src/Makefile.am: Extra linking flags for building libvirt DLL. * src/socketcompat.h: Hide Windows Winsock incompatibilities in a separate header file. * src/remote_internal.c: Switch to using socketcompat.h / socket_errno(). * src/test.c: Switch to using socketcompat.h. * gnulib/lib/arpa/.cvsignore: Ignore another generated file. * src/qparams.c: Include <config.h>.
This commit is contained in:
parent
76122538b6
commit
029aef1d24
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
Wed Jan 5 16:02:00 UTC 2008 Richard W.M. Jones <rjones@redhat.com>
|
||||
|
||||
Miscellaneous fixes for building on Windows (MinGW).
|
||||
* configure.in: xdr functions may require -lxdr.
|
||||
* configure.in, src/Makefile.am: Extra linking flags for
|
||||
building libvirt DLL.
|
||||
* src/socketcompat.h: Hide Windows Winsock incompatibilities
|
||||
in a separate header file.
|
||||
* src/remote_internal.c: Switch to using socketcompat.h /
|
||||
socket_errno().
|
||||
* src/test.c: Switch to using socketcompat.h.
|
||||
* gnulib/lib/arpa/.cvsignore: Ignore another generated file.
|
||||
* src/qparams.c: Include <config.h>.
|
||||
|
||||
Wed Jan 2 17:45:53 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/remote_internal.c: fix policykit auth handling of NULL
|
||||
|
@ -65,8 +65,8 @@ AC_CHECK_FUNCS([cfmakeraw regexec uname])
|
||||
dnl Availability of various common headers (non-fatal if missing).
|
||||
AC_CHECK_HEADERS([pwd.h paths.h sys/syslimits.h sys/utsname.h sys/wait.h winsock2.h])
|
||||
|
||||
dnl Need -lrpc? (Cygwin needs this)
|
||||
AC_SEARCH_LIBS(xdrmem_create,rpc)
|
||||
dnl Need -lrpc or -lxdr? (Cygwin and MinGW resp. need this)
|
||||
AC_SEARCH_LIBS(xdrmem_create,[rpc xdr])
|
||||
|
||||
dnl Do we have rpcgen?
|
||||
AC_PATH_PROG(RPCGEN, rpcgen, no)
|
||||
@ -650,6 +650,7 @@ dnl for now since I'm not supporting mingw at present. - RWMJ
|
||||
CYGWIN_EXTRA_LDFLAGS=
|
||||
CYGWIN_EXTRA_LIBADD=
|
||||
CYGWIN_EXTRA_PYTHON_LIBADD=
|
||||
MINGW_EXTRA_LDFLAGS=
|
||||
case "$host" in
|
||||
*-*-cygwin*)
|
||||
CYGWIN_EXTRA_LDFLAGS="-no-undefined"
|
||||
@ -658,10 +659,14 @@ case "$host" in
|
||||
CYGWIN_EXTRA_PYTHON_LIBADD="-L/usr/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
|
||||
fi
|
||||
;;
|
||||
*-*-mingw*)
|
||||
MINGW_EXTRA_LDFLAGS="-no-undefined"
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(CYGWIN_EXTRA_LDFLAGS)
|
||||
AC_SUBST(CYGWIN_EXTRA_LIBADD)
|
||||
AC_SUBST(CYGWIN_EXTRA_PYTHON_LIBADD)
|
||||
AC_SUBST(MINGW_EXTRA_LDFLAGS)
|
||||
|
||||
# very annoying
|
||||
rm -f COPYING
|
||||
|
@ -0,0 +1 @@
|
||||
inet.h
|
@ -31,6 +31,7 @@ lib_LTLIBRARIES = libvirt.la
|
||||
CLIENT_SOURCES = \
|
||||
libvirt.c internal.h \
|
||||
gnutls_1_0_compat.h \
|
||||
socketcompat.h \
|
||||
hash.c hash.h \
|
||||
test.c test.h \
|
||||
buf.c buf.h \
|
||||
@ -68,7 +69,7 @@ libvirt_la_LIBADD = $(LIBXML_LIBS) $(GNUTLS_LIBS) $(SASL_LIBS) \
|
||||
libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \
|
||||
-version-info @LIBVIRT_VERSION_INFO@ \
|
||||
$(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
|
||||
@CYGWIN_EXTRA_LDFLAGS@
|
||||
@CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
|
||||
libvirt_la_CFLAGS = $(COVERAGE_CFLAGS)
|
||||
|
||||
bin_PROGRAMS = virsh
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <libxml/uri.h>
|
||||
#include "getpass.h"
|
||||
|
||||
#if HAVE_WINSOCK2_H
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
* Utility functions to help parse and assemble query strings.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -23,12 +23,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/* Windows socket compatibility functions. */
|
||||
#include "socketcompat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -46,15 +48,6 @@
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WINSOCK2_H
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <gnutls/gnutls.h>
|
||||
@ -525,7 +518,7 @@ doRemoteOpen (virConnectPtr conn,
|
||||
|
||||
priv->sock = socket (r->ai_family, SOCK_STREAM, 0);
|
||||
if (priv->sock == -1) {
|
||||
error (conn, VIR_ERR_SYSTEM_ERROR, strerror (errno));
|
||||
error (conn, VIR_ERR_SYSTEM_ERROR, strerror (socket_errno ()));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -535,7 +528,7 @@ doRemoteOpen (virConnectPtr conn,
|
||||
sizeof no_slow_start);
|
||||
|
||||
if (connect (priv->sock, r->ai_addr, r->ai_addrlen) == -1) {
|
||||
error (conn, VIR_ERR_SYSTEM_ERROR, strerror (errno));
|
||||
error (conn, VIR_ERR_SYSTEM_ERROR, strerror (socket_errno ()));
|
||||
close (priv->sock);
|
||||
continue;
|
||||
}
|
||||
@ -3036,7 +3029,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
|
||||
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
|
||||
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"failed to get sock address %d (%s)",
|
||||
errno, strerror(errno));
|
||||
socket_errno (), strerror(socket_errno ()));
|
||||
goto cleanup;
|
||||
}
|
||||
if ((localAddr = addrToString(&sa, salen)) == NULL)
|
||||
@ -3048,7 +3041,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
|
||||
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
|
||||
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"failed to get peer address %d (%s)",
|
||||
errno, strerror(errno));
|
||||
socket_errno (), strerror(socket_errno ()));
|
||||
goto cleanup;
|
||||
}
|
||||
if ((remoteAddr = addrToString(&sa, salen)) == NULL)
|
||||
@ -3601,12 +3594,13 @@ really_write_buf (virConnectPtr conn, struct private_data *priv,
|
||||
while (len > 0);
|
||||
} else {
|
||||
do {
|
||||
err = write (priv->sock, p, len);
|
||||
err = send (priv->sock, p, len, 0);
|
||||
if (err == -1) {
|
||||
if (errno == EINTR || errno == EAGAIN)
|
||||
int errno_ = socket_errno ();
|
||||
if (errno_ == EINTR || errno_ == EAGAIN)
|
||||
continue;
|
||||
error (in_open ? NULL : conn,
|
||||
VIR_ERR_SYSTEM_ERROR, strerror (errno));
|
||||
VIR_ERR_SYSTEM_ERROR, strerror (errno_));
|
||||
return -1;
|
||||
}
|
||||
len -= err;
|
||||
@ -3683,12 +3677,13 @@ really_read_buf (virConnectPtr conn, struct private_data *priv,
|
||||
return err;
|
||||
} else {
|
||||
reread:
|
||||
err = read (priv->sock, bytes, len);
|
||||
err = recv (priv->sock, bytes, len, 0);
|
||||
if (err == -1) {
|
||||
if (errno == EINTR)
|
||||
int errno_ = socket_errno ();
|
||||
if (errno_ == EINTR)
|
||||
goto reread;
|
||||
error (in_open ? NULL : conn,
|
||||
VIR_ERR_SYSTEM_ERROR, strerror (errno));
|
||||
VIR_ERR_SYSTEM_ERROR, strerror (errno_));
|
||||
return -1;
|
||||
}
|
||||
if (err == 0) {
|
||||
|
60
src/socketcompat.h
Normal file
60
src/socketcompat.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* socketcompat.h: Socket compatibility for Windows, making it slightly
|
||||
* less painful to use.
|
||||
*
|
||||
* Use this header under the following circumstances:
|
||||
* (a) Instead of including any of: <net/if.h>, <netinet/in.h>,
|
||||
* <sys/socket.h>, <netdb.h>, <netinet/tcp.h>, AND
|
||||
* (b) The file will be part of what is built on Windows (basically
|
||||
* just remote client stuff).
|
||||
*
|
||||
* You need to use socket_errno() instead of errno to get socket
|
||||
* errors.
|
||||
*
|
||||
* Copyright (C) 2008 Red Hat, Inc.
|
||||
*
|
||||
* See COPYING.LIB for the License of this software
|
||||
*
|
||||
* Richard W.M. Jones <rjones@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef __SOCKETCOMPAT_H__
|
||||
#define __SOCKETCOMPAT_H__
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef HAVE_WINSOCK2_H /* Unix & Cygwin. */
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
|
||||
static inline int
|
||||
socket_errno (void)
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
|
||||
#else /* MinGW & Win32 */
|
||||
|
||||
#include <winsock2.h>
|
||||
|
||||
/* Socket functions in Windoze don't set errno. Instead of using errno
|
||||
* to test for socket errors, call this function to get the errno.
|
||||
*/
|
||||
static inline int
|
||||
socket_errno (void)
|
||||
{
|
||||
return WSAGetLastError ();
|
||||
}
|
||||
|
||||
/* Compatibility. */
|
||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define ECONNREFUSED WSAECONNREFUSED
|
||||
|
||||
#endif /* HAVE_WINSOCK2_H */
|
||||
|
||||
#endif /* __WINSOCKWRAPPER_H__ */
|
@ -28,7 +28,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
@ -37,12 +36,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef HAVE_WINSOCK2_H
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#include "socketcompat.h"
|
||||
|
||||
#include "internal.h"
|
||||
#include "test.h"
|
||||
|
Loading…
Reference in New Issue
Block a user