[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/5] qemu-img: move common options parsing befor
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 4/5] qemu-img: move common options parsing before commands processing |
Date: |
Fri, 3 Jun 2016 08:50:35 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 06/02/2016 12:35 PM, Denis V. Lunev wrote:
> This is necessary to enable creation of common qemu-img options which will
> be specified before command.
>
> Signed-off-by: Denis V. Lunev <address@hidden>
> CC: Eric Blake <address@hidden>
> CC: Paolo Bonzini <address@hidden>
> CC: Stefan Hajnoczi <address@hidden>
> CC: Kevin Wolf <address@hidden>
> ---
> qemu-img.c | 31 +++++++++++++++++++------------
> 1 file changed, 19 insertions(+), 12 deletions(-)
>
> - /* find the command */
> - for (cmd = img_cmds; cmd->name != NULL; cmd++) {
> - if (!strcmp(cmdname, cmd->name)) {
> - return cmd->handler(argc - 1, argv + 1);
> + while ((c = getopt_long(argc, argv, "+h", long_options, NULL)) != -1) {
> + switch (c) {
> + case 'h':
> + help();
> + return 0;
> + case 'v':
Umm, how is 'v' supposed to be hit if it is not passed in the short
option string summary? That is, 'qemu-img --version' will work, but
'qemu-img -v' won't; while both 'qemu-img --help' and 'qemu-img -h' work.
> + printf(QEMU_IMG_VERSION);
> + return 0;
> }
> }
>
> - c = getopt_long(argc, argv, "h", long_options, NULL);
> + cmdname = argv[optind];
>
> - if (c == 'h') {
> - help();
> - }
> - if (c == 'v') {
On the other hand, it seems to be a pre-existing bug. Still, it's worth
fixing while you're touching this.
In addition to moving the option processing, you should also update the
documentation (both --help and man page).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v3 0/5] trace: enable tracing in qemu-io/qemu-nbd/qemu-img, Denis V. Lunev, 2016/06/02
- [Qemu-devel] [PATCH 2/5] trace: enable tracing in qemu-io, Denis V. Lunev, 2016/06/02
- [Qemu-devel] [PATCH 4/5] qemu-img: move common options parsing before commands processing, Denis V. Lunev, 2016/06/02
- Re: [Qemu-devel] [PATCH 4/5] qemu-img: move common options parsing before commands processing,
Eric Blake <=
- [Qemu-devel] [PATCH 5/5] trace: enable tracing in qemu-img, Denis V. Lunev, 2016/06/02
- [Qemu-devel] [PATCH 1/5] trace: move qemu_trace_opts to trace/control.c, Denis V. Lunev, 2016/06/02
- [Qemu-devel] [PATCH 3/5] trace: enable tracing in qemu-nbd, Denis V. Lunev, 2016/06/02