From patchwork Mon Jul 18 22:00:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9235473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 296A1602F0 for ; Mon, 18 Jul 2016 22:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1522F205AD for ; Mon, 18 Jul 2016 22:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05B1D254F7; Mon, 18 Jul 2016 22:14:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8BDF1205AD for ; Mon, 18 Jul 2016 22:14:08 +0000 (UTC) Received: from localhost ([::1]:50580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPGnf-0003vX-Mb for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Jul 2016 18:14:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPGah-0006AL-Rs for qemu-devel@nongnu.org; Mon, 18 Jul 2016 18:00:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPGad-0005jk-Jd for qemu-devel@nongnu.org; Mon, 18 Jul 2016 18:00:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55006) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPGad-0005jf-B7 for qemu-devel@nongnu.org; Mon, 18 Jul 2016 18:00:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2E56C0C56; Mon, 18 Jul 2016 22:00:38 +0000 (UTC) Received: from localhost (ovpn-112-31.ams2.redhat.com [10.36.112.31]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6IM0bZd016349; Mon, 18 Jul 2016 18:00:38 -0400 From: Stefan Hajnoczi To: Date: Mon, 18 Jul 2016 23:00:18 +0100 Message-Id: <1468879219-24500-9-git-send-email-stefanha@redhat.com> In-Reply-To: <1468879219-24500-1-git-send-email-stefanha@redhat.com> References: <1468879219-24500-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 18 Jul 2016 22:00:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 8/9] trace: Allow event name pattern in "info trace-events" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Lluís Vilanova Homogenizes the command capabilities with QMP. Signed-off-by: Lluís Vilanova Reviewed-by: Eric Blake Reviewed-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- hmp-commands-info.hx | 8 +++++--- hmp.h | 1 + monitor.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 7da9e6c..3d07ca6 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -646,10 +646,12 @@ ETEXI { .name = "trace-events", - .args_type = "", - .params = "", - .help = "show available trace-events & their state", + .args_type = "name:s?", + .params = "[name]", + .help = "show available trace-events & their state " + "(name: event name pattern)", .mhandler.cmd = hmp_info_trace_events, + .command_completion = info_trace_events_completion, }, STEXI diff --git a/hmp.h b/hmp.h index f5d9749..0876ec0 100644 --- a/hmp.h +++ b/hmp.h @@ -115,6 +115,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 info_trace_events_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); diff --git a/monitor.c b/monitor.c index d0ff246..ab31725 100644 --- a/monitor.c +++ b/monitor.c @@ -1065,8 +1065,20 @@ static void hmp_info_cpustats(Monitor *mon, const QDict *qdict) static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) { - TraceEventInfoList *events = qmp_trace_event_get_state("*", NULL); + const char *name = qdict_get_try_str(qdict, "name"); + TraceEventInfoList *events; TraceEventInfoList *elem; + Error *local_err = NULL; + + if (name == NULL) { + name = "*"; + } + + events = qmp_trace_event_get_state(name, &local_err); + if (local_err) { + error_report_err(local_err); + return; + } for (elem = events; elem != NULL; elem = elem->next) { monitor_printf(mon, "%s : state %u\n", @@ -3296,6 +3308,23 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str) } } +void info_trace_events_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); + } + } + } +} + void trace_event_completion(ReadLineState *rs, int nb_args, const char *str) { size_t len;