diff mbox series

trace-cmd record/extract: Do not destroy existing instances

Message ID 20230601082836.2fc2eb1b@rorschach.local.home (mailing list archive)
State Accepted
Commit 9d6f3baa348ccf2fe79971aac6c42ce8c869094c
Headers show
Series trace-cmd record/extract: Do not destroy existing instances | expand

Commit Message

Steven Rostedt June 1, 2023, 12:28 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Do not destroy an instance that already exists when trace-cmd record or
extract is executed. There may be state that the user still would like to
know about the instance. When doing an extract, it should not delete the
instance when it is finished.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-record.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 32fbfef58c26..ded9ea1a04e2 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -5295,7 +5295,8 @@  void tracecmd_remove_instances(void)
 			close(instance->tracing_on_fd);
 			instance->tracing_on_fd = 0;
 		}
-		tracefs_instance_destroy(instance->tracefs);
+		if (tracefs_instance_is_new(instance->tracefs))
+			tracefs_instance_destroy(instance->tracefs);
 	}
 }
 
@@ -6055,7 +6056,8 @@  static inline void remove_instances(struct buffer_instance *instances)
 		del = instances;
 		instances = instances->next;
 		free(del->name);
-		tracefs_instance_destroy(del->tracefs);
+		if (tracefs_instance_is_new(del->tracefs))
+			tracefs_instance_destroy(del->tracefs);
 		tracefs_instance_free(del->tracefs);
 		free(del);
 	}