From 987bd27000b6e21df6c73f6badb945ab5e42996a Mon Sep 17 00:00:00 2001 From: Dr. David Alan Gilbert Date: Fri, 14 Aug 2015 11:27:43 +0100 Subject: trace-events: Add hmp completion Add completion for the trace event names in the hmp trace-event command. Signed-off-by: Dr. David Alan Gilbert Message-id: 1439548063-18410-1-git-send-email-dgilbert@redhat.com Signed-off-by: Stefan Hajnoczi --- monitor.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index fc32f12eef..b432447868 100644 --- a/monitor.c +++ b/monitor.c @@ -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; -- cgit v1.2.3-55-g7522