qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/4] qemu-img: Add "Quiet mode" option


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 2/4] qemu-img: Add "Quiet mode" option
Date: Fri, 08 Feb 2013 10:07:35 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 02/08/2013 01:33 AM, Miroslav Rezanina wrote:
> There can be a need to turn output to stdout off. This patch adds a -q option
> that enable "Quiet mode". In Quiet mode, only errors are printed out.
> 
> Signed-off-by: Miroslav Rezanina <address@hidden>
> ---
>  
>      if (result.bfi.total_clusters != 0 && result.bfi.allocated_clusters != 
> 0) {
> -        printf("%" PRId64 "/%" PRId64 "= %0.2f%% allocated, %0.2f%% 
> fragmented\n",
> +        /* BEWARE: parameter list not indented due to long expressions */

This code is being touched in an independent patch, with a solution much
nicer than adding a BEWARE comment:
https://lists.gnu.org/archive/html/qemu-devel/2013-02/msg01101.html

> +        qprintf(quiet,
> +        "%" PRId64 "/%" PRId64 "= %0.2f%% allocated, %0.2f%% fragmented\n",
>          result.bfi.allocated_clusters, result.bfi.total_clusters,
>          result.bfi.allocated_clusters * 100.0 / result.bfi.total_clusters,
>          result.bfi.fragmented_clusters * 100.0 / 
> result.bfi.allocated_clusters);
> +        /* end of parameter list */
>      }

This /* end of parameter list */ comment is bogus.

> @@ -742,9 +775,16 @@ static int img_convert(int argc, char **argv)
>          case 't':
>              cache = optarg;
>              break;
> +        case 'q':
> +            quiet = true;
> +            break;
>          }
>      }
>  
> +    if (quiet) {
> +        progress = 0;
> +    }

I'm still not sure I buy this.  Since '-p' normally adds output, and
'-q' normally removes output, I'm wondering if it is better to follow
conventions of other apps like ls, when when faced with mutually
competing options will favor the last one specified.  Something like:

qemu-img convert -p -q => turns off -p with quiet results
qemu-img convert -q -p => turns off -q, with progress bar results

Or, it might be worth actually erroring out if both -p and -q are
present, in any order.

> +++ b/qemu-img.texi
> @@ -54,6 +54,9 @@ indicates that target image must be compressed (qcow format 
> only)
>  with or without a command shows help and lists the supported formats
>  @item -p
>  display progress bar (convert and rebase commands only)
> address@hidden -q
> +Quiet mode - do not print any output (except errors). There's no progress bar
> +in case both @var{-q} and  @var{-p} options are used.

But at least your documentation matches your code, so I guess I can live
with your choice that -q is always more powerful than -p, no matter what
order they appear in.

You have an extra space before the second @var.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]