
On 05/03/2012 10:10 AM, Serge Hallyn wrote:
configure.ac+Makefile.am: support libnl-3 as well as libnl-1
src/util/virnetlink.c: support libnl3 api. To minimize impact on code flow with #ifdefs as requested by Stefan Berger, do some #defines at the top.
Unfortunately libnl3 moves netlink/msg.h to /usr/include/libnl3/netlink/msg.h, so the LIBNL_CFLAGS need to be added to a bunch of places where they weren't needed with libnl1.
if test "$with_linux" = "yes"; then - PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [ + PKG_CHECK_MODULES([LIBNL],[libnl-3.0],[ have_libnl=yes - AC_DEFINE_UNQUOTED([HAVE_LIBNL], 1, [whether the netlink library is available]) - ], [ - if test "$with_macvtap" = "yes"; then - AC_MSG_ERROR([libnl-devel >= $LIBNL_REQUIRED is required for macvtap support]) - fi - ]) + 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]) + ],
Need [ here...
+ PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [ + have_libnl=yes + AC_DEFINE_UNQUOTED([HAVE_LIBNL], 1, [whether the netlink library is available]) + AC_DEFINE_UNQUOTED([HAVE_LIBNL1], 1, [whether the netlink v1 library is available]) + ], [ + if test "$with_macvtap" = "yes"; then + AC_MSG_ERROR([libnl-devel >= $LIBNL_REQUIRED is required for macvtap support]) + fi + ])
and another ] here. (That is, when nesting one PKG_CHECK_MODULES within another, the nested version needs to be quoted.)
+ ) fi AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"])
diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 24cce8f..8074803 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -95,6 +95,7 @@ libvirtd_SOURCES = $(DAEMON_SOURCES) libvirtd_CFLAGS = \ $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \ $(XDR_CFLAGS) $(POLKIT_CFLAGS) $(DBUS_CFLAGS) \ + $(LIBNL_CFLAGS) $(LIBNL_ROUTE3_CFLAGS) \
I would prefer an approach that merged LIBNL_ROUTE3_CFLAGS into LIBNL_CFLAGS at configure time, so that you don't need so many Makefile.am edits.
@@ -109,7 +110,9 @@ libvirtd_LDADD = \ $(GNUTLS_LIBS) \ $(SASL_LIBS) \ $(DBUS_LIBS) \ - $(POLKIT_LIBS) + $(POLKIT_LIBS) \ + $(LIBNL_LIBS) \ + $(LIBNL_ROUTE3_LIBS)
Same for merging LIBNL_ROUTE3_LIBS into LIBNL_LIBS at configure time.
+++ b/src/util/virnetlink.c @@ -60,6 +60,16 @@ struct virNetlinkEventHandle { int deleted; };
+#ifdef HAVE_LIBNL1 +#define nl_alloc nl_handle_alloc +#define nl_free nl_handle_destroy
This fails 'make syntax-check' if you have cppi installed; you need to indent as in: #ifdef HAVE_LIBNL1 # define nl_alloc nl_handle_alloc #else ... But I do like the approach you took here. Looking forward to v3. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org