From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yqha7-0001Ym-I1 for qemu-devel@nongnu.org; Fri, 08 May 2015 08:40:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yqha1-0006r3-Lj for qemu-devel@nongnu.org; Fri, 08 May 2015 08:40:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yqha1-0006qg-EA for qemu-devel@nongnu.org; Fri, 08 May 2015 08:40:37 -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 (8.14.4/8.14.4) with ESMTP id t48CeaKl015577 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 8 May 2015 08:40:36 -0400 Message-ID: <554CAEC3.5030705@redhat.com> Date: Fri, 08 May 2015 06:40:35 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431078628-7856-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1431078628-7856-1-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jT6Qaj4j8rqxs9kOr1GKM23GkO0V51uCt" 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: Paolo Bonzini , qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jT6Qaj4j8rqxs9kOr1GKM23GkO0V51uCt Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/08/2015 03:50 AM, Paolo Bonzini wrote: > Right now, NBD includes potentially platform-specific error values in > the wire protocol. >=20 > Luckily, most common error values are more or less universal: in > particular, of all errno values <=3D 34 (up to ERANGE), they are all th= e > same on supported platforms except for 11 (which is EAGAIN on Windows a= nd > Linux, but EDEADLK on Darwin and the *BSDs). So, in order to guarantee= > some portability, only keep a handful of possible error codes and squas= h > everything else to EINVAL. >=20 > +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? But I can also live with it as is; Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jT6Qaj4j8rqxs9kOr1GKM23GkO0V51uCt Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVTK7DAAoJEKeha0olJ0NqZFUIAIeb2QyGzk6DQIPUMXECT4xo m4x7TWGuCeODozxwxi6/Azm4LbbqvqJtZwhpX1Uc+s5uHr9opatE3AREw4FkfUzn z8c6d8boZtjkaRE2fnZsrvkXC6592kNUkvDjjbqR6uHG7P4OpTzN3eg4J5ox4rUr gK2rhQd64POZd+3Q8DGh2Zj4UjdgtcuChan/R0Sg8DvzzE1YXlE2C/zHKnJ1DTOg al7t9YnwuntVaI2AHlArTIogWQC8Kz+7Y4dSd8vi0HXFbS71UkD7qO9p9eCTWENY n4sh47WYQstIhW25IhsvW9Cd0i2OSC5w/Ejz7a6pfKjyuCriQYRxybPcQHURj00= =JzS4 -----END PGP SIGNATURE----- --jT6Qaj4j8rqxs9kOr1GKM23GkO0V51uCt--