From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCF0y-0006WM-03 for qemu-devel@nongnu.org; Mon, 26 Mar 2012 14:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCF0w-0004ny-1u for qemu-devel@nongnu.org; Mon, 26 Mar 2012 14:51:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCF0v-0004ng-Pw for qemu-devel@nongnu.org; Mon, 26 Mar 2012 14:51:33 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2QIpVvX016400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 26 Mar 2012 14:51:31 -0400 Date: Mon, 26 Mar 2012 20:51:25 +0200 From: Alon Levy Message-ID: <20120326185125.GI32389@garlic> References: <1331765714-26209-1-git-send-email-alevy@redhat.com> <1332095353-19120-1-git-send-email-alevy@redhat.com> <1332095353-19120-2-git-send-email-alevy@redhat.com> <20120323112125.54f4d663@doriath.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120323112125.54f4d663@doriath.home> Subject: Re: [Qemu-devel] [PATCH v3 1/5] qerror: add error codes for fopen failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel@nongnu.org On Fri, Mar 23, 2012 at 11:21:25AM -0300, Luiz Capitulino wrote: > On Sun, 18 Mar 2012 19:29:09 +0100 > Alon Levy wrote: > > > Added: > > > > QERR_EINTR > > QERR_EACCES > > QERR_EEXIST > > QERR_OPEN_FILE_EMFILE > > QERR_ENOSPC > > QERR_EPERM > > QERR_READ_ONLY > > QERR_ENOTDIR > > QERR_EFBIG > > > > Signed-off-by: Alon Levy > > --- > > qerror.c | 36 ++++++++++++++++++++++++++++++++++++ > > qerror.h | 27 +++++++++++++++++++++++++++ > > 2 files changed, 63 insertions(+) > > > > diff --git a/qerror.c b/qerror.c > > index f55d435..4915939 100644 > > --- a/qerror.c > > +++ b/qerror.c > > @@ -213,6 +213,42 @@ static const QErrorStringTable qerror_table[] = { > > .desc = "Could not open '%(filename)'", > > }, > > { > > + .error_fmt = QERR_EINTR, > > + .desc = "Interrupted open of '%(filename)'", > > + }, > > There are two problems here. First, the QERR_INTR macro doesn't have the > filename argument, so this will crash. > > The second problem is that, I've talked to Anthony and EINTR should not > be returned to clients, it should be handled intead. So, please handle it > during write(). >>From a brief due dilligence (git grep -A10 fopen | grep EINTR | wc -l == 0) I gather that no one ever checks EINTR after fopen, so I'm going to avoid the complexity of possibly blocking in qemu_fopen_err and just note in the qapi-schema wherever an qemu_fopen_err derived error might be returned that the generic OpenFileFailed could indicate an EINTR. I think it will at least be easier to fix it later in a single location, that is at qemu_fopen_err, in a later patch. > > > + { > > + .error_fmt = QERR_EACCES, > > + .desc = "Cannot access file'", > > + }, > > We already have QERR_PERMISSION_DENIED. > > > + { > > + .error_fmt = QERR_EEXIST, > > + .desc = "File already exists'", > > + }, > > Can you use the description provided by man 3 errno? This is valid for all > errors you're adding. > > > + { > > + .error_fmt = QERR_OPEN_FILE_EMFILE, > > + .desc = "Max open files when opening file'", > > + }, > > + { > > + .error_fmt = QERR_ENOSPC, > > + .desc = "No space left opening file'", > > + }, > > + { > > + .error_fmt = QERR_EPERM, > > + .desc = "Permission denied (EPERM) opening file'", > > + }, > > + { > > + .error_fmt = QERR_READ_ONLY, > > + .desc = "Read only filesystem opening file'", > > + }, > > + { > > + .error_fmt = QERR_ENOTDIR, > > + .desc = "Directory related error opening file'", > > + }, > > + { > > + .error_fmt = QERR_EFBIG, > > + .desc = "File too big opening'", > > + }, > > + { > > .error_fmt = QERR_PERMISSION_DENIED, > > .desc = "Insufficient permission to perform this operation", > > }, > > diff --git a/qerror.h b/qerror.h > > index e26c635..ddc04e8 100644 > > --- a/qerror.h > > +++ b/qerror.h > > @@ -181,6 +181,33 @@ QError *qobject_to_qerror(const QObject *obj); > > #define QERR_OPEN_FILE_FAILED \ > > "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }" > > > > +#define QERR_OPEN_FILE_EMFILE \ > > + "{ 'class': 'OpenFileEMFILE', 'data': {} }" > > + > > +#define QERR_EINTR \ > > + "{ 'class': 'EINTR', 'data': {} }" > > + > > +#define QERR_EACCES \ > > + "{ 'class': 'EACCES', 'data': {} }" > > + > > +#define QERR_EEXIST \ > > + "{ 'class': 'EEXIST', 'data': {} }" > > We use more descriptive names instead of using the errno name. Like AlreadyExists. > Please fix it for errors you adding. > > > + > > +#define QERR_ENOSPC \ > > + "{ 'class': 'ENOSPC', 'data': {} }" > > + > > +#define QERR_EPERM \ > > + "{ 'class': 'EPERM', 'data': {} }" > > + > > +#define QERR_READ_ONLY \ > > + "{ 'class': 'ReadOnly', 'data': {} }" > > + > > +#define QERR_ENOTDIR \ > > + "{ 'class': 'ENOTDIR', 'data': {} }" > > + > > +#define QERR_EFBIG \ > > + "{ 'class': 'EFBIG', 'data': {} }" > > + > > #define QERR_PERMISSION_DENIED \ > > "{ 'class': 'PermissionDenied', 'data': {} }" > > > >