thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
Blob Blame History Raw
From b099e03cdfbf175bf8b2368b83348ca2359004c7 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Mon, 10 Mar 2014 10:33:22 +0100
Subject: [PATCH 11/16] qemu-img convert: Fix progress output

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1394447603-30527-2-git-send-email-kwolf@redhat.com>
Patchwork-id: 58060
O-Subject: [RHEL-7.0 qemu-kvm PATCH 1/2] qemu-img convert: Fix progress output
Bugzilla: 1073728
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

Initialise progress output only when the -p and -q options have already
been parsed, otherwise it's always disabled.

Reported-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 64bb01aa35a24bea7ad0a1a8713991bab5020d12)

Conflicts:
	qemu-img.c

Conflicts because RHEL 7 doesn't support -l in qemu-img convert.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-img.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 qemu-img.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 3dc325e..dcce380 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1163,9 +1163,6 @@ static int img_convert(int argc, char **argv)
     bool quiet = false;
     Error *local_err = NULL;
 
-    /* Initialize before goto out */
-    qemu_progress_init(progress, 1.0);
-
     fmt = NULL;
     out_fmt = "raw";
     cache = "unsafe";
@@ -1198,17 +1195,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);
@@ -1229,7 +1226,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;
@@ -1250,9 +1247,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;
@@ -1629,7 +1629,6 @@ out:
     free_option_parameters(create_options);
     free_option_parameters(param);
     qemu_vfree(buf);
-    g_free(options);
     if (out_bs) {
         bdrv_unref(out_bs);
     }
@@ -1641,6 +1640,9 @@ out:
         }
         g_free(bs);
     }
+fail_getopt:
+    g_free(options);
+
     if (ret) {
         return 1;
     }
-- 
1.7.1