qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] qemu-img convert: Fix progress output


From: Kevin Wolf
Subject: [Qemu-devel] [PATCH 1/2] qemu-img convert: Fix progress output
Date: Mon, 3 Mar 2014 14:57:10 +0100

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

Reported-by: Peter Lieven <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
 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;
     }
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]