Skip to content

Commit

Permalink
qemu-img amend: Support multiple -o options
Browse files Browse the repository at this point in the history
Instead of ignoring all option values but the last one, multiple -o
options now have the same meaning as having a single option with all
settings in the order of their respective -o options.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
  • Loading branch information
kevmw committed Feb 21, 2014
1 parent 2dc8328 commit 626f84f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions qemu-img.c
Expand Up @@ -2667,7 +2667,18 @@ static int img_amend(int argc, char **argv)
help();
break;
case 'o':
options = optarg;
if (!is_valid_option_list(optarg)) {
error_report("Invalid option list: %s", optarg);
ret = -1;
goto out;
}
if (!options) {
options = g_strdup(optarg);
} else {
char *old_options = options;
options = g_strdup_printf("%s,%s", options, optarg);
g_free(old_options);
}
break;
case 'f':
fmt = optarg;
Expand Down Expand Up @@ -2697,7 +2708,7 @@ static int img_amend(int argc, char **argv)

fmt = bs->drv->format_name;

if (is_help_option(options)) {
if (has_help_option(options)) {
ret = print_block_option_help(filename, fmt);
goto out;
}
Expand All @@ -2724,6 +2735,8 @@ static int img_amend(int argc, char **argv)
}
free_option_parameters(create_options);
free_option_parameters(options_param);
g_free(options);

if (ret) {
return 1;
}
Expand Down

0 comments on commit 626f84f

Please sign in to comment.