|
|
9ae3a8 |
From 6814f2b17eecd9ab6fde0fc38450632cae930a94 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 25 Feb 2014 15:00:01 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 3/7] qemu-img create: Support multiple -o options
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1393340405-9936-3-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 57797
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 2/6] qemu-img create: Support multiple -o options
|
|
|
9ae3a8 |
Bugzilla: 1065873
|
|
|
9ae3a8 |
RH-Acked-by: Juan Quintela <quintela@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
If you specified multiple -o options for qemu-img create, it would
|
|
|
9ae3a8 |
silently ignore all but the last one. This patch fixes the problem.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Now multiple -o options has the same meaning as having a single option
|
|
|
9ae3a8 |
with all settings in the order of their respective -o options.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 77386bf6ebe67164a2d102b207fb3bc11af8c1e8)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qemu-img.c | 28 ++++++++++++++++++++++------
|
|
|
9ae3a8 |
1 file changed, 22 insertions(+), 6 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qemu-img.c | 28 ++++++++++++++++++++++------
|
|
|
9ae3a8 |
1 files changed, 22 insertions(+), 6 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
9ae3a8 |
index bc48dc1..12bf996 100644
|
|
|
9ae3a8 |
--- a/qemu-img.c
|
|
|
9ae3a8 |
+++ b/qemu-img.c
|
|
|
9ae3a8 |
@@ -365,13 +365,23 @@ static int img_create(int argc, char **argv)
|
|
|
9ae3a8 |
case 'e':
|
|
|
9ae3a8 |
error_report("option -e is deprecated, please use \'-o "
|
|
|
9ae3a8 |
"encryption\' instead!");
|
|
|
9ae3a8 |
- return 1;
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
case '6':
|
|
|
9ae3a8 |
error_report("option -6 is deprecated, please use \'-o "
|
|
|
9ae3a8 |
"compat6\' instead!");
|
|
|
9ae3a8 |
- return 1;
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
case 'o':
|
|
|
9ae3a8 |
- options = optarg;
|
|
|
9ae3a8 |
+ if (!is_valid_option_list(optarg)) {
|
|
|
9ae3a8 |
+ error_report("Invalid option list: %s", optarg);
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (!options) {
|
|
|
9ae3a8 |
+ options = g_strdup(optarg);
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ char *old_options = options;
|
|
|
9ae3a8 |
+ options = g_strdup_printf("%s,%s", options, optarg);
|
|
|
9ae3a8 |
+ g_free(old_options);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
case 'q':
|
|
|
9ae3a8 |
quiet = true;
|
|
|
9ae3a8 |
@@ -398,7 +408,7 @@ static int img_create(int argc, char **argv)
|
|
|
9ae3a8 |
"G or T suffixes for ");
|
|
|
9ae3a8 |
error_report("kilobytes, megabytes, gigabytes and terabytes.");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- return 1;
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
img_size = (uint64_t)sval;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -406,7 +416,8 @@ static int img_create(int argc, char **argv)
|
|
|
9ae3a8 |
help();
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (options && is_help_option(options)) {
|
|
|
9ae3a8 |
+ if (options && has_help_option(options)) {
|
|
|
9ae3a8 |
+ g_free(options);
|
|
|
9ae3a8 |
return print_block_option_help(filename, fmt);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -415,10 +426,15 @@ static int img_create(int argc, char **argv)
|
|
|
9ae3a8 |
if (error_is_set(&local_err)) {
|
|
|
9ae3a8 |
error_report("%s: %s", filename, error_get_pretty(local_err));
|
|
|
9ae3a8 |
error_free(local_err);
|
|
|
9ae3a8 |
- return 1;
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ g_free(options);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+fail:
|
|
|
9ae3a8 |
+ g_free(options);
|
|
|
9ae3a8 |
+ return 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void dump_json_image_check(ImageCheck *check, bool quiet)
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|