From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqhbT-0003fL-Ai for qemu-devel@nongnu.org; Fri, 08 May 2015 08:42:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqhbM-0007ZF-Rg for qemu-devel@nongnu.org; Fri, 08 May 2015 08:42:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqhbM-0007ZB-Mm for qemu-devel@nongnu.org; Fri, 08 May 2015 08:42:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 57B498E67C for ; Fri, 8 May 2015 12:42:00 +0000 (UTC) Message-ID: <554CAF13.4030000@redhat.com> Date: Fri, 08 May 2015 14:41:55 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1431078628-7856-1-git-send-email-pbonzini@redhat.com> <554CAEC3.5030705@redhat.com> In-Reply-To: <554CAEC3.5030705@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] qemu-nbd: only send a limited number of errno codes on the wire List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, mreitz@redhat.com On 08/05/2015 14:40, Eric Blake wrote: > On 05/08/2015 03:50 AM, Paolo Bonzini wrote: >> Right now, NBD includes potentially platform-specific error values in >> the wire protocol. >> >> Luckily, most common error values are more or less universal: in >> particular, of all errno values <= 34 (up to ERANGE), they are all the >> same on supported platforms except for 11 (which is EAGAIN on Windows and >> Linux, but EDEADLK on Darwin and the *BSDs). So, in order to guarantee >> some portability, only keep a handful of possible error codes and squash >> everything else to EINVAL. >> > >> +static int system_errno_to_nbd_errno(int err) >> +{ >> + switch (err) { >> + case EPERM: >> + return NBD_EPERM; >> + case EIO: >> + return NBD_EIO; >> + case ENOMEM: >> + return NBD_ENOMEM; >> +#ifdef EDQUOT >> + case EDQUOT: >> +#endif >> + case EFBIG: >> + case ENOSPC: >> + return NBD_ENOSPC; >> + case EINVAL: >> + default: >> + return NBD_EINVAL; >> + } > > Do we also want to handle "case 0: return 0;" on either conversion, or > even "case 0: abort();" to ensure that callers are using these helpers > correctly? Yes, it's much better that way. Paolo