On Thu, Feb 14, 2019 at 03:05:20PM -0500, Steven Rostedt wrote: > On Thu, 14 Feb 2019 16:13:28 +0200 > Slavomir Kaslev <kaslevs@xxxxxxxxxx> wrote: > > > Add BUFFER_FL_GUEST and BUFFER_FL_AGENT flags to differentiate when > > trace-record.c is being called to trace guest or the VM tracing agent. > > > > Also disable functions talking to the local tracefs when called in recording > > guest instances context. > > > > Signed-off-by: Slavomir Kaslev <kaslevs@xxxxxxxxxx> > > --- > > tracecmd/include/trace-local.h | 2 ++ > > tracecmd/trace-record.c | 55 ++++++++++++++++++++++++++++++++-- > > 2 files changed, 55 insertions(+), 2 deletions(-) > > > > diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h > > index a1a06e9..f19c8bb 100644 > > --- a/tracecmd/include/trace-local.h > > +++ b/tracecmd/include/trace-local.h > > @@ -149,6 +149,8 @@ char *strstrip(char *str); > > enum buffer_instance_flags { > > BUFFER_FL_KEEP = 1 << 0, > > BUFFER_FL_PROFILE = 1 << 1, > > + BUFFER_FL_GUEST = 1 << 2, > > + BUFFER_FL_AGENT = 1 << 3, > > }; > > > > struct func_list { > > diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c > > index 8beefab..107d3d1 100644 > > --- a/tracecmd/trace-record.c > > +++ b/tracecmd/trace-record.c > > @@ -781,6 +781,9 @@ static void __clear_trace(struct buffer_instance *instance) > > FILE *fp; > > char *path; > > > > + if (instance->flags & BUFFER_FL_GUEST) > > + return; > > + > > /* reset the trace */ > > path = get_instance_file(instance, "trace"); > > fp = fopen(path, "w"); > > @@ -1264,6 +1267,9 @@ set_plugin_instance(struct buffer_instance *instance, const char *name) > > char *path; > > char zero = '0'; > > > > + if (instance->flags & BUFFER_FL_GUEST) > > + return; > > + > > path = get_instance_file(instance, "current_tracer"); > > fp = fopen(path, "w"); > > if (!fp) { > > @@ -1360,6 +1366,9 @@ static void disable_func_stack_trace_instance(struct buffer_instance *instance) > > int size; > > int ret; > > > > + if (instance->flags & BUFFER_FL_GUEST) > > + return; > > + > > path = get_instance_file(instance, "current_tracer"); > > ret = stat(path, &st); > > tracecmd_put_tracing_file(path); > > > I think we should add a: > > #define is_guest(instance) ((instance)->flags & BUFFER_FL_GUEST) > > Helper macro here, and all these should be turned into: > > if (is_guest(instance)) > return; > > Less error prone, and looks cleaner. > > We could add a is_agent() too in later patches. Makes sense. I added both is_agent and is_guest for the next iteration of this patchset.
![]() |