Implement kernel filter support
[lttng-tools.git] / src / bin / lttng-sessiond / save.c
index 908e5f8fd2924d67223ffbdcbf8a04dfc158a502..0c6894b0a91507125cc5f3310fb486af9aa3b52a 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <assert.h>
 #include <inttypes.h>
 #include <string.h>
@@ -509,7 +510,13 @@ int save_kernel_syscall(struct config_writer *writer,
                struct ltt_kernel_event *kevent;
 
                /* Create a temporary kevent in order to save it. */
-               kevent = trace_kernel_create_event(&events[i]);
+               /*
+                * TODO: struct lttng_event does not really work for a filter,
+                * but unfortunately, it is exposed as external API (and used as
+                * internal representation. Using NULL meanwhile.
+                */
+               kevent = trace_kernel_create_event(&events[i],
+                       NULL, NULL);
                if (!kevent) {
                        ret = -ENOMEM;
                        goto end;
@@ -715,6 +722,8 @@ end:
        return ret;
 }
 
+/* TODO: save/restore tracker pid */
+
 static
 int save_kernel_context(struct config_writer *writer,
        struct lttng_kernel_context *ctx)
@@ -1161,7 +1170,8 @@ int save_ust_session(struct config_writer *writer,
 
                ust_chan = caa_container_of(node, struct ltt_ust_channel, node);
                agent_channel = !strcmp(DEFAULT_JUL_CHANNEL_NAME, ust_chan->name) ||
-                       !strcmp(DEFAULT_LOG4J_CHANNEL_NAME, ust_chan->name);
+                       !strcmp(DEFAULT_LOG4J_CHANNEL_NAME, ust_chan->name) ||
+                       !strcmp(DEFAULT_PYTHON_CHANNEL_NAME, ust_chan->name);
                if (!(save_agent ^ agent_channel)) {
                        ret = save_ust_channel(writer, ust_chan, session->ust_session);
                        if (ret) {
@@ -1223,6 +1233,8 @@ int save_domains(struct config_writer *writer, struct ltt_session *session)
        }
 
        if (session->ust_session) {
+               unsigned long agent_count;
+
                ret = config_writer_open_element(writer,
                        config_element_domain);
                if (ret) {
@@ -1241,30 +1253,37 @@ int save_domains(struct config_writer *writer, struct ltt_session *session)
                        ret = LTTNG_ERR_SAVE_IO_FAIL;
                        goto end;
                }
-       }
 
-       if (session->ust_session &&
-                       lttng_ht_get_count(session->ust_session->agents) > 0) {
-               ret = config_writer_open_element(writer,
-                       config_element_domain);
-               if (ret) {
-                       ret = LTTNG_ERR_SAVE_IO_FAIL;
-                       goto end;
-               }
+               rcu_read_lock();
+               agent_count =
+                       lttng_ht_get_count(session->ust_session->agents);
+               rcu_read_unlock();
 
-               ret = save_ust_session(writer, session, 1);
-               if (ret) {
-                       goto end;
-               }
+               if (agent_count > 0) {
+                       ret = config_writer_open_element(writer,
+                               config_element_domain);
+                       if (ret) {
+                               ret = LTTNG_ERR_SAVE_IO_FAIL;
+                               goto end;
+                       }
 
-               /* /domain */
-               ret = config_writer_close_element(writer);
-               if (ret) {
-                       ret = LTTNG_ERR_SAVE_IO_FAIL;
-                       goto end;
+                       ret = save_ust_session(writer, session, 1);
+                       if (ret) {
+                               goto end;
+                       }
+
+                       /* /domain */
+                       ret = config_writer_close_element(writer);
+                       if (ret) {
+                               ret = LTTNG_ERR_SAVE_IO_FAIL;
+                               goto end;
+                       }
                }
        }
 
+       if (session->ust_session) {
+       }
+
        /* /domains */
        ret = config_writer_close_element(writer);
        if (ret) {
This page took 0.024439 seconds and 4 git commands to generate.