From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH v2 02/10] trace-cmd library: New API for setting a message context to an output handler
Date: Thu, 11 Nov 2021 17:03:13 +0200 [thread overview]
Message-ID: <20211111150321.85979-3-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20211111150321.85979-1-tz.stoyanov@gmail.com>
The new API associates previously created handler to message context
with given output handler. The message context is used by the output
handler to send data over a network, instead writing to a local file.
tracecmd_output_allocate()
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
.../include/private/trace-cmd-private.h | 2 ++
lib/trace-cmd/trace-output.c | 22 +++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index bed96657..49c8c138 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -270,6 +270,8 @@ struct tracecmd_option;
struct tracecmd_msg_handle;
struct tracecmd_output *tracecmd_output_allocate(int fd);
+int tracecmd_output_set_msg(struct tracecmd_output *handler,
+ struct tracecmd_msg_handle *msg_handle);
struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, int cpus);
struct tracecmd_output *
tracecmd_create_init_file_glob(const char *output_file,
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index 3878b963..d73c4f99 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -918,6 +918,28 @@ struct tracecmd_output *tracecmd_output_allocate(int fd)
return handle;
}
+/**
+ * tracecmd_output_set_msg - associated an output file handler with network message handler
+ * @handle: output handler to a trace file.
+ * @msg_handle: network handler, allocated by tracecmd_msg_handle_alloc()
+ *
+ * This API associates an output file handler with a network stream. All subsequent API calls
+ * with this output file handler will send data over the network using the @msg_handle, instead
+ * of writing to a file.
+ * This API must be called after the handler file version is set and before
+ * tracecmd_output_write_init().
+ *
+ * Returns 0 on success, or -1 if the output file handler is not allocated or not in expected state.
+ */
+int tracecmd_output_set_msg(struct tracecmd_output *handler, struct tracecmd_msg_handle *msg_handle)
+{
+ if (!handler || handler->file_state != TRACECMD_FILE_ALLOCATED)
+ return -1;
+
+ handler->msg_handle = msg_handle;
+
+ return 0;
+}
static int select_file_version(struct tracecmd_output *handle,
struct tracecmd_input *ihandle)
--
2.33.1
next prev parent reply other threads:[~2021-11-11 15:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 15:03 [PATCH v2 00/10] Refactor APIs for creating output handler Tzvetomir Stoyanov (VMware)
2021-11-11 15:03 ` [PATCH v2 01/10] trace-cmd library: New API for allocating an " Tzvetomir Stoyanov (VMware)
2021-11-24 3:37 ` Steven Rostedt
2021-11-11 15:03 ` Tzvetomir Stoyanov (VMware) [this message]
2021-11-24 3:41 ` [PATCH v2 02/10] trace-cmd library: New API for setting a message context to " Steven Rostedt
2021-11-11 15:03 ` [PATCH v2 03/10] trace-cmd library: New API for setting a custom trace directory " Tzvetomir Stoyanov (VMware)
2021-11-24 3:33 ` [PATCH v2 00/10] Refactor APIs for creating " Steven Rostedt
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=20211111150321.85979-3-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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).