cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From a20760c046f133055cedaba6952f49758e0d9cbf Mon Sep 17 00:00:00 2001
0a122b
From: Kevin Wolf <kwolf@redhat.com>
0a122b
Date: Tue, 25 Feb 2014 15:00:02 +0100
0a122b
Subject: [PATCH 4/7] qemu-img convert: Support multiple -o options
0a122b
0a122b
RH-Author: Kevin Wolf <kwolf@redhat.com>
0a122b
Message-id: <1393340405-9936-4-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: 57799
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH 3/6] qemu-img convert: Support multiple -o options
0a122b
Bugzilla: 1065873
0a122b
RH-Acked-by: Juan Quintela <quintela@redhat.com>
0a122b
RH-Acked-by: Fam Zheng <famz@redhat.com>
0a122b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
0a122b
Instead of ignoring all option values but the last one, multiple -o
0a122b
options now have the same meaning as having a single option with all
0a122b
settings in the order of their respective -o options.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
Reviewed-by: Jeff Cody <jcody@redhat.com>
0a122b
Reviewed-by: Eric Blake <eblake@redhat.com>
0a122b
(cherry picked from commit 2dc8328b4c6aba60f4ad543186f4e8aec2e9287e)
0a122b
0a122b
Conflicts:
0a122b
	qemu-img.c
0a122b
0a122b
Conflicts because qemu-img convert doesn't have an -l option in RHEL 7.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 qemu-img.c | 31 +++++++++++++++++++++++--------
0a122b
 1 file changed, 23 insertions(+), 8 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 qemu-img.c |   31 +++++++++++++++++++++++--------
0a122b
 1 files changed, 23 insertions(+), 8 deletions(-)
0a122b
0a122b
diff --git a/qemu-img.c b/qemu-img.c
0a122b
index 12bf996..e7b12c2 100644
0a122b
--- a/qemu-img.c
0a122b
+++ b/qemu-img.c
0a122b
@@ -1159,6 +1159,9 @@ static int img_convert(int argc, char **argv)
0a122b
     bool quiet = false;
0a122b
     Error *local_err = NULL;
0a122b
 
0a122b
+    /* Initialize before goto out */
0a122b
+    qemu_progress_init(progress, 1.0);
0a122b
+
0a122b
     fmt = NULL;
0a122b
     out_fmt = "raw";
0a122b
     cache = "unsafe";
0a122b
@@ -1190,13 +1193,26 @@ static int img_convert(int argc, char **argv)
0a122b
         case 'e':
0a122b
             error_report("option -e is deprecated, please use \'-o "
0a122b
                   "encryption\' instead!");
0a122b
-            return 1;
0a122b
+            ret = -1;
0a122b
+            goto out;
0a122b
         case '6':
0a122b
             error_report("option -6 is deprecated, please use \'-o "
0a122b
                   "compat6\' instead!");
0a122b
-            return 1;
0a122b
+            ret = -1;
0a122b
+            goto out;
0a122b
         case 'o':
0a122b
-            options = optarg;
0a122b
+            if (!is_valid_option_list(optarg)) {
0a122b
+                error_report("Invalid option list: %s", optarg);
0a122b
+                ret = -1;
0a122b
+                goto out;
0a122b
+            }
0a122b
+            if (!options) {
0a122b
+                options = g_strdup(optarg);
0a122b
+            } else {
0a122b
+                char *old_options = options;
0a122b
+                options = g_strdup_printf("%s,%s", options, optarg);
0a122b
+                g_free(old_options);
0a122b
+            }
0a122b
             break;
0a122b
         case 's':
0a122b
             snapshot_name = optarg;
0a122b
@@ -1208,7 +1224,8 @@ static int img_convert(int argc, char **argv)
0a122b
             sval = strtosz_suffix(optarg, &end, STRTOSZ_DEFSUFFIX_B);
0a122b
             if (sval < 0 || *end) {
0a122b
                 error_report("Invalid minimum zero buffer size for sparse output specified");
0a122b
-                return 1;
0a122b
+                ret = -1;
0a122b
+                goto out;
0a122b
             }
0a122b
 
0a122b
             min_sparse = sval / BDRV_SECTOR_SIZE;
0a122b
@@ -1240,10 +1257,7 @@ static int img_convert(int argc, char **argv)
0a122b
 
0a122b
     out_filename = argv[argc - 1];
0a122b
 
0a122b
-    /* Initialize before goto out */
0a122b
-    qemu_progress_init(progress, 1.0);
0a122b
-
0a122b
-    if (options && is_help_option(options)) {
0a122b
+    if (options && has_help_option(options)) {
0a122b
         ret = print_block_option_help(out_filename, out_fmt);
0a122b
         goto out;
0a122b
     }
0a122b
@@ -1610,6 +1624,7 @@ out:
0a122b
     free_option_parameters(create_options);
0a122b
     free_option_parameters(param);
0a122b
     qemu_vfree(buf);
0a122b
+    g_free(options);
0a122b
     if (out_bs) {
0a122b
         bdrv_unref(out_bs);
0a122b
     }
0a122b
-- 
0a122b
1.7.1
0a122b