From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, mreitz@redhat.com, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH] block: Clean up bdrv_img_create()'s error reporting
Date: Tue, 16 Oct 2018 14:39:07 +0200 [thread overview]
Message-ID: <20181016123907.GF5620@dhcp-200-186.str.redhat.com> (raw)
In-Reply-To: <20181016064141.32167-1-armbru@redhat.com>
Am 16.10.2018 um 08:41 hat Markus Armbruster geschrieben:
> bdrv_img_create() takes an Error ** argument and used it in the
> conventional way, except for one place: when qemu_opts_do_parse()
> fails, it first reports its error to stderr or the HMP monitor with
> error_report_err(), then error_setg()'s a generic error. When the
> caller reports that second error similarly, this produces two
> consecutive error messages on stderr or the HMP monitor. When the
> caller does something else with it, such as send it via QMP, the first
> error still goes to stderr or the HMP monitor. Not good.
>
> Turn the first message into a prefix for the second.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>
> This is RFC because I didn't check whether "caller does something else
> with it" can actually happen with current code, and I'm not sure the
> prefix is wanted. I hope we'll answer both questions during review.
The only caller that passes non-NULL options and can therefore even run
into this error path is qemu-img.c. It passes any Error it receives to
error_reportf_err().
Current behaviour:
$ ./qemu-img create -f qcow2 -o foo=bar /tmp/test.qcow2 64M
qemu-img: Invalid parameter 'foo'
qemu-img: /tmp/test.qcow2: Invalid options for file format 'qcow2'
Assumed behaviour with your patch (can't test because I don't have
error_propagate_prepend() yet and its addition is not a separate patch):
$ ./qemu-img create -f qcow2 -o foo=bar /tmp/test.qcow2 64M
qemu-img: /tmp/test.qcow2: Invalid options for file format 'qcow2': Invalid parameter 'foo'
Combining two redundant messages into a single line is nice. Keeping
the redundant information in it ('invalid options'/'invalid parameter')
isn't perfect, though.
If instead of prepending, we just propagate the error, would this
actually lack any important information?
$ ./qemu-img create -f qcow2 -o foo=bar /tmp/test.qcow2 64M
qemu-img: /tmp/test.qcow2: Invalid parameter 'foo'
Kevin
next prev parent reply other threads:[~2018-10-16 12:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 6:41 [Qemu-devel] [RFC PATCH] block: Clean up bdrv_img_create()'s error reporting Markus Armbruster
2018-10-16 12:39 ` Kevin Wolf [this message]
2018-10-16 15:40 ` Markus Armbruster
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=20181016123907.GF5620@dhcp-200-186.str.redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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).