[libvirt] [PATCH 1/2] build: avoid journald on rhel 5

Commit f6430390 broke builds on RHEL 5, where glibc (2.5) is too old to support mkostemp (2.7) or htole64 (2.9). While gnulib has mkostemp, it still lacks htole64; and it's not worth dragging in replacements on systems where journald is unlikely to exist in the first place, so we just use an extra configure-time check as our witness of whether to attempt compiling the code. * src/util/logging.c (virLogParseOutputs): Don't attempt to compile journald on older glibc. * configure.ac (AC_CHECK_FUNCS_ONCE): Check for htole64. --- Pushing under the build-breaker rule. configure.ac | 2 +- src/util/logging.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 13967e9..c791ed0 100644 --- a/configure.ac +++ b/configure.ac @@ -172,7 +172,7 @@ AC_CHECK_SIZEOF([long]) dnl Availability of various common functions (non-fatal if missing), dnl and various less common threadsafe functions AC_CHECK_FUNCS_ONCE([cfmakeraw geteuid getgid getgrnam_r getmntent_r \ - getpwuid_r getuid initgroups kill mmap newlocale posix_fallocate \ + getpwuid_r getuid htole64 initgroups kill mmap newlocale posix_fallocate \ posix_memalign regexec sched_getaffinity]) dnl Availability of pthread functions (if missing, win32 threading is diff --git a/src/util/logging.c b/src/util/logging.c index 0ce18f1..7a73553 100644 --- a/src/util/logging.c +++ b/src/util/logging.c @@ -50,6 +50,12 @@ #include "virtime.h" #include "intprops.h" +/* Journald output is only supported on Linux new enough to expose + * htole64. */ +#if HAVE_SYSLOG_H && defined(__linux__) && HAVE_HTOLE64 +# define USE_JOURNALD 1 +#endif + #define VIR_FROM_THIS VIR_FROM_NONE VIR_ENUM_DECL(virLogSource) @@ -1029,7 +1035,7 @@ virLogAddOutputToSyslog(virLogPriority priority, } -# ifdef __linux__ +# if USE_JOURNALD # define IOVEC_SET_STRING(iov, str) \ do { \ struct iovec *_i = &(iov); \ @@ -1197,7 +1203,7 @@ static int virLogAddOutputToJournald(int priority) } return 0; } -# endif /* __linux__ */ +# endif /* USE_JOURNALD */ #endif /* HAVE_SYSLOG_H */ #define IS_SPACE(cur) \ @@ -1294,12 +1300,10 @@ virLogParseOutputs(const char *outputs) VIR_FREE(abspath); } else if (STREQLEN(cur, "journald", 8)) { cur += 8; -#if HAVE_SYSLOG_H -# ifdef __linux__ +#if USE_JOURNALD if (virLogAddOutputToJournald(prio) == 0) count++; -# endif /* __linux__ */ -#endif /* HAVE_SYSLOG_H */ +#endif /* USE_JOURNALD */ } else { goto cleanup; } -- 1.7.11.4

Commit f1a43a8 missed one side of an #if/#else. * src/util/processinfo.c (virProcessInfoGetAffinity): Use correct bitmap operation. --- Pushing under the build-breaker rule. src/util/processinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/processinfo.c b/src/util/processinfo.c index d9d255c..d4f8f4b 100644 --- a/src/util/processinfo.c +++ b/src/util/processinfo.c @@ -161,7 +161,7 @@ realloc: for (i = 0 ; i < maxcpu ; i++) if (CPU_ISSET(i, &mask)) - VIR_USE_CPU(map, i); + ignore_value(virBitmapSetBit(*map, i)); # endif return 0; -- 1.7.11.4

On 10/01/2012 05:07 PM, Eric Blake wrote:
Commit f6430390 broke builds on RHEL 5, where glibc (2.5) is too old to support mkostemp (2.7) or htole64 (2.9). While gnulib has mkostemp, it still lacks htole64; and it's not worth dragging in replacements on systems where journald is unlikely to exist in the first place, so we just use an extra configure-time check as our witness of whether to attempt compiling the code.
* src/util/logging.c (virLogParseOutputs): Don't attempt to compile journald on older glibc. * configure.ac (AC_CHECK_FUNCS_ONCE): Check for htole64.
Actually, this won't work (glad I didn't push yet); on F17 little-endian machines, htole64 is a macro with no backing function, so you have to use AC_CHECK_DECLS rather than AC_CHECK_FUNCS to detect it. v2 coming up. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Commit f6430390 broke builds on RHEL 5, where glibc (2.5) is too old to support mkostemp (2.7) or htole64 (2.9). While gnulib has mkostemp, it still lacks htole64; and it's not worth dragging in replacements on systems where journald is unlikely to exist in the first place, so we just use an extra configure-time check as our witness of whether to attempt compiling the code. * src/util/logging.c (virLogParseOutputs): Don't attempt to compile journald on older glibc. * configure.ac (AC_CHECK_DECLS): Check for htole64. --- v2: use correct configure probe. Now tested on both F17 and RHEL 5, so finally pushing under the build-breaker rule. configure.ac | 2 ++ src/util/logging.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 13967e9..6d50985 100644 --- a/configure.ac +++ b/configure.ac @@ -187,6 +187,8 @@ dnl Availability of various common headers (non-fatal if missing). AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \ sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \ sys/un.h sys/syscall.h netinet/tcp.h ifaddrs.h libtasn1.h]) +dnl Check whether endian provides handy macros. +AC_CHECK_DECLS([htole64], [], [], [[#include <endian.h>]]) dnl We need to decide at configure time if libvirt will use real atomic dnl operations ("lock free") or emulated ones with a mutex. diff --git a/src/util/logging.c b/src/util/logging.c index 0ce18f1..246f12c 100644 --- a/src/util/logging.c +++ b/src/util/logging.c @@ -50,6 +50,12 @@ #include "virtime.h" #include "intprops.h" +/* Journald output is only supported on Linux new enough to expose + * htole64. */ +#if HAVE_SYSLOG_H && defined(__linux__) && HAVE_DECL_HTOLE64 +# define USE_JOURNALD 1 +#endif + #define VIR_FROM_THIS VIR_FROM_NONE VIR_ENUM_DECL(virLogSource) @@ -1029,7 +1035,7 @@ virLogAddOutputToSyslog(virLogPriority priority, } -# ifdef __linux__ +# if USE_JOURNALD # define IOVEC_SET_STRING(iov, str) \ do { \ struct iovec *_i = &(iov); \ @@ -1197,7 +1203,7 @@ static int virLogAddOutputToJournald(int priority) } return 0; } -# endif /* __linux__ */ +# endif /* USE_JOURNALD */ #endif /* HAVE_SYSLOG_H */ #define IS_SPACE(cur) \ @@ -1294,12 +1300,10 @@ virLogParseOutputs(const char *outputs) VIR_FREE(abspath); } else if (STREQLEN(cur, "journald", 8)) { cur += 8; -#if HAVE_SYSLOG_H -# ifdef __linux__ +#if USE_JOURNALD if (virLogAddOutputToJournald(prio) == 0) count++; -# endif /* __linux__ */ -#endif /* HAVE_SYSLOG_H */ +#endif /* USE_JOURNALD */ } else { goto cleanup; } -- 1.7.11.4

On Mon, Oct 01, 2012 at 05:38:56PM -0600, Eric Blake wrote:
Commit f6430390 broke builds on RHEL 5, where glibc (2.5) is too old to support mkostemp (2.7) or htole64 (2.9). While gnulib has mkostemp, it still lacks htole64; and it's not worth dragging in replacements on systems where journald is unlikely to exist in the first place, so we just use an extra configure-time check as our witness of whether to attempt compiling the code.
* src/util/logging.c (virLogParseOutputs): Don't attempt to compile journald on older glibc. * configure.ac (AC_CHECK_DECLS): Check for htole64. ---
v2: use correct configure probe. Now tested on both F17 and RHEL 5, so finally pushing under the build-breaker rule.
ACK 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 :|
participants (2)
-
Daniel P. Berrange
-
Eric Blake