[PATCH 13/23] perf kvm: Add -q/--quiet option

From: Namhyung Kim
Date: Tue Mar 07 2017 - 10:34:44 EST


The -q/--quiet option is to suppress any message. Sometimes users just
want to run the command and it can be used for that case.

Suggested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/Documentation/perf-kvm.txt | 3 +++
tools/perf/builtin-kvm.c | 10 +++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-kvm.txt b/tools/perf/Documentation/perf-kvm.txt
index 6a5bb2b17039..8eec9d13181c 100644
--- a/tools/perf/Documentation/perf-kvm.txt
+++ b/tools/perf/Documentation/perf-kvm.txt
@@ -96,6 +96,9 @@ OPTIONS
-v::
--verbose::
Be more verbose (show counter open errors, etc).
+-q::
+--quiet::
+ Do not show any message.

STAT REPORT OPTIONS
-------------------
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 08fa88f62a24..1d121bb0a14d 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1018,7 +1018,7 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)

err = perf_evlist__open(evlist);
if (err < 0) {
- printf("Couldn't create the events: %s\n",
+ pr_err("Couldn't create the events: %s\n",
str_error_r(errno, sbuf, sizeof(sbuf)));
goto out;
}
@@ -1313,6 +1313,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
perf_evlist__parse_mmap_pages),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_BOOLEAN('a', "all-cpus", &kvm->opts.target.system_wide,
"system-wide collection from all CPUs"),
OPT_UINTEGER('d', "display", &kvm->display_time,
@@ -1372,6 +1373,9 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
usage_with_options(live_usage, live_options);
}

+ if (quiet)
+ perf_quiet_option();
+
kvm->duration *= NSEC_PER_USEC; /* convert usec to nsec */

/*
@@ -1557,6 +1561,7 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
"file", "file saving guest os /proc/modules"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_END()
};

@@ -1572,6 +1577,9 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
if (!argc)
usage_with_options(kvm_usage, kvm_options);

+ if (quiet)
+ perf_quiet_option();
+
if (!perf_host)
perf_guest = 1;

--
2.11.0