mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
virsh: Display perf enabled/disabled message for set operations
When setting perf events, the enabled/disabled perf events are not listed. Since we know which events were changed it's possible to print out the values on successful set, such as : virsh perf Domain --enable instructions --disable cache_misses instructions : enabled cache_misses : disabled Created a helper to print the messages - use the vshPrintExtra to adhere to the --quiet|-q option being set by some script. This will cause the get code to print nothing, but will return success/failure. Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
This commit is contained in:
parent
779073c575
commit
0289b8b2ba
@ -8848,13 +8848,27 @@ virshParseEventStr(const char *event,
|
|||||||
return ret;
|
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) {
|
||||||
|
vshPrintExtra(ctl, "%-15s: %s\n", params[i].field, _("enabled"));
|
||||||
|
} else {
|
||||||
|
vshPrintExtra(ctl, "%-15s: %s\n", params[i].field, _("disabled"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cmdPerf(vshControl *ctl, const vshCmd *cmd)
|
cmdPerf(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
virDomainPtr dom;
|
virDomainPtr dom;
|
||||||
int nparams = 0;
|
int nparams = 0;
|
||||||
int maxparams = 0;
|
int maxparams = 0;
|
||||||
size_t i;
|
|
||||||
virTypedParameterPtr params = NULL;
|
virTypedParameterPtr params = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
const char *enable = NULL, *disable = NULL;
|
const char *enable = NULL, *disable = NULL;
|
||||||
@ -8891,18 +8905,13 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
|
|||||||
vshError(ctl, "%s", _("Unable to get perf events"));
|
vshError(ctl, "%s", _("Unable to get perf events"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
for (i = 0; i < nparams; i++) {
|
virshPrintPerfStatus(ctl, params, nparams);
|
||||||
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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0) {
|
if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0) {
|
||||||
vshError(ctl, "%s", _("Unable to enable/disable perf events"));
|
vshError(ctl, "%s", _("Unable to enable/disable perf events"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
} else {
|
||||||
|
virshPrintPerfStatus(ctl, params, nparams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user