I'm assuming that you can pair multiple guests with a single host? That is, can we have: bool g1 = false, g2 = false; host = tracecmd_open_head("trace.dat"); tracecmd_init_data(host); guest1 = tracecmd_open_head("trace-Guest-1.dat"); guest2 = tracecmd_open_head("trace-Guest-2.dat"); guest_id_1 = tracecmd_get_traceid(guest1); guest_id_2 = tracecmd_get_traceid(guest1); if (!tracecmd_get_guest_cpumap(host, guest_id_1, &name1, &vcount1, &cpu_pids1) g1 = !tracecmd_init_data(guest1); if (!tracecmd_get_guest_cpumap(host, guest_id_2, &name2, &vcount2, &cpu_pids2) g2 = !tracecmd_init_data(guest2); if (g1) { int i; for (i = 0; i < vcount1; i++) { printf("Host task id %d maps to guest %s cpu %d\n", cpu_pids1[i], name1, i); } tracecmd_unpair_peer(guest1); } if (g2) { int i; for (i = 0; i < vcount2; i++) { printf("Host task id %d maps to guest %s cpu %d\n", cpu_pids2[i], name2, i); } tracecmd_unpair_peer(guest2); } And use something like the above for the example? -- Steve On Wed, 23 Dec 2020 06:34:28 +0200 "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote: > +EXAMPLE > +------- > +[source,c] > +-- > +#include <trace-cmd.h> > +... > +struct tracecmd_input *host = tracecmd_open_head("trace.dat"); > + if (!host) { > + /* Failed to open host trace file */ > + } > + tracecmd_init_data(host); > + > +struct tracecmd_input *guest = tracecmd_open_head("trace-Guest.dat"); > + if (!guest) { > + /* Failed to open guest trace file */ > + } > + > +unsigned long long guest_id = tracecmd_get_traceid(guest); > +int *cpu_pid; > +char *name; > +int vcount; > + > + if (!tracecmd_get_guest_cpumap(host, guest_id, &name, &vcount, &cpu_pid)) { > + /* The Host and a guest with name was part of the same trace session. > + * Got guest VCPU to host PID mapping. > + */ > + if (!tracecmd_pair_peer(guest, host)) { > + /* Successfully paired host to the guest handler */ > + tracecmd_init_data(guest); > + ... > + tracecmd_unpair_peer(guest); > + } > + } > + > +... > + tracecmd_close(guest); > + tracecmd_close(hadle); > + > +--
![]() |