From 30cd5983b73d9a32898f44336eda10e474f5ff0f Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Wed, 30 Mar 2016 17:56:02 +0200 Subject: [PATCH] virsh: Make perf accept event list separated by commas Everywhere else we use a comma separated list. There's no good reason to make 'perf' command an exception. Currently, it accepts string list separated by '|'. Signed-off-by: Michal Privoznik --- tools/virsh-domain.c | 18 ++++++------------ tools/virsh.pod | 17 +++++++++-------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a09cdece22..f3aa1bb592 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8564,8 +8564,7 @@ static const vshCmdOptDef opts_perf[] = { }; static int -virshParseEventStr(vshControl *ctl, - const char *event, +virshParseEventStr(const char *event, bool state, virTypedParameterPtr *params, int *nparams, @@ -8575,14 +8574,9 @@ virshParseEventStr(vshControl *ctl, size_t i, ntok; int ret = -1; - if (!(tok = virStringSplitCount(event, "|", 0, &ntok))) + if (!(tok = virStringSplitCount(event, ",", 0, &ntok))) return -1; - if (ntok > VIR_PERF_EVENT_LAST) { - vshError(ctl, _("event string '%s' has too many fields"), event); - goto cleanup; - } - for (i = 0; i < ntok; i++) { if ((*tok[i] != '\0') && virTypedParamsAddBoolean(params, nparams, @@ -8615,12 +8609,12 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0) return false; - if (enable && virshParseEventStr(ctl, enable, true, - ¶ms, &nparams, &maxparams) < 0) + if (enable && virshParseEventStr(enable, true, ¶ms, + &nparams, &maxparams) < 0) goto cleanup; - if (disable && virshParseEventStr(ctl, disable, false, - ¶ms, &nparams, &maxparams) < 0) + if (disable && virshParseEventStr(disable, false, ¶ms, + &nparams, &maxparams) < 0) goto cleanup; if (nparams == 0) { diff --git a/tools/virsh.pod b/tools/virsh.pod index 0c02d7f4e3..a9915b09f4 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2144,11 +2144,11 @@ The guaranteed minimum memory allocation for the guest. Specifying -1 as a value for these limits is interpreted as unlimited. -=item B I [I<--enable> B] -[I<--disable> B] +=item B I [I<--enable> B] +[I<--disable> B] Get the current perf events setting or enable/disable specific perf -event for a guest domain. +events for a guest domain. Perf is a performance analyzing tool in Linux, and it can instrument CPU performance counters, tracepoints, kprobes, and uprobes (dynamic @@ -2158,11 +2158,12 @@ pure kernel counters, in this case they are called software events, including context-switches, minor-faults, etc.. Now dozens of events from different sources can be supported by perf. -Currently only QEMU/KVM supports I<--enable> and I<--disable>. -B is a string listing one or more events, in the format -of name|name|name. Only "cmt" event is supported presently. CMT is -a PQos (Platform Qos) feature to monitor the usage of cache by -applications running on the platform. +Currently only QEMU/KVM supports this command. The I<--enable> and I<--disable> +option combined with B can be used to enabled or disable specific +performance event. B is a string list of one or more events +separated by commas. However, just "cmt" event is supported presently. CMT is a +PQos (Platform Qos) feature to monitor the usage of cache by applications +running on the platform. =item B I [I<--weight> B] [I<--device-weights> B]