From 30bdadf032d1c210bae6e2785277afe030d9baf4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 29 Mar 2014 14:55:01 +0000 Subject: [PATCH] builder: Disable internal parallel xzcat on RHEL 6. --- builder/pxzcat-c.c | 28 +++++++++++++++++++--------- configure.ac | 8 +++++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/builder/pxzcat-c.c b/builder/pxzcat-c.c index f905b31f9..941599581 100644 --- a/builder/pxzcat-c.c +++ b/builder/pxzcat-c.c @@ -36,6 +36,10 @@ #include "ignore-value.h" +#if HAVE_LIBLZMA +#include +#endif + #ifdef HAVE_CAML_UNIXSUPPORT_H #include #else @@ -43,18 +47,24 @@ extern void unix_error (int errcode, char * cmdname, value arg) Noreturn; #endif -#ifdef HAVE_LIBLZMA -#include - -static void pxzcat (value filenamev, value outputfilev, unsigned nr_threads); +#if defined (HAVE_LIBLZMA) && \ + defined (HAVE_LZMA_INDEX_STREAM_FLAGS) && \ + defined (HAVE_LZMA_INDEX_STREAM_PADDING) +#define PARALLEL_XZCAT 1 +#else +#define PARALLEL_XZCAT 0 #endif +#if PARALLEL_XZCAT +static void pxzcat (value filenamev, value outputfilev, unsigned nr_threads); +#endif /* PARALLEL_XZCAT */ + value virt_builder_pxzcat (value inputfilev, value outputfilev) { CAMLparam2 (inputfilev, outputfilev); -#ifdef HAVE_LIBLZMA +#if PARALLEL_XZCAT /* Parallel implementation of xzcat (pxzcat). */ /* XXX Make number of threads configurable? */ @@ -73,7 +83,7 @@ virt_builder_pxzcat (value inputfilev, value outputfilev) */ pxzcat (inputfilev, outputfilev, nr_threads); -#else +#else /* !PARALLEL_XZCAT */ /* Fallback: use regular xzcat. */ int fd; @@ -105,12 +115,12 @@ virt_builder_pxzcat (value inputfilev, value outputfilev) if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) caml_failwith (XZCAT " program failed, see earlier error messages"); -#endif +#endif /* !PARALLEL_XZCAT */ CAMLreturn (Val_unit); } -#ifdef HAVE_LIBLZMA +#if PARALLEL_XZCAT #define DEBUG 0 @@ -649,4 +659,4 @@ worker_thread (void *vp) return &state->status; } -#endif /* HAVE_LIBLZMA */ +#endif /* PARALLEL_XZCAT */ diff --git a/configure.ac b/configure.ac index 5b13c1d9c..7e1c06812 100644 --- a/configure.ac +++ b/configure.ac @@ -677,10 +677,16 @@ test "x$XZCAT" = "xno" && AC_MSG_ERROR([xzcat must be installed]) AC_DEFINE_UNQUOTED([XZCAT],["$XZCAT"],[Name of xzcat program.]) dnl liblzma can be used by virt-builder (optional). -PKG_CHECK_MODULES([LIBLZMA], [liblzma],[ +PKG_CHECK_MODULES([LIBLZMA], [liblzma], [ AC_SUBST([LIBLZMA_CFLAGS]) AC_SUBST([LIBLZMA_LIBS]) AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.]) + + dnl Old lzma in RHEL 6 didn't have some APIs we need. + old_LIBS="$LIBS" + LIBS="$LIBS $LIBLZMA_LIBS" + AC_CHECK_FUNCS([lzma_index_stream_flags lzma_index_stream_padding]) + LIBS="$old_LIBS" ], [AC_MSG_WARN([liblzma not found, virt-builder will be slower])])