qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Hrdina <phrdina@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 01/11] qemu-img: introduce qemu_img_handle_error()
Date: Thu, 18 Apr 2013 15:09:27 +0200	[thread overview]
Message-ID: <516FF087.3070603@redhat.com> (raw)
In-Reply-To: <20130418125912.GE2723@dhcp-200-207.str.redhat.com>

On 18.4.2013 14:59, Kevin Wolf wrote:
> Am 18.04.2013 um 13:52 hat Pavel Hrdina geschrieben:
>> On 18.4.2013 13:44, Kevin Wolf wrote:
>>> Am 16.04.2013 um 18:05 hat Pavel Hrdina geschrieben:
>>>> Later in the patch series we will use this function few times.
>>>> This will avoid of duplicating the code.
>>>>
>>>> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>>>> ---
>>>>   qemu-img.c | 17 +++++++++++------
>>>>   1 file changed, 11 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/qemu-img.c b/qemu-img.c
>>>> index 31627b0..dbacdb7 100644
>>>> --- a/qemu-img.c
>>>> +++ b/qemu-img.c
>>>> @@ -322,6 +322,16 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list,
>>>>       return 0;
>>>>   }
>>>>
>>>> +static int qemu_img_handle_error(const char *msg, Error *err)
>>>> +{
>>>> +    if (error_is_set(&err)) {
>>>> +        error_report("%s: %s", msg, error_get_pretty(err));
>>>> +        error_free(err);
>>>> +        return 1;
>>>> +    }
>>>> +    return 0;
>>>> +}
>>>> +
>>>>   static int img_create(int argc, char **argv)
>>>>   {
>>>>       int c;
>>>> @@ -400,13 +410,8 @@ static int img_create(int argc, char **argv)
>>>>
>>>>       bdrv_img_create(filename, fmt, base_filename, base_fmt,
>>>>                       options, img_size, BDRV_O_FLAGS, &local_err, quiet);
>>>> -    if (error_is_set(&local_err)) {
>>>> -        error_report("%s", error_get_pretty(local_err));
>>>> -        error_free(local_err);
>>>> -        return 1;
>>>> -    }
>>>>
>>>> -    return 0;
>>>> +    return qemu_img_handle_error("qemu-img create failed", local_err);
>>>>   }
>>>
>>> This makes a change to the error message that isn't mentioned in the
>>> commit message. It should definitely be mentioned there, but I'm not
>>> even sure if it's a good change. Today you get something like:
>>>
>>>      $ qemu-img create -f foo test.img
>>>      qemu-img: Unknown file format 'foo'
>>>
>>> With the patch applied it becomes:
>>>
>>>      $ qemu-img create -f foo test.img
>>>      qemu-img: qemu-img create failed: Unknown file format 'foo'
>>>
>>> Does this add any useful information or does it just make the error
>>> message longer? I feel it's the latter.
>>>
>>> Kevin
>>>
>>
>> Thanks for pointing this out, it should be
>> qemu_img_handle_error("create failed", local_err);
>>
>> and later in patch series also
>> qemu_img_handle_error("snapshot create failed", local_err);
>>
>> Is that OK after this change?
>
> I would in fact leave the error message as it is today. The "create
> failed" doesn't help me understand the error better. I already know that
> it's a create command that failed, because it was me who called 'qemu-img
> create'.
>
> Kevin
>

Yes that's true and make sense, but what if another tool internally uses 
the qemu-img command? I know that the tool could print/return/whatever 
proper error message, but qemu-img could help with that printing more 
information.

Pavel

  reply	other threads:[~2013-04-18 13:09 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16 16:05 [Qemu-devel] [PATCH 00/11] covert savevm, loadvm and delvm into qapi Pavel Hrdina
2013-04-16 16:05 ` [Qemu-devel] [PATCH 01/11] qemu-img: introduce qemu_img_handle_error() Pavel Hrdina
2013-04-16 16:46   ` Eric Blake
2013-04-18 11:44   ` Kevin Wolf
2013-04-18 11:52     ` Pavel Hrdina
2013-04-18 12:59       ` Kevin Wolf
2013-04-18 13:09         ` Pavel Hrdina [this message]
2013-04-18 15:23           ` Luiz Capitulino
2013-04-16 16:05 ` [Qemu-devel] [PATCH 02/11] block: update error reporting for bdrv_snapshot_delete() and related functions Pavel Hrdina
2013-04-16 17:14   ` Eric Blake
2013-04-18 12:55   ` Kevin Wolf
2013-04-18 13:09     ` Eric Blake
2013-04-18 13:51       ` Kevin Wolf
2013-04-18 13:19     ` Pavel Hrdina
2013-04-18 13:41       ` Kevin Wolf
2013-04-16 16:05 ` [Qemu-devel] [PATCH 03/11] savevm: update bdrv_snapshot_find() to find snapshot by id or name Pavel Hrdina
2013-04-16 17:34   ` Eric Blake
2013-04-18 13:17   ` Kevin Wolf
2013-04-16 16:05 ` [Qemu-devel] [PATCH 04/11] qapi: Convert delvm Pavel Hrdina
2013-04-16 19:39   ` Eric Blake
2013-04-18 13:28   ` Kevin Wolf
2013-04-16 16:05 ` [Qemu-devel] [PATCH 05/11] block: update error reporting for bdrv_snapshot_goto() and related functions Pavel Hrdina
2013-04-16 20:48   ` Eric Blake
2013-04-23 14:08   ` Kevin Wolf
2013-04-16 16:05 ` [Qemu-devel] [PATCH 06/11] savevm: update error reporting for qemu_loadvm_state() Pavel Hrdina
2013-04-16 21:42   ` Eric Blake
2013-04-16 16:05 ` [Qemu-devel] [PATCH 07/11] qapi: Convert loadvm Pavel Hrdina
2013-04-16 23:43   ` Eric Blake
2013-04-18 10:34     ` Pavel Hrdina
2013-04-16 16:05 ` [Qemu-devel] [PATCH 08/11] block: update error reporting for bdrv_snapshot_create() and related functions Pavel Hrdina
2013-04-16 23:54   ` Eric Blake
2013-04-16 16:05 ` [Qemu-devel] [PATCH 09/11] savevm: update error reporting off qemu_savevm_state() " Pavel Hrdina
2013-04-17  0:02   ` Eric Blake
2013-04-16 16:05 ` [Qemu-devel] [PATCH 10/11] qapi: Convert savevm Pavel Hrdina
2013-04-16 16:05 ` [Qemu-devel] [PATCH 11/11] savevm: remove backward compatibility from bdrv_snapshot_find() Pavel Hrdina
2013-04-17  2:53   ` Wenchao Xia
2013-04-17  7:52     ` Pavel Hrdina
2013-04-17 10:19       ` Wenchao Xia
2013-04-17 10:51         ` Pavel Hrdina
2013-04-17 18:14           ` Eric Blake
2013-04-17 18:22             ` Eric Blake
2013-04-18  4:31             ` Wenchao Xia
2013-04-18  7:20               ` Wenchao Xia
2013-04-18 10:22               ` Pavel Hrdina
2013-04-19  0:28                 ` Wenchao Xia
2013-04-24  3:51                   ` Wenchao Xia
2013-04-24  9:37                     ` Pavel Hrdina
2013-04-16 16:33 ` [Qemu-devel] [PATCH 00/11] covert savevm, loadvm and delvm into qapi Eric Blake

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=516FF087.3070603@redhat.com \
    --to=phrdina@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --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 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).