'\" t .\" Title: libtracecmd .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 04/07/2024 .\" Manual: libtracefs Manual .\" Source: libtracefs .\" Language: English .\" .TH "LIBTRACECMD" "3" "04/07/2024" "libtracefs" "libtracefs Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" tracecmd_get_traceid, tracecmd_get_guest_cpumap \- Manage trace session with multiple trace peers, recorded in multiple trace files\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR unsigned long long \fBtracecmd_get_traceid\fR(struct tracecmd_input *\fIhandle\fR); int \fBtracecmd_get_guest_cpumap\fR(struct tracecmd_input *\fIhandle\fR, unsigned long long \fItrace_id\fR, const char **\fIname\fR, int *\fIvcpu_count\fR, const int **\fIcpu_pid\fR); .fi .SH "DESCRIPTION" .sp This set of APIs can be used to manage a trace session with multiple trace peers, for example, tracing both a host and one or more guest virtual machines\&. The trace data of each peer from the session is recorded in separate trace files\&. Information about peers from the session is stored in the metadata of each trace file\&. These APIs use that information to extract and synchronize the trace data\&. .sp The \fBtracecmd_get_traceid()\fR function returns the trace ID stored in the trace file metadata associated with \fIhandle\fR\&. Each peer from a trace session has an ID unique for that peer and that trace session only\&. This ID is used to match multiple trace files recorded in a same trace session\&. .sp The \fBtracecmd_get_guest_cpumap()\fR function gets the mapping of guest virtual CPUs (VCPU) to the host process that represents those VCPUs and is stored in the metadata of the trace file associated with \fIhandle\fR\&. This information is gathered during a host\-guest trace session and is stored in the host trace file\&. The \fItrace_id\fR parameter is the trace ID of the guest in this particular trace session\&. If a guest with that ID was part of that session, its VCPU to host process mapping is in the host trace file and the information is returned in \fIname\fR, \fIvcpu_count\fR and \fIcpu_pid\fR parameters\&. The \fIname\fR parameter contains the name of the guest, the \fIvcpu_count\fR contains the count of VCPUs of that guest and the \fIcpu_pid\fR array contains the VCPU to host process mapping\&. The array is of size \fIvcpu_count\fR where the index is VCPU and the value is the process ID (PID) of the host process, running that VCPU\&. The \fIname\fR, \fIvcpu_count\fR and \fIcpu_pid\fR values must \fBnot\fR be freed\&. .SH "RETURN VALUE" .sp The \fBtracecmd_get_traceid()\fR function returns a 64 bit trace ID\&. .sp The \fBtracecmd_get_guest_cpumap()\fR function returns \-1 in case of an error or 0 otherwise\&. If 0 is returned, then the \fIname\fR, \fIvcpu_count\fR and \fIcpu_pid\fR parameters contain the requested information\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include \&.\&.\&. struct tracecmd_input *host = tracecmd_open("trace\&.dat"); if (!host) { /* Failed to open host trace file */ } struct tracecmd_input *guest1 = tracecmd_open_head("trace\-Guest1\&.dat"); if (!guest1) { /* Failed to open guest1 trace file */ } struct tracecmd_input *guest2 = tracecmd_open_head("trace\-Guest2\&.dat"); if (!guest2) { /* Failed to open guest2 trace file */ } unsigned long long guest_id_1 = tracecmd_get_traceid(guest1); unsigned long long guest_id_2 = tracecmd_get_traceid(guest2); int *cpu_pid_1, *cpu_pid_2; int vcount_1, vcount_2; char *name_1, *name_2; if (!tracecmd_get_guest_cpumap(host, guest_id_1, &name_1, &vcount_1, &cpu_pid_1)) { /* The Host and a guest1 with name_1 are part of the same trace session\&. * Got guest1 VCPU to host PID mapping\&. */ } if (!tracecmd_get_guest_cpumap(host, guest_id_2, &name_2, &vcount_2, &cpu_pid_2)) { /* The Host and a guest2 with name_2 are part of the same trace session\&. * Got guest2 VCPU to host PID mapping\&. */ } \&.\&.\&. tracecmd_close(guest1); tracecmd_close(guest2); tracecmd_close(handle); .fi .if n \{\ .RE .\} .SH "FILES" .sp .if n \{\ .RS 4 .\} .nf \fBtrace\-cmd\&.h\fR Header file to include in order to have access to the library APIs\&. \fB\-ltracecmd\fR Linker switch to add when building a program that uses the library\&. .fi .if n \{\ .RE .\} .SH "SEE ALSO" .sp \fBlibtracefs(3)\fR, \fBlibtraceevent(3)\fR, \fBtrace\-cmd(1)\fR \fBtrace\-cmd\&.dat(5)\fR .SH "AUTHOR" .sp .if n \{\ .RS 4 .\} .nf \fBSteven Rostedt\fR <\m[blue]\fBrostedt@goodmis\&.org\fR\m[]\&\s-2\u[1]\d\s+2> \fBTzvetomir Stoyanov\fR <\m[blue]\fBtz\&.stoyanov@gmail\&.com\fR\m[]\&\s-2\u[2]\d\s+2> .fi .if n \{\ .RE .\} .SH "REPORTING BUGS" .sp Report bugs to <\m[blue]\fBlinux\-trace\-devel@vger\&.kernel\&.org\fR\m[]\&\s-2\u[3]\d\s+2> .SH "LICENSE" .sp libtracecmd is Free Software licensed under the GNU LGPL 2\&.1 .SH "RESOURCES" .sp \m[blue]\fBhttps://git\&.kernel\&.org/pub/scm/utils/trace\-cmd/trace\-cmd\&.git/\fR\m[] .SH "COPYING" .sp Copyright (C) 2020 VMware, Inc\&. Free use of this software is granted under the terms of the GNU Public License (GPL)\&. .SH "NOTES" .IP " 1." 4 rostedt@goodmis.org .RS 4 \%mailto:rostedt@goodmis.org .RE .IP " 2." 4 tz.stoyanov@gmail.com .RS 4 \%mailto:tz.stoyanov@gmail.com .RE .IP " 3." 4 linux-trace-devel@vger.kernel.org .RS 4 \%mailto:linux-trace-devel@vger.kernel.org .RE