From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCRW1-00056u-S3 for qemu-devel@nongnu.org; Thu, 22 Aug 2013 05:49:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCRVu-0006vc-CC for qemu-devel@nongnu.org; Thu, 22 Aug 2013 05:49:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCRVu-0006vN-4c for qemu-devel@nongnu.org; Thu, 22 Aug 2013 05:49:10 -0400 From: Stefan Hajnoczi Date: Thu, 22 Aug 2013 11:29:03 +0200 Message-Id: <1377163743-25029-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1377163743-25029-1-git-send-email-stefanha@redhat.com> References: <1377163743-25029-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] osdep: warn if open(O_DIRECT) on fails with EINVAL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Markus Armbruster , Stefan Hajnoczi , Deepak C Shetty 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 Signed-off-by: Stefan Hajnoczi --- util/osdep.c | 7 +++++++ 1 file changed, 7 insertions(+) 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; } -- 1.8.3.1