+/*
+ * Create the specified channel onto the UST tracer for a UST session.
+ */
+static int create_ust_channel(struct ust_app *app,
+ struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan)
+{
+ int ret;
+
+ /* TODO: remove cast and use lttng-ust-abi.h */
+ ret = ustctl_create_channel(app->key.sock, ua_sess->handle,
+ (struct lttng_ust_channel_attr *)&ua_chan->attr, &ua_chan->obj);
+ if (ret < 0) {
+ DBG("Error creating channel %s for app (pid: %d, sock: %d) "
+ "and session handle %d with ret %d",
+ ua_chan->name, app->key.pid, app->key.sock,
+ ua_sess->handle, ret);
+ goto error;
+ }
+
+ ua_chan->handle = ua_chan->obj->handle;
+ ua_chan->attr.shm_fd = ua_chan->obj->shm_fd;
+ ua_chan->attr.wait_fd = ua_chan->obj->wait_fd;
+ ua_chan->attr.memory_map_size = ua_chan->obj->memory_map_size;
+
+ DBG2("UST app channel %s created successfully for pid:%d and sock:%d",
+ ua_chan->name, app->key.pid, app->key.sock);
+
+error:
+ return ret;
+}
+
+/*
+ * Create the specified event onto the UST tracer for a UST session.
+ */
+static int create_ust_event(struct ust_app *app,
+ struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan,
+ struct ust_app_event *ua_event)
+{
+ int ret = 0;
+
+ /* Create UST event on tracer */
+ ret = ustctl_create_event(app->key.sock, &ua_event->attr, ua_chan->obj,
+ &ua_event->obj);
+ if (ret < 0) {
+ ERR("Error ustctl create event %s for app pid: %d with ret %d",
+ ua_event->attr.name, app->key.pid, ret);
+ goto error;
+ }
+
+ ua_event->handle = ua_event->obj->handle;
+ ua_event->enabled = 1;
+
+ DBG2("UST app event %s created successfully for pid:%d",
+ ua_event->attr.name, app->key.pid);
+
+error:
+ return ret;
+}
+