Re: [PATCH] build: force libnl1 if netcf also used libnl1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/07/2012 06:42 PM, Eric Blake wrote:
Recent spec file changes ensure that in distro situations, netcf
and libvirt will link against the same libnl in order to avoid
dumping core.  But for every-day development, if you are F17 and
have the libnl3-devel headers available, libvirt was blindly
linking against libnl3 even though F17 netcf still links against
libnl1, making testing a self-built binary on F17 impossible.

By making configure a little bit smarter, we can avoid this
situation.  I intentionally wrote the test so that we still favor
libnl-3 if netcf is not installed or if we couldn't use ldd
to determine which library netcf linked against.

* configure.ac (LIBNL): Don't probe libnl3 if netcf doesn't use it.
---

Does this patch look safe enough to use?  It was sufficient to
let me resume self-tests on my F17 box, where I had intentionally
installed libnl3-devel.

The problem that this patch is attempting to fix is both real and takes a little digging to find ... as happened to me.

While is might be nice to have the option of using libnl-3 on a Fedora 17 system, it should then require the correct netcf.

Gene

  configure.ac | 28 +++++++++++++++++++---------
  1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 47a72b9..7528894 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2902,14 +2902,24 @@ LIBNL_LIBS=""
  have_libnl=no

  if test "$with_linux" = "yes"; then
-    PKG_CHECK_MODULES([LIBNL], [libnl-3.0], [
-        have_libnl=yes
-        AC_DEFINE([HAVE_LIBNL3], [1], [Use libnl-3.0])
-        AC_DEFINE([HAVE_LIBNL], [1], [whether the netlink library is available])
-        PKG_CHECK_MODULES([LIBNL_ROUTE3], [libnl-route-3.0])
-        LIBNL_CFLAGS="$LIBNL_CFLAGS $LIBNL_ROUTE3_CFLAGS"
-        LIBNL_LIBS="$LIBNL_LIBS $LIBNL_ROUTE3_LIBS"
-    ], [PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
+    # When linking with netcf, we must ensure that we pick the same version
+    # of libnl that netcf picked.  Prefer libnl-3 unless we can prove
+    # netcf linked against libnl-1.
+    ncftool=`which ncftool`
+    case `(ldd "$ncftool") 2>&1` in
+        *libnl.so.1*) ;;
+        *)
+        PKG_CHECK_MODULES([LIBNL], [libnl-3.0], [
+            have_libnl=yes
+            AC_DEFINE([HAVE_LIBNL3], [1], [Use libnl-3.0])
+            AC_DEFINE([HAVE_LIBNL], [1], [whether the netlink library is available])
+            PKG_CHECK_MODULES([LIBNL_ROUTE3], [libnl-route-3.0])
+            LIBNL_CFLAGS="$LIBNL_CFLAGS $LIBNL_ROUTE3_CFLAGS"
+            LIBNL_LIBS="$LIBNL_LIBS $LIBNL_ROUTE3_LIBS"
+        ], []) ;;
+    esac
+    if test "$have_libnl" = no; then
+        PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
              have_libnl=yes
              AC_DEFINE_UNQUOTED([HAVE_LIBNL], [1],
               [whether the netlink library is available])
@@ -2920,7 +2930,7 @@ if test "$with_linux" = "yes"; then
                  AC_MSG_ERROR([libnl-devel >= $LIBNL_REQUIRED is required for macvtap support])
              fi
          ])
-    ])
+    fi
  fi
  AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"])


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]