[libvirt] [PATCH 0/2] FreeBSD build fixes

Applying these fixes building on FreeBSD, at least on my local builder (10.3-RELEASE). Cheers. Andrea Bolognani (2): configure: Move check for <gnutls/crypto.h> netdev: Use the correct pointer type for virSocketAddrFormat() configure.ac | 10 +++++----- src/util/virnetdev.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) -- 2.5.5

Checking for the availability of this header, just like checking for the availability of gnutls_rnd(), requires CFLAGS and LIBS to be set appropriately. Fixes the following compilation errors on FreeBSD: qemu/qemu_domain.c:640:16: error: implicit declaration of function 'gnutls_rnd' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if ((ret = gnutls_rnd(GNUTLS_RND_RANDOM, key, nbytes)) < 0) { ^ qemu/qemu_domain.c:640:27: error: use of undeclared identifier 'GNUTLS_RND_RANDOM'; did you mean 'GNUTLS_CRD_ANON'? if ((ret = gnutls_rnd(GNUTLS_RND_RANDOM, key, nbytes)) < 0) { ^~~~~~~~~~~~~~~~~ GNUTLS_CRD_ANON --- configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index c8c2895..1eb19ee 100644 --- a/configure.ac +++ b/configure.ac @@ -1281,11 +1281,6 @@ if test "x$with_gnutls" != "xno"; then [set to 1 if it is known or assumed that GNUTLS uses gcrypt]) fi - dnl gnutls 3.x moved some declarations to a new header - AC_CHECK_HEADERS([gnutls/crypto.h], [], [], [[ - #include <gnutls/gnutls.h> - ]]) - with_gnutls=yes fi @@ -1294,6 +1289,11 @@ if test "x$with_gnutls" != "xno"; then CFLAGS="$old_CFLAGS $GNUTLS_CFLAGS" LIBS="$old_LIBS $GNUTLS_LIBS" + dnl gnutls 3.x moved some declarations to a new header + AC_CHECK_HEADERS([gnutls/crypto.h], [], [], [[ + #include <gnutls/gnutls.h> + ]]) + AC_CHECK_FUNCS([gnutls_rnd]) CFLAGS="$old_CFLAGS" -- 2.5.5

virSocketAddrFormat() wants a single pointer, not a double pointer. Fixes the following compilation error on FreeBSD: util/virnetdev.c:1448:72: error: incompatible pointer types passing 'virSocketAddr **' to parameter of type 'const virSocketAddr *'; remove & [-Werror,-Wincompatible-pointer-types] if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(&peer))) ^~~~~ ./util/virsocketaddr.h:92:48: note: passing argument to parameter 'addr' here char *virSocketAddrFormat(const virSocketAddr *addr); ^ --- src/util/virnetdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 6e32ebb..712c3bc 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1445,7 +1445,7 @@ int virNetDevSetIPAddress(const char *ifname, if (!(addrstr = virSocketAddrFormat(addr))) goto cleanup; - if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(&peer))) + if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(peer))) goto cleanup; /* format up a broadcast address if this is IPv4 */ -- 2.5.5

Andrea Bolognani wrote:
virSocketAddrFormat() wants a single pointer, not a double pointer.
Fixes the following compilation error on FreeBSD:
util/virnetdev.c:1448:72: error: incompatible pointer types passing 'virSocketAddr **' to parameter of type 'const virSocketAddr *'; remove & [-Werror,-Wincompatible-pointer-types] if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(&peer))) ^~~~~ ./util/virsocketaddr.h:92:48: note: passing argument to parameter 'addr' here char *virSocketAddrFormat(const virSocketAddr *addr); ^ --- src/util/virnetdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 6e32ebb..712c3bc 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1445,7 +1445,7 @@ int virNetDevSetIPAddress(const char *ifname, if (!(addrstr = virSocketAddrFormat(addr))) goto cleanup;
- if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(&peer))) + if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(peer))) goto cleanup;
/* format up a broadcast address if this is IPv4 */
ACK (having the same one in my queue :-) ). On a related note, there's one more issue in this function related to the peer address support addition. It contains a code like this: 1466 if (peerstr) 1467 virCommandAddArgList(cmd, "pointopoint", peerstr, NULL); This should work on Linux, but FreeBSD's ifconfig has no support for the "pointopoint" keyword, the syntax is just "ifconfig $if $addr $peer_addr". I'll add a fix for that a little later as soon as I figure out how to give it a real test. Unfortunately, I see no easy way to detect presence of this keyword in ifconfig, so I guess it's going to be one more "#ifdef __linux__" knob. PS Also, appears that a command like this: ifconfig tun0 inet 192.168.77.0/24 192.168.77.12 broadcast 192.168.77.255 Actually sets peer address to 192.168.77.255. So need to figure out if we need to set broadcast if have peer address. Roman Bogorodskiy

On Fri, 2016-04-08 at 12:44 +0300, Roman Bogorodskiy wrote:
On a related note, there's one more issue in this function related to the peer address support addition. It contains a code like this: 1466 if (peerstr) 1467 virCommandAddArgList(cmd, "pointopoint", peerstr, NULL); This should work on Linux, but FreeBSD's ifconfig has no support for the "pointopoint" keyword, the syntax is just "ifconfig $if $addr $peer_addr". I'll add a fix for that a little later as soon as I figure out how to give it a real test. Unfortunately, I see no easy way to detect presence of this keyword in ifconfig, so I guess it's going to be one more "#ifdef __linux__" knob. PS Also, appears that a command like this: ifconfig tun0 inet 192.168.77.0/24 192.168.77.12 broadcast 192.168.77.255 Actually sets peer address to 192.168.77.255. So need to figure out if we need to set broadcast if have peer address.
I'll leave fixes related to the FreeBSD userland to you, as my experience with that OS is actually pretty limited :) Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team
participants (2)
-
Andrea Bolognani
-
Roman Bogorodskiy