Add ust create trace feature
[lttng-tools.git] / liblttngctl / liblttngctl.c
index fda45ae10d2bc423dea61b94f3a2521c5c074b0c..a586b34f53a61d2ba6dd630204325d1f71a31835 100644 (file)
@@ -35,6 +35,7 @@ static char sessiond_sock_path[PATH_MAX];
 
 /* Communication structure to ltt-sessiond */
 static struct lttcomm_session_msg lsm;
+static struct lttcomm_lttng_msg llm;
 
 /* Prototypes */
 static int check_tracing_group(const char *grp_name);
@@ -109,7 +110,6 @@ static int ask_sessiond(enum lttcomm_command_type lct, void **buf)
        int ret;
        size_t size;
        void *data = NULL;
-       struct lttcomm_lttng_msg llm;
 
        lsm.cmd_type = lct;
 
@@ -167,6 +167,21 @@ const char *lttng_get_readable_code(int code)
        return lttcomm_get_readable_code(code);
 }
 
+/*
+ *  lttng_ust_create_trace
+ *
+ *  Request a trace creation for pid.
+ */
+int lttng_ust_create_trace(pid_t pid)
+{
+       int ret;
+
+       lsm.pid = pid;
+       ret = ask_sessiond(UST_CREATE_TRACE, NULL);
+
+       return ret;
+}
+
 /*
  *  lttng_ust_list_apps
  *
@@ -188,6 +203,50 @@ int lttng_ust_list_apps(pid_t **pids)
        return ret / sizeof(pid_t);
 }
 
+/*
+ *  lttng_create_session
+ *
+ *  Create a brand new session using name. Allocate
+ *  the session_id param pointing to the UUID.
+ */
+int lttng_create_session(char *name, uuid_t *session_id)
+{
+       int ret;
+
+       strncpy(lsm.session_name, name, sizeof(lsm.session_name));
+       lsm.session_name[sizeof(lsm.session_name) - 1] = '\0';
+
+       ret = ask_sessiond(LTTNG_CREATE_SESSION, NULL);
+       if (ret < 0) {
+               goto end;
+       }
+
+       uuid_copy(*session_id, llm.session_id);
+
+end:
+       return ret;
+}
+
+/*
+ *  lttng_destroy_session
+ *
+ *  Destroy session using name.
+ */
+int lttng_destroy_session(uuid_t *uuid)
+{
+       int ret;
+
+       uuid_copy(lsm.session_id, *uuid);
+
+       ret = ask_sessiond(LTTNG_DESTROY_SESSION, NULL);
+       if (ret < 0) {
+               goto end;
+       }
+
+end:
+       return ret;
+}
+
 /*
  *  lttng_list_sessions
  *
@@ -236,6 +295,34 @@ int lttng_connect_sessiond(void)
        return 0;
 }
 
+/*
+ *  lttng_disconnect_sessiond
+ *
+ *  Clean disconnect the session daemon.
+ */
+int lttng_disconnect_sessiond(void)
+{
+       int ret = 0;
+
+       if (connected) {
+               ret = lttcomm_close_unix_sock(sessiond_socket);
+               sessiond_socket = 0;
+               connected = 0;
+       }
+
+       return ret;
+}
+
+/*
+ *  lttng_set_current_session_uuid
+ *
+ *  Set the session uuid for current lsm.
+ */
+void lttng_set_current_session_uuid(char *uuid)
+{
+       uuid_parse(uuid, lsm.session_id);
+}
+
 /*
  *  lttng_set_tracing_group
  *
This page took 0.023626 seconds and 4 git commands to generate.