[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] qemu-nbd: only send a limited number of errn
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2] qemu-nbd: only send a limited number of errno codes on the wire |
Date: |
Fri, 08 May 2015 06:40:35 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
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?
But I can also live with it as is;
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature