On 12/28/2016 06:36 AM, Nitesh Konkar wrote: > Currently no message is displayed on successful > perf event enable or disable. This patch gives > the enabled/disabled status message on successful > enabling/disabling of the perf event. > Eg:virsh perf Domain --enable instructions --disable cache_misses > instructions : enabled > cache_misses : disabled > > Signed-off-by: Nitesh Konkar <nitkon12@xxxxxxxxxxxxxxxxxx> > --- > tools/virsh-domain.c | 27 ++++++++++++++++++--------- > 1 file changed, 18 insertions(+), 9 deletions(-) > ACK and pushed w/ adjustment shown below and an altered commit message. John > diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c > index 3a6fa5c..287ca28 100644 > --- a/tools/virsh-domain.c > +++ b/tools/virsh-domain.c > @@ -8848,13 +8848,27 @@ virshParseEventStr(const char *event, > return ret; > } > > +static void > +virshPrintPerfStatus(vshControl *ctl, virTypedParameterPtr params, int nparams) > +{ > + size_t i; > + > + for (i = 0; i < nparams; i++) { > + if (params[i].type == VIR_TYPED_PARAM_BOOLEAN && > + params[i].value.b) { > + vshPrint(ctl, "%-15s: %s\n", params[i].field, _("enabled")); > + } else { > + vshPrint(ctl, "%-15s: %s\n", params[i].field, _("disabled")); Use vshPrintExtra for both to adhere to the --quiet/-q flag > + } > + } > +} > + > static bool > cmdPerf(vshControl *ctl, const vshCmd *cmd) > { > virDomainPtr dom; > int nparams = 0; > int maxparams = 0; > - size_t i; > virTypedParameterPtr params = NULL; > bool ret = false; > const char *enable = NULL, *disable = NULL; > @@ -8891,18 +8905,13 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) > vshError(ctl, "%s", _("Unable to get perf events")); > goto cleanup; > } > - for (i = 0; i < nparams; i++) { > - if (params[i].type == VIR_TYPED_PARAM_BOOLEAN && > - params[i].value.b) { > - vshPrint(ctl, "%-15s: %s\n", params[i].field, _("enabled")); > - } else { > - vshPrint(ctl, "%-15s: %s\n", params[i].field, _("disabled")); > - } > - } > + virshPrintPerfStatus(ctl, params, nparams); > } else { > if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0) { > vshError(ctl, "%s", _("Unable to enable/disable perf events")); > goto cleanup; > + } else { > + virshPrintPerfStatus(ctl, params, nparams); > } > } > > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list