From: Anthony Liguori <anthony@codemonkey.ws>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] Ignoring errno makes QMP errors suck
Date: Mon, 26 Mar 2012 11:01:55 -0500 [thread overview]
Message-ID: <4F7092F3.9030200@codemonkey.ws> (raw)
In-Reply-To: <4F709246.6050709@redhat.com>
On 03/26/2012 10:59 AM, Kevin Wolf wrote:
> Am 26.03.2012 17:38, schrieb Anthony Liguori:
>> You can add parameters to Errors in a fully compatible fashion, so just add an
>> filename parameter to PermissionDenied. Problem solved.
>
> So your error types will end up accumulating optional parameters for all
> contexts in which they can occur?
>
> In the long run, PermissionDenied would have an optional file name (for
> raw), optional host name, port, sheepdog volume ID (for sheepdog),
> optional source and destination block devices (for blkmirror), remote
> host and port, local address and port (for UDP chardevs)...
I don't see the generalization.
>
> I could go on forever. Does this really make sense?
What's the alternative proposal? If you just add errno to OPEN_FILE_FAILED,
then you end up with errors for SHEEP_DOG_ATTACH_VOLUME_FAILED,
NBD_CONNECT_FAILED, etc.
The proper way to design an error is to make it a verb, and have parameters that
correspond to the direct object and/or indirect object. The subject is implied
by the command itself.
So in the case of block_snapshot_sync, the failure is:
The block_snapshot_sync command failed due to insufficient permission when
creating foo.img.
So the error is "PERMISSION_DENIED", with the data "filename=foo.img"
In the case of NBD, the error would be:
The block_snapshot_sync command failed because the host localhost:42 could not
be contacted.
The error is "CONNECTION_REFUSED", with the data "hostname=localhost,port=42".
It the block layer returns both of these as EACCESS today, then this is a good
argument to refactor the block layer to take an Error object instead of
overloading the meaning of EACCESS.
Regards,
Anthony Liguori
>
> Kevin
prev parent reply other threads:[~2012-03-26 16:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-26 8:39 [Qemu-devel] Ignoring errno makes QMP errors suck Kevin Wolf
2012-03-26 12:46 ` Luiz Capitulino
2012-03-26 13:13 ` Kevin Wolf
2012-03-26 13:28 ` Luiz Capitulino
2012-03-26 13:39 ` Anthony Liguori
2012-03-26 14:04 ` Kevin Wolf
2012-03-26 14:33 ` Luiz Capitulino
2012-03-26 14:47 ` Kevin Wolf
2012-03-26 14:54 ` Luiz Capitulino
2012-03-26 15:20 ` Kevin Wolf
2012-03-26 13:37 ` Anthony Liguori
2012-03-26 15:08 ` Kevin Wolf
2012-03-26 15:14 ` Anthony Liguori
2012-03-26 15:34 ` Kevin Wolf
2012-03-26 15:38 ` Anthony Liguori
2012-03-26 15:59 ` Kevin Wolf
2012-03-26 16:01 ` Anthony Liguori [this message]
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=4F7092F3.9030200@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=Qemu-devel@nongnu.org \
--cc=kwolf@redhat.com \
--cc=lcapitulino@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 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.