[libvirt] building on RHEL 5 currently broken

Just a quick heads-up (I'll fix it later, when I have more time): I just learned commit 350583c85 broke builds on RHEL 5, because of the use of AS_VERSION_COMPARE in configure.ac which was not available in older autoconf 2.59. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Commit 350583c8 broke development on a RHEL 5 box, where the ancient Autoconf 2.59 lacks AS_VERSION_STRING. Rather than backport the complex awk script that newer autoconf uses for true strverscmp comparisons from the shell, it was easier to just open-code a shell case statement. * configure.ac (qemu_version): Open-code a replacement for AS_VERSION_CHECK. --- Pushing under the build-breaker rule. 'make' still failed: util/virfile.c: In function 'virFileLoopDeviceAssociate': util/virfile.c:580: error: 'LO_FLAGS_AUTOCLEAR' undeclared (first use in this function) But at least I got past the './autogen.sh' failure. configure.ac | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ba5a3cd..d650626 100644 --- a/configure.ac +++ b/configure.ac @@ -1121,8 +1121,11 @@ if test "$with_qemu:$with_yajl" = yes:check; then else [qemu_version_sed='s/.*ersion \([0-9.,]*\).*/\1/'] qemu_version=`$QEMU -version | sed "$qemu_version_sed"` - AS_VERSION_COMPARE([$qemu_version], [0.15], - [], [with_yajl=yes], [with_yajl=yes]) + case $qemu_version in + [[1-9]].* | 0.15.* ) with_yajl=yes ;; + 0.* | '' ) ;; + *) AC_MSG_ERROR([Unexpected qemu version string]) ;; + esac fi fi fi -- 1.7.11.4

We already skip out on building the LXC under RHEL 5, because the kernel is too old (commits 4c18acf, 2dee896); but commit 9612e4b moved some LXC-only code into common files, resulting in this build failure: util/virfile.c: In function 'virFileLoopDeviceAssociate': util/virfile.c:580: error: 'LO_FLAGS_AUTOCLEAR' undeclared (first use in this function) Unfortunately, the kernel folks only made it an enum, rather than also a #define, so we have to modify configure.ac to record when it is usable. * configure.ac (with_lxc): Mark when LO_FLAGS_AUTOCLEAR was found. * src/util/virfile.c (virFileLoopDeviceAssociate): Avoid compilation when kernel is too old. --- Pushing under the build-breaker rule. configure.ac | 3 +++ src/util/virfile.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e7d36bc..a4b06ca 100644 --- a/configure.ac +++ b/configure.ac @@ -874,6 +874,9 @@ if test "$with_lxc" = "yes" || test "$with_lxc" = "check"; then unshare (!(LO_FLAGS_AUTOCLEAR + EPOLL_CLOEXEC)); ], [ with_lxc=yes + AC_DEFINE([HAVE_DECL_LO_FLAGS_AUTOCLEAR], [1], + [Define to 1 if you have the declaration of `LO_FLAGS_AUTOCLEAR', + and to 0 if you don't.]) ], [ if test "$with_lxc" = "check"; then with_lxc=no diff --git a/src/util/virfile.c b/src/util/virfile.c index 6a43869..dd64e88 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -497,7 +497,7 @@ int virFileUpdatePerm(const char *path, } -#ifdef __linux__ +#if defined(__linux__) && HAVE_DECL_LO_FLAGS_AUTOCLEAR static int virFileLoopDeviceOpen(char **dev_name) { int fd = -1; -- 1.7.11.4

Building on RHEL 5 warned: nodeinfo.c: 305: warning: implicit declaration of function 'CPU_COUNT' This extension macro in <sched.h> was not added until later glibc. * src/nodeinfo.c (CPU_COUNT): Add fallback implementation. --- Pushing under the build-breaker rule. I'm still getting link failures: ./.libs/libvirt_util.a(libvirt_util_la-virobject.o): In function `virAtomicIntXor': /home/dummy/l,ibvirt/src/util/viratomoic.h:404: multiple definition of `virAtomicIntXor' ./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):/home/dummy/libvirt/src/util/viratomic.h:404: first defined here but at least the compile failures now appear to be solved. src/nodeinfo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 84a5d66..e3d4a24 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -184,6 +184,19 @@ virNodeParseSocket(const char *dir, unsigned int cpu) return ret; } +# ifndef CPU_COUNT +static int +CPU_COUNT(cpu_set_t *set) +{ + int i, count = 0; + + for (i = 0; i < CPU_SETSIZE; i++) + if (CPU_ISSET(i, set)) + count++; + return count; +} +# endif /* !CPU_COUNT */ + /* parses a node entry, returning number of processors in the node and * filling arguments */ static int -- 1.7.11.4

On Tue, Aug 21, 2012 at 11:17:21AM -0600, Eric Blake wrote:
Building on RHEL 5 warned:
nodeinfo.c: 305: warning: implicit declaration of function 'CPU_COUNT'
This extension macro in <sched.h> was not added until later glibc.
* src/nodeinfo.c (CPU_COUNT): Add fallback implementation. ---
Pushing under the build-breaker rule. I'm still getting link failures:
./.libs/libvirt_util.a(libvirt_util_la-virobject.o): In function `virAtomicIntXor': /home/dummy/l,ibvirt/src/util/viratomoic.h:404: multiple definition of `virAtomicIntXor' ./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):/home/dummy/libvirt/src/util/viratomic.h:404: first defined here
Hmm, that seems to suggested that when viratomic.c #includes viratomic.h, GCC is instantiating the functions, even though they're declared inline. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 08/21/2012 12:39 PM, Daniel P. Berrange wrote:
On Tue, Aug 21, 2012 at 11:17:21AM -0600, Eric Blake wrote:
Building on RHEL 5 warned:
nodeinfo.c: 305: warning: implicit declaration of function 'CPU_COUNT'
This extension macro in <sched.h> was not added until later glibc.
* src/nodeinfo.c (CPU_COUNT): Add fallback implementation. ---
Pushing under the build-breaker rule. I'm still getting link failures:
./.libs/libvirt_util.a(libvirt_util_la-virobject.o): In function `virAtomicIntXor': /home/dummy/l,ibvirt/src/util/viratomoic.h:404: multiple definition of `virAtomicIntXor' ./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):/home/dummy/libvirt/src/util/viratomic.h:404: first defined here
Hmm, that seems to suggested that when viratomic.c #includes viratomic.h, GCC is instantiating the functions, even though they're declared inline.
Yep, we declared them 'inline' (which means they still have an eternal address), not 'static inline' (which means don't emit, if possible) or even '__attribute__((__gnu_inline__))' (which means don't emit, ever). We don't see it on modern Fedora or RHEL (gcc intrinsics work); I'm not sure why mingw isn't seeing it, but RHEL 5 is seeing it because it falls back to the pthread implementation. I'm testing a patch now... -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Without this patch, RHEL 5 fails to compile, since the dbus files lives under /usr/include/dbus-1.0/dbus/dbus.h, and DBUS_CFLAGS contains -I/usr/include/dbus-1.0. In file included from network/bridge_driver.c:67: ../src/util/virdbus.h:26:25: error: dbus/dbus.h: No such file or directory * src/Makefile.am (libvirt_driver_network_impl_la_CFLAGS): Add DBUS_CFLAGS. --- src/Makefile.am | 2 +- src/util/viratomic.h | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 61b6e09..39cbefd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1006,7 +1006,7 @@ noinst_LTLIBRARIES += libvirt_driver_network.la endif libvirt_driver_network_impl_la_CFLAGS = \ - $(LIBNL_CFLAGS) \ + $(LIBNL_CFLAGS) $(DBUS_CFLAGS) \ -I$(top_srcdir)/src/conf $(AM_CFLAGS) $(DBUS_CFLAGS) libvirt_driver_network_impl_la_SOURCES = $(NETWORK_DRIVER_SOURCES) endif -- 1.7.11.4

