From: Luiz Capitulino <lcapitulino@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string()
Date: Thu, 22 Apr 2010 10:44:13 -0300 [thread overview]
Message-ID: <20100422104413.63635d9d@redhat.com> (raw)
In-Reply-To: <m34oj4raoj.fsf@blackfin.pond.sub.org>
On Wed, 21 Apr 2010 19:13:16 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> "Daniel P. Berrange" <berrange@redhat.com> writes:
>
> > On Wed, Apr 21, 2010 at 12:12:14PM -0300, Luiz Capitulino wrote:
> >> On Wed, 21 Apr 2010 18:42:38 +0400 (MSD)
> >> malc <av1474@comtv.ru> wrote:
> >>
> >> > On Wed, 21 Apr 2010, Kevin Wolf wrote:
> >> >
> >> > > Am 21.04.2010 10:28, schrieb Daniel P. Berrange:
> >> > > > On Tue, Apr 20, 2010 at 06:09:37PM -0300, Luiz Capitulino wrote:
> >> > > >> There are error handling functions in QEMU which print errno codes
> >> > > >> to the user. While it's debatable if this is good from a user
> >> > > >> perspective, sometimes it's the best you can do because it's what
> >> > > >> system calls return and this is also useful for debugging.
> >> > > >>
> >> > > >> So, we need a way to expose those codes in QMP. We can't use the
> >> > > >> codes themselfs because they may vary between systems.
> >> > > >>
> >> > > >> The best solution I can think of is returning the string
> >> > > >> representation of the name. For example, EIO becomes "EIO".
> >> > > >>
> >> > > >> This is what get_errno_string() does.
> >> > > >>
> >> > > >> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> >> > > >> ---
> >> > > >> qemu-error.c | 25 +++++++++++++++++++++++++
> >> > > >> qemu-error.h | 1 +
> >> > > >> 2 files changed, 26 insertions(+), 0 deletions(-)
> >> > > >>
> >> > > >> diff --git a/qemu-error.c b/qemu-error.c
> >> > > >> index 5a35e7c..55ce133 100644
> >> > > >> --- a/qemu-error.c
> >> > > >> +++ b/qemu-error.c
> >> > > >> @@ -207,3 +207,28 @@ void error_report(const char *fmt, ...)
> >> > > >> va_end(ap);
> >> > > >> error_printf("\n");
> >> > > >> }
> >> > > >> +
> >> > > >> +/*
> >> > > >> + * This is probably only useful for QMP
> >> > > >> + */
> >> > > >> +const char *get_errno_string(int err)
> >> > > >> +{
> >> > > >> + assert(err < 0);
> >> > > >> +
> >> > > >> + switch (err) {
> >> > > >> + case -EINVAL:
> >> > > >> + return "EINVAL";
> >> > > >> + case -EIO:
> >> > > >> + return "EIO";
> >> > > >> + case -ENOENT:
> >> > > >> + return "ENOENT";
> >> > > >> + case -ENOMEDIUM:
> >> > > >> + return "ENOMEDIUM";
> >> > > >> + case -ENOTSUP:
> >> > > >> + return "ENOTSUP";
> >> > > >> + default:
> >> > > >> + return "unknown";
> >> > > >> + }
> >> > > >> +
> >> > > >> + abort();
> >> > > >> +}
> >> > > >
> >> > > > Wouldn't it be nicer to return strerror_r() output instead of errno
> >> > > > names ?
> >> > >
> >> > > I agree. And it would be more complete, too.
> >> >
> >> > OTOH it has a problem of returning translated messages (subject to
> >> > LC_MESSAGES value).
> >>
> >> Exactly, and I'm not sure if there's anything that ensure they're
> >> exactly the same among different systems.
> >
> > I thought QMP already declared that the printable error strings are subject
> > to arbitrary change at any time, which includes translation? Apps needing
> > something reliable should be hooking onto the error code.
>
> Yes, but the value of get_errno_string() is put into the error's data
> object, where the "client should not attempt to parse this" clause does
> not apply.
>
> We need to decide whether clients need to know the errno or not.
>
> If they do, we need to encode errno in a way that doesn't depend on
> QEMU's host system. The encoding proposed by Luiz is as good as any, I
> think.
>
> If they don't, then substituting text obtained from strerror_r() into
> desc is the way to go. There's currently no way to do that without
> putting something it the error's data object, so that would need fixing.
> Simple: don't send members whose names start with '_' across the wire.
That's even better indeed, actually we could do both: put the errno
in the data object _and_ the strerror_r() text in desc.
next prev parent reply other threads:[~2010-04-22 13:44 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-20 21:09 [Qemu-devel] [RFC 00/22]: QMP: Convert savevm/loadvm/delvm Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 01/22] QMP: Introduce RESUME event Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 02/22] savevm: Don't check the return of qemu_fopen_bdrv() Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 03/22] savevm: Introduce delete_snapshot() and use it Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 04/22] savevm: do_loadvm(): Always resume the VM Luiz Capitulino
2010-04-20 21:28 ` [Qemu-devel] " Juan Quintela
2010-04-20 21:59 ` Luiz Capitulino
2010-04-21 8:36 ` Juan Quintela
2010-04-21 14:54 ` Luiz Capitulino
2010-04-21 15:39 ` Juan Quintela
2010-04-21 15:42 ` Kevin Wolf
2010-04-22 13:33 ` Luiz Capitulino
2010-04-21 13:28 ` Kevin Wolf
2010-04-21 15:08 ` Luiz Capitulino
2010-04-21 15:27 ` Kevin Wolf
2010-04-21 15:47 ` Juan Quintela
2010-04-21 15:45 ` Juan Quintela
2010-04-21 17:50 ` Jamie Lokier
2010-04-20 21:09 ` [Qemu-devel] [PATCH 05/22] savevm: load_vmstate(): Return 'ret' on error Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 06/22] savevm: load_vmstate(): Improve error check Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string() Luiz Capitulino
2010-04-21 8:28 ` Daniel P. Berrange
2010-04-21 13:38 ` Kevin Wolf
2010-04-21 14:42 ` malc
2010-04-21 15:12 ` Luiz Capitulino
2010-04-21 15:15 ` Daniel P. Berrange
2010-04-21 15:29 ` Luiz Capitulino
2010-04-21 17:13 ` Markus Armbruster
2010-04-22 13:44 ` Luiz Capitulino [this message]
2010-05-03 18:00 ` Anthony Liguori
2010-05-10 17:50 ` Markus Armbruster
2010-05-11 22:36 ` Jamie Lokier
2010-04-20 21:09 ` [Qemu-devel] [PATCH 08/22] QError: New QERR_SNAPSHOT_NO_DEVICE Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 09/22] QError: New QERR_SNAPSHOT_DELETE_FAILED Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 10/22] QError: New QERR_SNAPSHOT_CREATE_FAILED Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 11/22] QError: New QERR_SNAPSHOT_ACTIVATE_FAILED Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 12/22] QError: New QERR_STATEVM_SAVE_FAILED Luiz Capitulino
2010-04-20 21:31 ` [Qemu-devel] " Juan Quintela
2010-04-20 22:02 ` Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 13/22] QError: New QERR_STATEVM_LOAD_FAILED Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 14/22] QError: New QERR_DEVICE_NO_SNAPSHOT Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 15/22] QError: New QERR_SNAPSHOT_NOT_FOUND Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 16/22] savevm: Convert delete_snapshot() to QError Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 17/22] savevm: delete_snapshot(): Remove unused parameter Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 18/22] savevm: Convert do_delvm() to QObject, QError Luiz Capitulino
2010-04-21 14:18 ` [Qemu-devel] " Kevin Wolf
2010-04-22 13:48 ` Luiz Capitulino
2010-04-22 14:31 ` Kevin Wolf
2010-04-20 21:09 ` [Qemu-devel] [PATCH 19/22] savevm: Convert do_savevm() to QError Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 20/22] savevm: Convert do_savevm() to QObject Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 21/22] savevm: Convert do_loadvm() to QError Luiz Capitulino
2010-04-20 21:09 ` [Qemu-devel] [PATCH 22/22] savevm: Convert do_loadvm() to QObject Luiz Capitulino
2010-04-20 21:41 ` [Qemu-devel] Re: [RFC 00/22]: QMP: Convert savevm/loadvm/delvm Juan Quintela
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=20100422104413.63635d9d@redhat.com \
--to=lcapitulino@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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).