From db08adf526ce78eea7ae5f24e30b8caa1af4cf24 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 4 Jun 2009 15:39:38 +0200 Subject: 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 --- qemu-img.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'qemu-img.c') 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) { -- cgit v1.2.3