Older automake 1.9.6 (hello there, RHEL 5) did not populate $(builddir), which meant 'make check' failed with: make[3]: *** No rule to make target `/.libs/libvirt.la', needed by `check-symfile'. Stop. For that matter, even newer automake doesn't directly emit rules to build .libs/libvirt.la; we are better off basing our rules on the public ./libvirt.la. * src/Makefile.am (check-symfile): Delete useless variable. --- Pushing under the build-breaker rule. src/Makefile.am | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 39cbefd..2f15a37 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -310,8 +310,11 @@ PDWTAGS = \ echo 'WARNING: install the dwarves package to get pdwtags' >&2; \ fi -check-symfile: libvirt.syms $(builddir)/.libs/libvirt.la - $(AM_V_GEN)$(PERL) $(srcdir)/check-symfile.pl libvirt.syms $(builddir)/.libs/libvirt.so +# .libs/libvirt.so is built by libtool as a side-effect of the Makefile +# rule for libvirt.la +check-symfile: libvirt.syms libvirt.la + $(AM_V_GEN)$(PERL) $(srcdir)/check-symfile.pl libvirt.syms \ + .libs/libvirt.so PROTOCOL_STRUCTS = \ $(srcdir)/remote_protocol-structs \ -- 1.7.11.4

On 08/20/2012 05:54 PM, Eric Blake wrote:
Just a quick heads-up (I'll fix it later, when I have more time): I just learned commit 350583c85 broke builds on RHEL 5, because of the use of AS_VERSION_COMPARE in configure.ac which was not available in older autoconf 2.59.
It turned into six patches, but I can now run 'make check', with these results: TEST: viruritest ...........!....!. 18 FAIL FAIL: viruritest TEST: virdrivermoduletest !!!!!!!! 8 FAIL FAIL: virdrivermoduletest TEST: interfaceschematest ..!.!!!!.......... 18 FAILED FAIL: interfaceschematest TEST: nwfilterschematest ......!..........................!...... 40 . 41 FAILED FAIL: nwfilterschematest ======================================= 4 of 65 tests failed (3 tests were not run) I suspect 3 of those 4 are due to the bugs in the extremely old libxml2 in RHEL 5 failing to validate complex RNG; but the failures in virdrivermoduletest may warrant investigation. Running that one under VIR_TEST_DEBUG doesn't give any hints. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/21/2012 04:50 PM, Eric Blake wrote:
On 08/20/2012 05:54 PM, Eric Blake wrote:
Just a quick heads-up (I'll fix it later, when I have more time): I just learned commit 350583c85 broke builds on RHEL 5, because of the use of AS_VERSION_COMPARE in configure.ac which was not available in older autoconf 2.59. It turned into six patches, but I can now run 'make check', with these results:
TEST: interfaceschematest ..!.!!!!.......... 18 FAILED
interfaceschematest is meaningless for RHEL5, since actually using the virInterface API requires netcf, and netcf was never an official part of RHEL5 (although there was a package in EPEL, at some point fairly early on support was discontinued because of some other dependent package missing in RHEL5; a proper version of libnl maybe? I've forgotten...)
FAIL: interfaceschematest
TEST: nwfilterschematest ......!..........................!...... 40 . 41 FAILED FAIL: nwfilterschematest
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Laine Stump