From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMHhd-0001a6-7I for qemu-devel@nongnu.org; Wed, 18 Sep 2013 09:22:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMHhU-0002qB-Q1 for qemu-devel@nongnu.org; Wed, 18 Sep 2013 09:21:57 -0400 Received: from mail-ea0-x235.google.com ([2a00:1450:4013:c01::235]:65506) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMHhU-0002q4-Hn for qemu-devel@nongnu.org; Wed, 18 Sep 2013 09:21:48 -0400 Received: by mail-ea0-f181.google.com with SMTP id d10so3451551eaj.40 for ; Wed, 18 Sep 2013 06:21:47 -0700 (PDT) Date: Wed, 18 Sep 2013 15:21:43 +0200 From: Stefan Hajnoczi Message-ID: <20130918132143.GA25444@stefanha-thinkpad.redhat.com> References: <1377163743-25029-1-git-send-email-stefanha@redhat.com> <1377163743-25029-3-git-send-email-stefanha@redhat.com> <20130906203243.GA16486@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130906203243.GA16486@localhost.localdomain> Subject: Re: [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: Jeff Cody Cc: Kevin Wolf , Deepak C Shetty , qemu-devel@nongnu.org, Stefan Hajnoczi , Markus Armbruster On Fri, Sep 06, 2013 at 04:32:43PM -0400, Jeff Cody wrote: > On Thu, Aug 22, 2013 at 11:29:03AM +0200, Stefan Hajnoczi wrote: > > 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 > > > > > > What about putting something similar in error_setg_file_open(), in > util/error.c? There are other occasions when O_DIRECT causes a file > open to fail (e.g. live snapshots with 'cache=none' to a tmpfs > filesystem). That would give additional info then for QMP commands. > Of course, it would then be necessary to also pass the open flags (or > other equivalent info) to error_setg_file_open(). It would be nice to cover all file open cases. But I think error_setg_file_open() is a bit beyond the scope here. error_setg_file_open() is not used in cases where O_DIRECT is relevant. I checked all callers and they don't seem to allow O_DIRECT. Some of them even use qemu_fopen(). Stefan