cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 867469aa337ac206ee6f4ea1b5c4c0f1ec36696d Mon Sep 17 00:00:00 2001
0a122b
From: Kevin Wolf <kwolf@redhat.com>
0a122b
Date: Tue, 25 Feb 2014 15:00:03 +0100
0a122b
Subject: [PATCH 5/7] qemu-img amend: Support multiple -o options
0a122b
0a122b
RH-Author: Kevin Wolf <kwolf@redhat.com>
0a122b
Message-id: <1393340405-9936-5-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: 57794
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH 4/6] qemu-img amend: 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 626f84f39d4ae365a44dbbc0d0dd3c7739c3971a)
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 qemu-img.c | 17 +++++++++++++++--
0a122b
 1 file changed, 15 insertions(+), 2 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 qemu-img.c |   17 +++++++++++++++--
0a122b
 1 files changed, 15 insertions(+), 2 deletions(-)
0a122b
0a122b
diff --git a/qemu-img.c b/qemu-img.c
0a122b
index e7b12c2..5002a56 100644
0a122b
--- a/qemu-img.c
0a122b
+++ b/qemu-img.c
0a122b
@@ -2617,7 +2617,18 @@ static int img_amend(int argc, char **argv)
0a122b
                 help();
0a122b
                 break;
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 'f':
0a122b
                 fmt = optarg;
0a122b
@@ -2647,7 +2658,7 @@ static int img_amend(int argc, char **argv)
0a122b
 
0a122b
     fmt = bs->drv->format_name;
0a122b
 
0a122b
-    if (is_help_option(options)) {
0a122b
+    if (has_help_option(options)) {
0a122b
         ret = print_block_option_help(filename, fmt);
0a122b
         goto out;
0a122b
     }
0a122b
@@ -2674,6 +2685,8 @@ out:
0a122b
     }
0a122b
     free_option_parameters(create_options);
0a122b
     free_option_parameters(options_param);
0a122b
+    g_free(options);
0a122b
+
0a122b
     if (ret) {
0a122b
         return 1;
0a122b
     }
0a122b
-- 
0a122b
1.7.1
0a122b