From: Markus Armbruster <armbru@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name()
Date: Mon, 10 May 2010 19:36:12 +0200 [thread overview]
Message-ID: <m3wrvbr75f.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <4BDECCB3.9000601@codemonkey.ws> (Anthony Liguori's message of "Mon, 03 May 2010 08:16:35 -0500")
Anthony Liguori <anthony@codemonkey.ws> writes:
> On 05/03/2010 08:06 AM, Markus Armbruster wrote:
>> Luiz Capitulino<lcapitulino@redhat.com> writes:
>>
>>
>>> We need to expose errno in QMP, for three reasons:
>>>
>>> 1. Some error handling functions print errno codes to the user,
>>> while it's debatable whether this is good or not from a user
>>> perspective, sometimes it's the best we can do because it's
>>> what system calls and libraries return
>>>
>>> 2. Some events (eg. BLOCK_IO_ERROR) will be made even more
>>> complete with errno information
>>>
>>> 3. It's very good for debugging
>>>
>>> So, we need a way to expose those codes in QMP. We can't just use
>>> the codes themselfs because they may vary between systems.
>>>
>>> The best solution I can think of is to return the string
>>> representation of the name. For example, EIO becomes "EIO".
>>>
>>> This is what get_errno_name() does.
>>>
>>> Signed-off-by: Luiz Capitulino<lcapitulino@redhat.com>
>>> ---
>>> qemu-error.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> qemu-error.h | 1 +
>>> 2 files changed, 86 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/qemu-error.c b/qemu-error.c
>>> index 5a35e7c..7035417 100644
>>> --- a/qemu-error.c
>>> +++ b/qemu-error.c
>>> @@ -207,3 +207,88 @@ void error_report(const char *fmt, ...)
>>> va_end(ap);
>>> error_printf("\n");
>>> }
>>> +
>>> +/*
>>> + * Probably only useful for QMP
>>> + */
>>> +const char *get_errno_name(int err)
>>> +{
>>> + switch (abs(err)) {
>>> + case EPERM:
>>> + return "EPERM";
>>> + case ENOENT:
>>> + return "ENOENT";
>>>
>> [...]
>>
>>> + case EDOM:
>>> + return "EDOM";
>>> + case ERANGE:
>>> + return "ERANGE";
>>> + case ENOMEDIUM:
>>> + return "ENOMEDIUM";
>>> + case ENOTSUP:
>>> + return "ENOTSUP";
>>> + default:
>>> + return "unknown";
>>>
>> How did you choose the codes to implement? POSIX has many more...
>>
>
> Let me say another way why I think this is a bad path to go down.
>
> In generally, we could never just pass errno through down. Different
> host platforms are going to generate different errno values so we
> really need to filter and send reliable errno values so that clients
> don't have to have special code for when they're on Linux vs. AIX
> vs. Solaris.
Most instances are covered by POSIX. The best way to deal with systems
that violate POSIX is to provide conforming replacements for the
offenders. See gnulib (I just wish it wasn't joined at the hip to
automake).
> If we're white listing errno values, we should be able to trivially
> convert errnos to QError types via a table just like you have above.
Yes, but you'll get many tables.
Luiz encodes the information as event name + errno for events, and as
error class + errno for errors.
The same errno can mean different things for different events / errors.
Thus, if you flatten the two into a single error, you need in the order
of one table per event / error.
next prev parent reply other threads:[~2010-05-10 17:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-28 20:32 [Qemu-devel] [PATCH 0/2]: QMP: expose errno in the BLOCK_IO_ERROR event Luiz Capitulino
2010-04-28 20:32 ` [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name() Luiz Capitulino
2010-05-03 13:06 ` Markus Armbruster
2010-05-03 13:16 ` Anthony Liguori
2010-05-04 13:56 ` Luiz Capitulino
2010-05-04 14:03 ` Anthony Liguori
2010-05-04 20:30 ` Luiz Capitulino
2010-05-04 21:56 ` Anthony Liguori
2010-05-05 15:00 ` Luiz Capitulino
2010-05-10 17:45 ` Markus Armbruster
2010-05-10 17:36 ` Markus Armbruster [this message]
2010-04-28 20:32 ` [Qemu-devel] [PATCH 2/2] QMP: Add 'reason' member to the BLOCK_IO_ERROR event Luiz Capitulino
2010-04-28 23:24 ` Anthony Liguori
2010-04-29 17:30 ` Luiz Capitulino
2010-05-03 13:14 ` Anthony Liguori
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=m3wrvbr75f.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=lcapitulino@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.