qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: stefanha@redhat.com, pbonzini@redhat.com, michael.roth@amd.com,
	armbru@redhat.com, vsementsov@virtuozzo.com, den@openvz.org
Subject: [PATCH 2/5] qapi/qmp: QmpCommand: add .tracing field and API
Date: Thu, 23 Sep 2021 22:54:48 +0300	[thread overview]
Message-ID: <20210923195451.714796-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20210923195451.714796-1-vsementsov@virtuozzo.com>

We are going to add a possibility to trace some qmp commands by user
selection. For now add a new field to QmpCommand structure and two
functions to manipulate with it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/qapi/qmp/dispatch.h | 14 ++++++++++++++
 qapi/qmp-registry.c         | 27 +++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h
index 075203dc67..5d0df2f984 100644
--- a/include/qapi/qmp/dispatch.h
+++ b/include/qapi/qmp/dispatch.h
@@ -38,6 +38,7 @@ typedef struct QmpCommand
     QTAILQ_ENTRY(QmpCommand) node;
     bool enabled;
     const char *disable_reason;
+    bool tracing;
 } QmpCommand;
 
 typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;
@@ -64,4 +65,17 @@ typedef void (*qmp_cmd_callback_fn)(const QmpCommand *cmd, void *opaque);
 void qmp_for_each_command(const QmpCommandList *cmds, qmp_cmd_callback_fn fn,
                           void *opaque);
 
+/*
+ * Enable or disable tracing for commands matching the pattern.
+ * Pattern matching is handled by g_pattern_match_simple().
+ */
+void qmp_commands_set_tracing(QmpCommandList *cmds, const char *pattern,
+                              bool enable);
+
+/*
+ * Return true if tracing is enabled for any command matching the pattern.
+ * If pattern is NULL, return true if tracing is enabled for any command.
+ */
+bool qmp_commands_is_tracing_enabled(QmpCommandList *cmds, const char *pattern);
+
 #endif
diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
index f78c064aae..56e761857b 100644
--- a/qapi/qmp-registry.c
+++ b/qapi/qmp-registry.c
@@ -67,6 +67,33 @@ void qmp_enable_command(QmpCommandList *cmds, const char *name)
     qmp_toggle_command(cmds, name, true, NULL);
 }
 
+void qmp_commands_set_tracing(QmpCommandList *cmds, const char *pattern,
+                              bool enable)
+{
+    QmpCommand *cmd;
+
+    QTAILQ_FOREACH(cmd, cmds, node) {
+        if (g_pattern_match_simple(pattern, cmd->name)) {
+            cmd->tracing = true;
+        }
+    }
+}
+
+bool qmp_commands_is_tracing_enabled(QmpCommandList *cmds, const char *pattern)
+{
+    QmpCommand *cmd;
+
+    QTAILQ_FOREACH(cmd, cmds, node) {
+        if (cmd->tracing &&
+            (!pattern || g_pattern_match_simple(pattern, cmd->name)))
+        {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 bool qmp_command_is_enabled(const QmpCommand *cmd)
 {
     return cmd->enabled;
-- 
2.29.2



  parent reply	other threads:[~2021-09-23 20:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 19:54 [PATCH 0/5] trace: inroduce qmp: trace namespace Vladimir Sementsov-Ogievskiy
2021-09-23 19:54 ` [PATCH 1/5] trace/control: introduce trace_opt_parse_opts() Vladimir Sementsov-Ogievskiy
2021-09-23 19:54 ` Vladimir Sementsov-Ogievskiy [this message]
2021-09-23 19:54 ` [PATCH 3/5] monitor: add qmp tracing API for qmp_commands Vladimir Sementsov-Ogievskiy
2021-09-23 19:54 ` [PATCH 4/5] util/qemu-option: make qemu_opt_del_all() function public Vladimir Sementsov-Ogievskiy
2021-09-23 19:54 ` [PATCH 5/5] trace: add qmp trace event namespace Vladimir Sementsov-Ogievskiy
2021-10-12 11:49 ` [PATCH 0/5] trace: inroduce qmp: trace namespace Markus Armbruster
2021-10-14 15:22   ` Vladimir Sementsov-Ogievskiy
2021-10-25 12:28     ` Stefan Hajnoczi
2021-10-26 10:28       ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210923195451.714796-3-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).