qemu-devel
[Top][All Lists]
Advanced

[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: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2] qemu-nbd: only send a limited number of errno codes on the wire
Date: Fri, 08 May 2015 14:41:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0


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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]