From patchwork Mon Mar 3 13:57:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 325841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C15102C00CE for ; Tue, 4 Mar 2014 00:58:14 +1100 (EST) Received: from localhost ([::1]:39849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKTNk-0003qS-Ba for incoming@patchwork.ozlabs.org; Mon, 03 Mar 2014 08:58:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKTNC-0002ws-Bn for qemu-devel@nongnu.org; Mon, 03 Mar 2014 08:57:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKTN6-00085W-9C for qemu-devel@nongnu.org; Mon, 03 Mar 2014 08:57:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKTN5-000856-V2 for qemu-devel@nongnu.org; Mon, 03 Mar 2014 08:57:32 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s23DvG11005862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 Mar 2014 08:57:16 -0500 Received: from dhcp-200-207.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s23DvDwA028173; Mon, 3 Mar 2014 08:57:15 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Mon, 3 Mar 2014 14:57:10 +0100 Message-Id: <1393855031-26915-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1393855031-26915-1-git-send-email-kwolf@redhat.com> References: <1393855031-26915-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pl@kamp.de, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 1/2] qemu-img convert: Fix progress output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Initialise progress output only when the -p and -q options have already been parsed, otherwise it's always disabled. Reported-by: Peter Lieven Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- qemu-img.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 78fc868..a93b71a 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1168,9 +1168,6 @@ static int img_convert(int argc, char **argv) Error *local_err = NULL; QemuOpts *sn_opts = NULL; - /* Initialize before goto out */ - qemu_progress_init(progress, 1.0); - fmt = NULL; out_fmt = "raw"; cache = "unsafe"; @@ -1203,17 +1200,17 @@ static int img_convert(int argc, char **argv) error_report("option -e is deprecated, please use \'-o " "encryption\' instead!"); ret = -1; - goto out; + goto fail_getopt; case '6': error_report("option -6 is deprecated, please use \'-o " "compat6\' instead!"); ret = -1; - goto out; + goto fail_getopt; case 'o': if (!is_valid_option_list(optarg)) { error_report("Invalid option list: %s", optarg); ret = -1; - goto out; + goto fail_getopt; } if (!options) { options = g_strdup(optarg); @@ -1233,7 +1230,7 @@ static int img_convert(int argc, char **argv) error_report("Failed in parsing snapshot param '%s'", optarg); ret = -1; - goto out; + goto fail_getopt; } } else { snapshot_name = optarg; @@ -1247,7 +1244,7 @@ static int img_convert(int argc, char **argv) if (sval < 0 || *end) { error_report("Invalid minimum zero buffer size for sparse output specified"); ret = -1; - goto out; + goto fail_getopt; } min_sparse = sval / BDRV_SECTOR_SIZE; @@ -1268,9 +1265,12 @@ static int img_convert(int argc, char **argv) } } + /* Initialize before goto out */ if (quiet) { progress = 0; } + qemu_progress_init(progress, 1.0); + bs_n = argc - optind - 1; out_filename = bs_n >= 1 ? argv[argc - 1] : NULL; @@ -1673,7 +1673,6 @@ out: free_option_parameters(create_options); free_option_parameters(param); qemu_vfree(buf); - g_free(options); if (sn_opts) { qemu_opts_del(sn_opts); } @@ -1688,6 +1687,9 @@ out: } g_free(bs); } +fail_getopt: + g_free(options); + if (ret) { return 1; }