]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
build: fix build on RHEL 5
authorEric Blake <eblake@redhat.com>
Fri, 4 Oct 2013 23:25:13 +0000 (17:25 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 4 Oct 2013 23:33:37 +0000 (17:33 -0600)
On RHEL 5, compilation fails with:

storage/storage_backend.c: In function 'createRawFile':
storage/storage_backend.c:339: warning: implicit declaration of function 'fallocate'
storage/storage_backend.c:339: warning: nested extern declaration of 'fallocate' [-Wnested-externs]

But:

$ grep HAVE_FALLOCATE config.h
/* #undef HAVE_FALLOCATE */

Huh? It turns out that in kernels that old, fallocate() is not
implemented (config.h is correct), but <linux/fs.h> defines
HAVE_FALLOCATE as an empty witness macro for a completely
different purpose.  Since storage_backend.c is including
<linux/fs.h> on RHEL 5, we are hosed by the kernel definition.
Newer kernels no longer pollute the namespace, and it's fairly
easy to convert to an expression that works with both the old
kernel witness and the new-style config.h (undefined or 1).

Problem introduced in commit 532fef3.

* src/storage/storage_backend.c (createRawFile): Avoid namespace
pollution from kernel, by checking HAVE_FALLOCATE for a value.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/storage/storage_backend.c

index 5f1bc669719815f7adc27914302c8813fa6dc39e..662af3266f8ae7e4ba4634cac972776aacbb4378 100644 (file)
@@ -329,7 +329,8 @@ createRawFile(int fd, virStorageVolDefPtr vol,
         goto cleanup;
     }
 
-#ifdef HAVE_FALLOCATE
+/* Avoid issues with older kernel's <linux/fs.h> namespace pollution. */
+#if HAVE_FALLOCATE - 0
     /* Try to preallocate all requested disk space, but fall back to
      * other methods if this fails with ENOSYS or EOPNOTSUPP.
      * NOTE: do not use posix_fallocate; posix_fallocate falls back