From: Kevin Wolf <kwolf@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
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 17:59:02 +0200 [thread overview]
Message-ID: <4F709246.6050709@redhat.com> (raw)
In-Reply-To: <4F708D66.9010509@codemonkey.ws>
Am 26.03.2012 17:38, schrieb Anthony Liguori:
> On 03/26/2012 10:34 AM, Kevin Wolf wrote:
>> Am 26.03.2012 17:14, schrieb Anthony Liguori:
>>> On 03/26/2012 10:08 AM, Kevin Wolf wrote:
>>>> Am 26.03.2012 15:37, schrieb Anthony Liguori:
>>>>> On 03/26/2012 03:39 AM, Kevin Wolf wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I keep getting reports of problems, with nice error descriptions that
>>>>>> usually look very similar to what I produced here:
>>>>>>
>>>>>> {"execute":"blockdev-snapshot-sync","arguments":{"device":"ide0-hd0","snapshot-file":"/tmp/backing.qcow2"}}
>>>>>> {"error": {"class": "OpenFileFailed", "desc": "Could not open
>>>>>> '/tmp/backing.qcow2'", "data": {"filename": "/tmp/backing.qcow2"}}}
>>>>>
>>>>> This is not QMP's fault. This is the block layers. Specifically, you're missing:
>>>>>
>>>>> diff --git a/blockdev.c b/blockdev.c
>>>>> index 1a500b8..04c3a39 100644
>>>>> --- a/blockdev.c
>>>>> +++ b/blockdev.c
>>>>> @@ -777,7 +777,11 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **
>>>>> states->old_bs->drv->format_name,
>>>>> NULL, -1, flags);
>>>>> if (ret) {
>>>>> - error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
>>>>> + if (ret == -EPERM) {
>>>>> + error_set(errp, QERR_PERMISSION_DENIED);
>>>>> + } else {
>>>>> + error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
>>>>> + }
>>>>> goto delete_and_fail;
>>>>> }
>>>>> }
>>>>>
>>>>> Which is handling:
>>>>>
>>>>> ret = bdrv_img_create(new_image_file, format,
>>>>> states->old_bs->filename,
>>>>> states->old_bs->drv->format_name,
>>>>> NULL, -1, flags);
>>>>
>>>> It really should be something like this:
>>>>
>>>> - error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
>>>> + error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file, -ret);
>>>>
>>>> And QERR_OPEN_FILE_FAILED would contain a conversion specifier for
>>>> errnos in qobject_from_jsonv().
>>>
>>> No, it really shouldn't be.
>>>
>>> Errors are verbs, not knows, you're treating the error as a noun "the operation
>>> open file" and looking to use errno as the verb. This is wrong. The noun is
>>> implied in the operation.
>>>
>>> You could use error_set_from_errno(errp, -ret) which doesn't exist, but could.
>>> But errno on it's own lacks a lot of useful information so I wouldn't suggest
>>> always using such a function.
>>
>> I couldn't care less about nouns and verbs and stuff.
>>
>> I want to transfer the information that a "permission denied" error has
>> happened and on which file it has happened. The existing OpenFileFailed
>> error doesn't allow to specify that the missing permission was the
>> problem, and a hypothetical PermissionDenied error wouldn't allow me to
>> specify the file name because it would be too generic.
>>
>> This is my problem, and nothing else.
>
> Then extend PermissionDenied to include a filename. Problem solved.
> 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 could go on forever. Does this really make sense?
Kevin
next prev parent reply other threads:[~2012-03-26 15:55 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 [this message]
2012-03-26 16:01 ` 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=4F709246.6050709@redhat.com \
--to=kwolf@redhat.com \
--cc=Qemu-devel@nongnu.org \
--cc=anthony@codemonkey.ws \
--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 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).