mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 06:50:22 +03:00
virsh: Add event completer to --enable/--disable args of perf command
Signed-off-by: Lin Ma <lma@suse.de> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a2ab5eb8e1
commit
eddd9932ee
@ -29,6 +29,7 @@
|
||||
#include "virsh.h"
|
||||
#include "virstring.h"
|
||||
#include "virxml.h"
|
||||
#include "virperf.h"
|
||||
|
||||
char **
|
||||
virshDomainNameCompleter(vshControl *ctl,
|
||||
@ -338,3 +339,51 @@ virshDomainHostnameSourceCompleter(vshControl *ctl G_GNUC_UNUSED,
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
char **
|
||||
virshDomainPerfEnableCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags)
|
||||
{
|
||||
size_t i = 0;
|
||||
VIR_AUTOSTRINGLIST events = NULL;
|
||||
const char *event = NULL;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (VIR_ALLOC_N(events, VIR_PERF_EVENT_LAST + 1) < 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < VIR_PERF_EVENT_LAST; i++)
|
||||
events[i] = g_strdup(virPerfEventTypeToString(i));
|
||||
|
||||
if (vshCommandOptStringQuiet(ctl, cmd, "enable", &event) < 0)
|
||||
return NULL;
|
||||
|
||||
return virshCommaStringListComplete(event, (const char **)events);
|
||||
}
|
||||
|
||||
|
||||
char **
|
||||
virshDomainPerfDisableCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags)
|
||||
{
|
||||
size_t i = 0;
|
||||
VIR_AUTOSTRINGLIST events = NULL;
|
||||
const char *event = NULL;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (VIR_ALLOC_N(events, VIR_PERF_EVENT_LAST + 1) < 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < VIR_PERF_EVENT_LAST; i++)
|
||||
events[i] = g_strdup(virPerfEventTypeToString(i));
|
||||
|
||||
if (vshCommandOptStringQuiet(ctl, cmd, "disable", &event) < 0)
|
||||
return NULL;
|
||||
|
||||
return virshCommaStringListComplete(event, (const char **)events);
|
||||
}
|
||||
|
@ -62,3 +62,11 @@ virshDomainInterfaceAddrSourceCompleter(vshControl *ctl,
|
||||
char ** virshDomainHostnameSourceCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags);
|
||||
|
||||
char ** virshDomainPerfEnableCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags);
|
||||
|
||||
char ** virshDomainPerfDisableCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags);
|
||||
|
@ -9332,10 +9332,12 @@ static const vshCmdOptDef opts_perf[] = {
|
||||
VIRSH_COMMON_OPT_DOMAIN_FULL(0),
|
||||
{.name = "enable",
|
||||
.type = VSH_OT_STRING,
|
||||
.completer = virshDomainPerfEnableCompleter,
|
||||
.help = N_("perf events which will be enabled")
|
||||
},
|
||||
{.name = "disable",
|
||||
.type = VSH_OT_STRING,
|
||||
.completer = virshDomainPerfDisableCompleter,
|
||||
.help = N_("perf events which will be disabled")
|
||||
},
|
||||
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
|
||||
|
Loading…
x
Reference in New Issue
Block a user