diff options
author | Peter Maydell | 2014-05-02 11:50:58 +0200 |
---|---|---|
committer | Peter Maydell | 2014-05-02 11:50:58 +0200 |
commit | e50bf23438f8f35dcf32f9e720b04e0e969a3215 (patch) | |
tree | 6b787d2d5b46db517f47204e8ab34a06f75aecdf /qemu-img.c | |
parent | Merge remote-tracking branch 'remotes/cohuck/tags/kvm_cap_helpers' into staging (diff) | |
parent | curl: Fix hang reading from slow connections (diff) | |
download | qemu-e50bf23438f8f35dcf32f9e720b04e0e969a3215.tar.gz qemu-e50bf23438f8f35dcf32f9e720b04e0e969a3215.tar.xz qemu-e50bf23438f8f35dcf32f9e720b04e0e969a3215.zip |
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block patches
# gpg: Signature made Wed 30 Apr 2014 19:19:32 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
* remotes/kevin/tags/for-upstream: (31 commits)
curl: Fix hang reading from slow connections
curl: Ensure all informationals are checked for completion
curl: Eliminate unnecessary use of curl_multi_socket_all
curl: Remove unnecessary explicit calls to internal event handler
curl: Remove erroneous sleep waiting for curl completion
curl: Fix return from curl_read_cb with invalid state
curl: Remove unnecessary use of goto
curl: Fix long line
block/vdi: Error out immediately in vdi_create()
block/bochs: Fix error handling for seek_to_sector()
qcow2: Check min_size in qcow2_grow_l1_table()
qcow2: Catch bdrv_getlength() error
block: Use correct width in format strings
qcow2: Avoid overflow in alloc_clusters_noref()
block: Use error_abort in bdrv_image_info_specific_dump()
block: Fix open_flags in bdrv_reopen()
Revert "block: another bdrv_append fix"
block: Unlink temporary files in raw-posix/win32
block: Remove BDRV_O_COPY_ON_READ for bs->file
block: Create bdrv_backing_flags()
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/qemu-img.c b/qemu-img.c index 968b4c8e83..96f44638b7 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -33,6 +33,9 @@ #include "block/qapi.h" #include <getopt.h> +#define QEMU_IMG_VERSION "qemu-img version " QEMU_VERSION \ + ", Copyright (c) 2004-2008 Fabrice Bellard\n" + typedef struct img_cmd_t { const char *name; int (*handler)(int argc, char **argv); @@ -75,7 +78,7 @@ static void QEMU_NORETURN GCC_FMT_ATTR(1, 2) error_exit(const char *fmt, ...) static void QEMU_NORETURN help(void) { const char *help_msg = - "qemu-img version " QEMU_VERSION ", Copyright (c) 2004-2008 Fabrice Bellard\n" + QEMU_IMG_VERSION "usage: qemu-img command [command options]\n" "QEMU disk image utility\n" "\n" @@ -2789,6 +2792,12 @@ int main(int argc, char **argv) { const img_cmd_t *cmd; const char *cmdname; + int c; + static const struct option long_options[] = { + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'v'}, + {0, 0, 0, 0} + }; #ifdef CONFIG_POSIX signal(SIGPIPE, SIG_IGN); @@ -2803,15 +2812,24 @@ 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++) { + 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, NULL); + + if (c == 'h') { + help(); + } + if (c == 'v') { + printf(QEMU_IMG_VERSION); + return 0; + } + /* not found */ error_exit("Command not found: %s", cmdname); } |