aboutsummaryrefslogtreecommitdiff
path: root/qemu-img.c
diff options
context:
space:
mode:
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 3edf25a8f0..947e71beab 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -281,15 +281,17 @@ static int img_create(int argc, char **argv)
break;
}
}
- if (optind >= argc)
- help();
- filename = argv[optind++];
/* Find driver and parse its options */
drv = bdrv_find_format(fmt);
if (!drv)
error("Unknown file format '%s'", fmt);
+ if (options && !strcmp(options, "?")) {
+ print_option_help(drv->create_options);
+ return 0;
+ }
+
if (options) {
param = parse_option_parameters(options, drv->create_options, param);
if (param == NULL) {
@@ -299,6 +301,11 @@ static int img_create(int argc, char **argv)
param = parse_option_parameters("", drv->create_options, param);
}
+ /* Get the filename */
+ if (optind >= argc)
+ help();
+ filename = argv[optind++];
+
/* Add size to parameters */
if (optind < argc) {
set_option_parameter(param, BLOCK_OPT_SIZE, argv[optind++]);
@@ -596,6 +603,11 @@ static int img_convert(int argc, char **argv)
if (!drv)
error("Unknown file format '%s'", out_fmt);
+ if (options && !strcmp(options, "?")) {
+ print_option_help(drv->create_options);
+ return 0;
+ }
+
if (options) {
param = parse_option_parameters(options, drv->create_options, param);
if (param == NULL) {