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_DECLS): Check for htole64.
This commit is contained in:
Eric Blake 2012-10-01 16:38:56 -06:00
parent 9038ac65da
commit cd1e8d1c47
2 changed files with 12 additions and 6 deletions

View File

@ -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 \ 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/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]) 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 We need to decide at configure time if libvirt will use real atomic
dnl operations ("lock free") or emulated ones with a mutex. dnl operations ("lock free") or emulated ones with a mutex.

View File

@ -50,6 +50,12 @@
#include "virtime.h" #include "virtime.h"
#include "intprops.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 #define VIR_FROM_THIS VIR_FROM_NONE
VIR_ENUM_DECL(virLogSource) VIR_ENUM_DECL(virLogSource)
@ -1029,7 +1035,7 @@ virLogAddOutputToSyslog(virLogPriority priority,
} }
# ifdef __linux__ # if USE_JOURNALD
# define IOVEC_SET_STRING(iov, str) \ # define IOVEC_SET_STRING(iov, str) \
do { \ do { \
struct iovec *_i = &(iov); \ struct iovec *_i = &(iov); \
@ -1197,7 +1203,7 @@ static int virLogAddOutputToJournald(int priority)
} }
return 0; return 0;
} }
# endif /* __linux__ */ # endif /* USE_JOURNALD */
#endif /* HAVE_SYSLOG_H */ #endif /* HAVE_SYSLOG_H */
#define IS_SPACE(cur) \ #define IS_SPACE(cur) \
@ -1294,12 +1300,10 @@ virLogParseOutputs(const char *outputs)
VIR_FREE(abspath); VIR_FREE(abspath);
} else if (STREQLEN(cur, "journald", 8)) { } else if (STREQLEN(cur, "journald", 8)) {
cur += 8; cur += 8;
#if HAVE_SYSLOG_H #if USE_JOURNALD
# ifdef __linux__
if (virLogAddOutputToJournald(prio) == 0) if (virLogAddOutputToJournald(prio) == 0)
count++; count++;
# endif /* __linux__ */ #endif /* USE_JOURNALD */
#endif /* HAVE_SYSLOG_H */
} else { } else {
goto cleanup; goto cleanup;
} }