[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/31] block: fix qemu-img --help invocation
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 01/31] block: fix qemu-img --help invocation |
Date: |
Wed, 30 Apr 2014 20:23:33 +0200 |
From: Jeff Cody <address@hidden>
This fixes a bug introduced in commit ac1307ab, that caused the
'--help' option to not be recognized as a valid command, and not
print any help.
Signed-off-by: Jeff Cody <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-img.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 968b4c8..d884324 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2789,6 +2789,12 @@ int main(int argc, char **argv)
{
const img_cmd_t *cmd;
const char *cmdname;
+ int c;
+ int option_index = 0;
+ static const struct option long_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
#ifdef CONFIG_POSIX
signal(SIGPIPE, SIG_IGN);
@@ -2803,15 +2809,20 @@ int main(int argc, char **argv)
error_exit("Not enough arguments");
}
cmdname = argv[1];
- argc--; argv++;
/* find the command */
for(cmd = img_cmds; cmd->name != NULL; cmd++) {
if (!strcmp(cmdname, cmd->name)) {
- return cmd->handler(argc, argv);
+ return cmd->handler(argc - 1, argv + 1);
}
}
+ c = getopt_long(argc, argv, "h", long_options, &option_index);
+
+ if (c == 'h') {
+ help();
+ }
+
/* not found */
error_exit("Command not found: %s", cmdname);
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/31] Block patches, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 01/31] block: fix qemu-img --help invocation,
Kevin Wolf <=
- [Qemu-devel] [PULL 02/31] mirror: Use DIV_ROUND_UP, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 03/31] block: Add '--version' option to qemu-img, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 04/31] block: Ignore duplicate or NULL format_name in bdrv_iterate_format, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 07/31] block: qemu-iotests - fix image cleanup when using spaced pathnames, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 06/31] mirror: Check for bdrv_get_info result, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 08/31] block: qemu-iotests: make test 019 and 086 work with spaced pathnames, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 05/31] mirror: Fix resource leak when bdrv_getlength fails, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 10/31] iotests: Discarding compressed clusters on qcow2, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 09/31] qcow2: Fix discard, Kevin Wolf, 2014/04/30
- [Qemu-devel] [PULL 11/31] block: Create bdrv_inherited_flags(), Kevin Wolf, 2014/04/30