diff --git a/configure.ac b/configure.ac index 13967e90bb..6d50985cca 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 ]]) 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 0ce18f1c18..246f12cf0b 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; }