qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, kraxel@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 04/13] qemu-img: Suppress unhelpful extra errors in convert, resize
Date: Mon, 16 Feb 2015 15:19:23 -0500	[thread overview]
Message-ID: <54E250CB.1050008@redhat.com> (raw)
In-Reply-To: <1424097865-3973-5-git-send-email-armbru@redhat.com>



On 02/16/2015 09:44 AM, Markus Armbruster wrote:
> add_old_style_options() for img_convert() and img_resize() use
> qemu_opt_set(), which reports errors with qerror_report_err().  Its
> error messages aren't helpful here, the caller reports one that
> actually makes sense.  Reproducer:
>
>      $ qemu-img convert -B raw in.img out.img
>      qemu-img: Invalid parameter 'backing_file'
>      qemu-img: Backing file not supported for file format 'raw'
>
> Switch to qemu_opt_set_err() to get rid of the unwanted messages.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   qemu-img.c | 16 ++++++++++++----
>   1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/qemu-img.c b/qemu-img.c
> index 7eea84a..7a806bc 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -338,17 +338,23 @@ static int add_old_style_options(const char *fmt, QemuOpts *opts,
>                                    const char *base_filename,
>                                    const char *base_fmt)
>   {
> +    Error *err = NULL;
> +
>       if (base_filename) {
> -        if (qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename)) {
> +        qemu_opt_set_err(opts, BLOCK_OPT_BACKING_FILE, base_filename, &err);
> +        if (err) {
>               error_report("Backing file not supported for file format '%s'",
>                            fmt);
> +            error_free(err);
>               return -1;
>           }
>       }
>       if (base_fmt) {
> -        if (qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt)) {
> +        qemu_opt_set_err(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &err);
> +        if (err) {
>               error_report("Backing file format not supported for file "
>                            "format '%s'", fmt);
> +            error_free(err);
>               return -1;
>           }
>       }
> @@ -2758,6 +2764,7 @@ out:
>
>   static int img_resize(int argc, char **argv)
>   {
> +    Error *err = NULL;
>       int c, ret, relative;
>       const char *filename, *fmt, *size;
>       int64_t n, total_size;
> @@ -2830,8 +2837,9 @@ static int img_resize(int argc, char **argv)
>
>       /* Parse size */
>       param = qemu_opts_create(&resize_options, NULL, 0, &error_abort);
> -    if (qemu_opt_set(param, BLOCK_OPT_SIZE, size)) {
> -        /* Error message already printed when size parsing fails */
> +    qemu_opt_set_err(param, BLOCK_OPT_SIZE, size, &err);
> +    if (err) {
> +        error_report_err(err);

Creates a new warning/failure for me, if basing off of origin/master or 
kevin/block:

   CC    qemu-img.o
/home/bos/jhuston/src/qemu/qemu-img.c: In function ‘img_resize’:
/home/bos/jhuston/src/qemu/qemu-img.c:2844:9: error: implicit 
declaration of function ‘error_report_err’ 
[-Werror=implicit-function-declaration]
          error_report_err(err);
          ^
/home/bos/jhuston/src/qemu/qemu-img.c:2844:9: error: nested extern 
declaration of ‘error_report_err’ [-Werror=nested-externs]
cc1: all warnings being treated as errors
make: *** [qemu-img.o] Error 1
make: *** Waiting for unfinished jobs....


>           ret = -1;
>           qemu_opts_del(param);
>           goto out;
>

  reply	other threads:[~2015-02-16 20:19 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16 14:44 [Qemu-devel] [PATCH 00/13] QemuOpts: Convert various setters to Error Markus Armbruster
2015-02-16 14:44 ` [Qemu-devel] [PATCH 01/13] QemuOpts: Convert qemu_opt_set_bool() to Error, fix its use Markus Armbruster
2015-02-16 20:24   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 02/13] QemuOpts: Convert qemu_opt_set_number() " Markus Armbruster
2015-02-16 20:26   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 03/13] QemuOpts: Convert qemu_opts_set() " Markus Armbruster
2015-02-16 21:06   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 04/13] qemu-img: Suppress unhelpful extra errors in convert, resize Markus Armbruster
2015-02-16 20:19   ` John Snow [this message]
2015-02-17  8:18     ` Markus Armbruster
2015-02-17 15:28   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 05/13] block: Suppress unhelpful extra errors in bdrv_img_create() Markus Armbruster
2015-02-16 22:26   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 06/13] QemuOpts: Drop qemu_opt_set(), rename qemu_opt_set_err(), fix use Markus Armbruster
2015-02-16 22:53   ` Eric Blake
2015-02-17  8:21     ` Markus Armbruster
2015-02-16 14:44 ` [Qemu-devel] [PATCH 07/13] QemuOpts: Propagate errors through opts_do_parse() Markus Armbruster
2015-02-16 22:54   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 08/13] QemuOpts: Propagate errors through opts_parse() Markus Armbruster
2015-02-16 23:15   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 09/13] qemu-img: Suppress unhelpful extra errors in convert, amend Markus Armbruster
2015-02-16 23:38   ` Eric Blake
2015-02-17  8:25     ` Markus Armbruster
2015-02-16 14:44 ` [Qemu-devel] [PATCH 10/13] block: Simplify setting numeric options Markus Armbruster
2015-02-17 16:42   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 11/13] qemu-sockets: Simplify setting numeric and boolean options Markus Armbruster
2015-02-17 16:45   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 12/13] pc: Use qemu_opt_set() instead of qemu_opts_parse() Markus Armbruster
2015-02-17 16:46   ` Eric Blake
2015-02-16 14:44 ` [Qemu-devel] [PATCH 13/13] qtest: " Markus Armbruster
2015-02-17 16:47   ` Eric Blake
2015-02-17  8:16 ` [Qemu-devel] [PATCH 00/13] QemuOpts: Convert various setters to Error 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=54E250CB.1050008@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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).