+ ret = LTTNG_ERR_BUFFER_NOT_SUPPORTED;
+ goto error;
+ }
+
+ /* Create UST channel */
+ uchan = trace_ust_create_channel(attr, LTTNG_DOMAIN_UST);
+ if (uchan == NULL) {
+ ret = LTTNG_ERR_FATAL;
+ goto error;
+ }
+
+ /*
+ * HACK: Set the channel's subdomain (JUL, Log4j, Python, etc.)
+ * based on the default name.
+ */
+ if (!strcmp(uchan->name, DEFAULT_JUL_CHANNEL_NAME)) {
+ uchan->domain = LTTNG_DOMAIN_JUL;
+ } else if (!strcmp(uchan->name, DEFAULT_LOG4J_CHANNEL_NAME)) {
+ uchan->domain = LTTNG_DOMAIN_LOG4J;
+ } else if (!strcmp(uchan->name, DEFAULT_PYTHON_CHANNEL_NAME)) {
+ uchan->domain = LTTNG_DOMAIN_PYTHON;
+ }
+
+ uchan->enabled = 1;
+ if (trace_ust_is_max_id(usess->used_channel_id)) {
+ ret = LTTNG_ERR_UST_CHAN_FAIL;
+ goto error;
+ }
+ uchan->id = trace_ust_get_next_chan_id(usess);
+
+ DBG2("Channel %s is being created for UST with buffer %d and id %" PRIu64,
+ uchan->name, type, uchan->id);
+
+ /* Flag session buffer type. */
+ if (!usess->buffer_type_changed) {
+ usess->buffer_type = type;
+ usess->buffer_type_changed = 1;
+ } else if (usess->buffer_type != type) {
+ /* Buffer type was already set. Refuse to create channel. */
+ ret = LTTNG_ERR_BUFFER_TYPE_MISMATCH;