summary refs log tree commit diff stats
path: root/qemu-img.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2009-06-04 15:39:38 +0200
committerBlue Swirl <blauwirbel@gmail.com>2009-06-06 18:38:57 +0300
commitdb08adf526ce78eea7ae5f24e30b8caa1af4cf24 (patch)
treec52baf3aed5286724a6114327f2532bad99ef4bb /qemu-img.c
parentf425c278724fc477735a0eecd2e2b03e53fd1a62 (diff)
downloadfocaccia-qemu-db08adf526ce78eea7ae5f24e30b8caa1af4cf24.tar.gz
focaccia-qemu-db08adf526ce78eea7ae5f24e30b8caa1af4cf24.zip
qemu-img: Print available options with -o ?
This patch adds a small help text to each of the options in the block drivers
which can be displayed by using qemu-img create -f fmt -o ?

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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) {