+ if (traces->len > 1) {
+ struct ctf_fs_trace *first_trace = (struct ctf_fs_trace *) traces->pdata[0];
+ const uint8_t *first_trace_uuid = first_trace->metadata->tc->uuid;
+ struct ctf_fs_trace *trace;
+
+ /*
+ * We have more than one trace, they must all share the same
+ * UUID, verify that.
+ */
+ for (i = 0; i < traces->len; i++) {
+ struct ctf_fs_trace *this_trace =
+ (struct ctf_fs_trace *) traces->pdata[i];
+ const uint8_t *this_trace_uuid = this_trace->metadata->tc->uuid;
+
+ if (!this_trace->metadata->tc->is_uuid_set) {
+ BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
+ "Multiple traces given, but a trace does not have a UUID: path=%s",
+ this_trace->path->str);
+ goto error;
+ }
+
+ if (bt_uuid_compare(first_trace_uuid, this_trace_uuid) != 0) {
+ char first_trace_uuid_str[BT_UUID_STR_LEN + 1];
+ char this_trace_uuid_str[BT_UUID_STR_LEN + 1];
+
+ bt_uuid_to_str(first_trace_uuid, first_trace_uuid_str);
+ bt_uuid_to_str(this_trace_uuid, this_trace_uuid_str);
+
+ BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
+ "Multiple traces given, but UUIDs don't match: "
+ "first-trace-uuid=%s, first-trace-path=%s, "
+ "trace-uuid=%s, trace-path=%s",
+ first_trace_uuid_str, first_trace->path->str,
+ this_trace_uuid_str, this_trace->path->str);
+ goto error;
+ }
+ }
+
+ ret = merge_ctf_fs_traces((struct ctf_fs_trace **) traces->pdata,
+ traces->len, &trace);
+ if (ret) {
+ BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
+ "Failed to merge traces with the same UUID.");
+ goto error;
+ }
+
+ ctf_fs->trace = trace;
+ } else {
+ /* Just one trace, it may or may not have a UUID, both are fine. */
+ ctf_fs->trace = traces->pdata[0];
+ traces->pdata[0] = NULL;