From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNMuV-0006W6-OF for qemu-devel@nongnu.org; Mon, 16 Feb 2015 09:44:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNMuT-00042Q-1u for qemu-devel@nongnu.org; Mon, 16 Feb 2015 09:44:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNMuS-00041v-JL for qemu-devel@nongnu.org; Mon, 16 Feb 2015 09:44:28 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1GEiR6S018945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 16 Feb 2015 09:44:27 -0500 From: Markus Armbruster Date: Mon, 16 Feb 2015 15:44:16 +0100 Message-Id: <1424097865-3973-5-git-send-email-armbru@redhat.com> In-Reply-To: <1424097865-3973-1-git-send-email-armbru@redhat.com> References: <1424097865-3973-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 04/13] qemu-img: Suppress unhelpful extra errors in convert, resize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, kraxel@redhat.com, stefanha@redhat.com 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 --- 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); ret = -1; qemu_opts_del(param); goto out; -- 1.9.3