Skip to content

Commit

Permalink
trace-events: Add hmp completion
Browse files Browse the repository at this point in the history
Add completion for the trace event names in the hmp trace-event
command.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-id: 1439548063-18410-1-git-send-email-dgilbert@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
dagrh authored and stefanhaRH committed Sep 3, 2015
1 parent 561578c commit 987bd27
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions hmp-commands.hx
Expand Up @@ -271,6 +271,7 @@ ETEXI
.params = "name on|off",
.help = "changes status of a specific trace event",
.mhandler.cmd = hmp_trace_event,
.command_completion = trace_event_completion,
},

STEXI
Expand Down
1 change: 1 addition & 0 deletions hmp.h
Expand Up @@ -113,6 +113,7 @@ void set_link_completion(ReadLineState *rs, int nb_args, const char *str);
void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str);
void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str);
void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str);
void trace_event_completion(ReadLineState *rs, int nb_args, const char *str);
void watchdog_action_completion(ReadLineState *rs, int nb_args,
const char *str);
void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
Expand Down
20 changes: 20 additions & 0 deletions monitor.c
Expand Up @@ -4429,6 +4429,26 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str)
}
}

void trace_event_completion(ReadLineState *rs, int nb_args, const char *str)
{
size_t len;

len = strlen(str);
readline_set_completion_index(rs, len);
if (nb_args == 2) {
TraceEventID id;
for (id = 0; id < trace_event_count(); id++) {
const char *event_name = trace_event_get_name(trace_event_id(id));
if (!strncmp(str, event_name, len)) {
readline_add_completion(rs, event_name);
}
}
} else if (nb_args == 3) {
add_completion_option(rs, str, "on");
add_completion_option(rs, str, "off");
}
}

void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str)
{
int i;
Expand Down

0 comments on commit 987bd27

Please sign in to comment.