From: Paolo Bonzini <pbonzini@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, mreitz@redhat.com
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 [thread overview]
Message-ID: <554CAF13.4030000@redhat.com> (raw)
In-Reply-To: <554CAEC3.5030705@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
next prev parent reply other threads:[~2015-05-08 12:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 9:50 [Qemu-devel] [PATCH v2] qemu-nbd: only send a limited number of errno codes on the wire Paolo Bonzini
2015-05-08 10:12 ` Markus Armbruster
2015-05-08 10:27 ` Paolo Bonzini
2015-05-08 10:40 ` Richard W.M. Jones
2015-05-08 12:35 ` Eric Blake
2015-05-08 12:40 ` Eric Blake
2015-05-08 12:41 ` Paolo Bonzini [this message]
2015-05-08 13:02 ` Eric Blake
2015-05-08 13:04 ` Paolo Bonzini
2015-05-09 14:29 ` Thomas Schwinge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=554CAF13.4030000@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).