- /* Start all UST traces */
- cds_list_for_each_entry(ustsession, &session->ust_session_list.head, list) {
- struct ltt_ust_channel *ustchan;
-
- /* Open kernel metadata */
- if (ustsession->metadata == NULL) {
- struct lttng_ust_channel_attr ustattr;
-
- /* Allocate UST metadata */
- ustsession->metadata = trace_ust_create_metadata(ustsession->path);
- if (ustsession->metadata == NULL) {
- ret = LTTCOMM_UST_META_FAIL;
- goto error;
- }
-
- ustattr.overwrite = ustsession->metadata->attr.overwrite;
- ustattr.subbuf_size = ustsession->metadata->attr.subbuf_size;
- ustattr.num_subbuf = ustsession->metadata->attr.num_subbuf;
- ustattr.switch_timer_interval = ustsession->metadata->attr.switch_timer_interval;
- ustattr.read_timer_interval = ustsession->metadata->attr.read_timer_interval;
- ustattr.output = ustsession->metadata->attr.output;
-
- /* UST tracer metadata creation */
- ret = ustctl_open_metadata(ustsession->sock,
- ustsession->handle, &ustattr,
- &ustsession->metadata->obj);
- if (ret < 0) {
- ret = LTTCOMM_UST_META_FAIL;
- goto error;
- }
- }
-
- /* Open UST metadata stream */
- if (ustsession->metadata->stream_obj == NULL) {
- ret = ustctl_create_stream(ustsession->sock,
- ustsession->metadata->obj,
- &ustsession->metadata->stream_obj);
- if (ret < 0) {
- ERR("UST create metadata stream failed");
- ret = LTTCOMM_UST_STREAM_FAIL;
- goto error;
- }
- ret = asprintf(&ustsession->metadata->pathname, "%s/%s",
- ustsession->path, "metadata");
- if (ret < 0) {
- perror("asprintf UST create stream");
- goto error;
- }
- }
-
- /* For each channel */
- cds_list_for_each_entry(ustchan, &ustsession->channels.head, list) {
- if (ustchan->stream_count == 0) {
- struct ltt_ust_stream *ustream;
-
- ustream = zmalloc(sizeof(*ustream));
- if (!ustream) {
- ret = LTTCOMM_UST_STREAM_FAIL;
- goto error;
- }
- ret = ustctl_create_stream(ustsession->sock,
- ustchan->obj, &ustream->obj);
- if (ret < 0) {
- ret = LTTCOMM_UST_STREAM_FAIL;
- goto error;
- }
- ret = asprintf(&ustream->pathname, "%s/%s_%d",
- ustchan->trace_path, ustchan->name,
- ustchan->stream_count);
- if (ret < 0) {
- perror("asprintf UST create stream");
- goto error;
- }
- cds_list_add(&ustream->list, &ustchan->stream_list.head);
- ustchan->stream_count++;
- }
- }
-
- /* Setup UST consumer socket and send fds to it */
- ret = init_ust_tracing(ustsession);
- if (ret < 0) {
- ret = LTTCOMM_UST_START_FAIL;
- goto error;
- }
-
- /* This start the UST tracing */
- ret = ustctl_start_session(ustsession->sock, ustsession->handle);
- if (ret < 0) {
- ret = LTTCOMM_UST_START_FAIL;
- goto error;
- }
-
- /* Quiescent wait after starting trace */
- ustctl_wait_quiescent(ustsession->sock);