[libvirt] [PATCH 2/1] build: work with older RHEL 5 kernel

Eric Blake eblake at redhat.com
Tue Aug 21 17:17:20 UTC 2012


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




More information about the libvir-list mailing list