# libtracecmd(3) Manual Page

## NAME

tracecmd_get_traceid, tracecmd_get_guest_cpumap - Manage trace session with multiple trace peers, recorded in multiple trace files.

## SYNOPSIS

    #include <trace-cmd.h>

    unsigned long long tracecmd_get_traceid(struct tracecmd_input *handle);
    int tracecmd_get_guest_cpumap(struct tracecmd_input *handle, unsigned long long trace_id, const char **name, int *vcpu_count, const int **cpu_pid);

## DESCRIPTION

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.

The tracecmd_get_traceid() function returns the trace ID stored in the trace file metadata associated with handle. 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.

The tracecmd_get_guest_cpumap() 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 handle. This information is gathered during a host-guest trace session and is stored in the host trace file. The trace_id 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 name, vcpu_count and cpu_pid parameters. The name parameter contains the name of the guest, the vcpu_count contains the count of VCPUs of that guest and the cpu_pid array contains the VCPU to host process mapping. The array is of size vcpu_count where the index is VCPU and the value is the process ID (PID) of the host process, running that VCPU. The name, vcpu_count and cpu_pid values must not be freed.

## RETURN VALUE

The tracecmd_get_traceid() function returns a 64 bit trace ID.

The tracecmd_get_guest_cpumap() function returns -1 in case of an error or 0 otherwise. If 0 is returned, then the name, vcpu_count and cpu_pid parameters contain the requested information.

## EXAMPLE

## FILES

    trace-cmd.h
            Header file to include in order to have access to the library APIs.
    -ltracecmd
            Linker switch to add when building a program that uses the library.

## SEE ALSO

libtracefs(3), libtraceevent(3), trace-cmd(1) trace-cmd.dat(5)

## AUTHOR

    Steven Rostedt <rostedt@goodmis.org>
    Tzvetomir Stoyanov <tz.stoyanov@gmail.com>

## REPORTING BUGS

Report bugs to <linux-trace-devel@vger.kernel.org>

## LICENSE

libtracecmd is Free Software licensed under the GNU LGPL 2.1

## RESOURCES

https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/

## COPYING

Copyright (C) 2020 VMware, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).