aboutsummaryrefslogtreecommitdiff
path: root/util/osdep.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2013-08-22 11:29:03 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2013-09-18 15:34:51 +0200
commita5813077aac7865f69b7ee46a594f3705429f7cd (patch)
tree903e1d953b00ac44f65b6ef88c3d93bac0d26b4b /util/osdep.c
parent975a0015ee380f49a3be744279a6a06ab97e960a (diff)
downloadqemu-a5813077aac7865f69b7ee46a594f3705429f7cd.zip
qemu-a5813077aac7865f69b7ee46a594f3705429f7cd.tar.gz
qemu-a5813077aac7865f69b7ee46a594f3705429f7cd.tar.bz2
osdep: warn if open(O_DIRECT) on fails with EINVAL
Print a warning when opening a file O_DIRECT fails with EINVAL. This saves users a lot of time trying to figure out the EINVAL error, which is typical when attempting to open a file O_DIRECT on Linux tmpfs. Reported-by: Deepak C Shetty <deepakcs@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'util/osdep.c')
-rw-r--r--util/osdep.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/osdep.c b/util/osdep.c
index 685c8ae..62072b4 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -207,6 +207,13 @@ int qemu_open(const char *name, int flags, ...)
}
#endif
+#ifdef O_DIRECT
+ if (ret == -1 && errno == EINVAL && (flags & O_DIRECT)) {
+ error_report("file system may not support O_DIRECT");
+ errno = EINVAL; /* in case it was clobbered */
+ }
+#endif /* O_DIRECT */
+
return ret;
}