[libvirt PATCH 26/32] src: conditionalize use of O_DIRECT

Daniel P. Berrangé berrange at redhat.com
Mon Jan 27 13:03:24 UTC 2020


On Thu, Jan 23, 2020 at 11:43:19AM +0000, Daniel P. Berrangé wrote:
> The O_DIRECT flag is not available on platforms, so we
> must avoid it once we remove GNULIB.
> 
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>  src/util/virfile.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index d0e0062aa7..617d5d7a48 100644
> --- a/src/util/virfile.c
> +++ b/src/util/virfile.c
> @@ -178,7 +178,11 @@ virFileDirectFdFlag(void)
>  {
>      /* XXX For now, Linux posix_fadvise is not powerful enough to
>       * avoid O_DIRECT.  */
> +#ifdef O_DIRECT
>      return O_DIRECT ? O_DIRECT : -1;
> +#else
> +    return -1;
> +#endif
>  }

This patch is broken, as it misses iohelper. The real
fix needs to be to follow what gnulib does

diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index d864bbeaed..618bfb1d3d 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -39,6 +39,10 @@
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
+#ifndef O_DIRECT
+# define O_DIRECT 0
+#endif
+
 static int
 runIO(const char *path, int fd, int oflags)
 {
diff --git a/src/util/virfile.c b/src/util/virfile.c
index d0e0062aa7..efa59f2b13 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -95,6 +95,10 @@
 
 VIR_LOG_INIT("util.file");
 
+#ifndef O_DIRECT
+# define O_DIRECT 0
+#endif
+
 int virFileClose(int *fdptr, virFileCloseFlags flags)
 {
     int saved_errno = 0;



Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list