+/*
+ * Add context to a specific event in a channel for global UST domain.
+ */
+int ust_app_set_filter_event_glb(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
+ struct lttng_filter_bytecode *bytecode)
+{
+ int ret = 0;
+ struct lttng_ht_node_str *ua_chan_node, *ua_event_node;
+ struct lttng_ht_iter iter, uiter;
+ struct ust_app_session *ua_sess;
+ struct ust_app_event *ua_event;
+ struct ust_app_channel *ua_chan = NULL;
+ struct ust_app *app;
+
+ rcu_read_lock();
+
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ if (!app->compatible) {
+ /*
+ * TODO: In time, we should notice the caller of this error by
+ * telling him that this is a version error.
+ */
+ continue;
+ }
+ ua_sess = lookup_session_by_app(usess, app);
+ if (ua_sess == NULL) {
+ continue;
+ }
+
+ /* Lookup channel in the ust app session */
+ lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter);
+ ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
+ if (ua_chan_node == NULL) {
+ continue;
+ }
+ ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel,
+ node);
+
+ lttng_ht_lookup(ua_chan->events, (void *)uevent->attr.name, &uiter);
+ ua_event_node = lttng_ht_iter_get_node_str(&uiter);
+ if (ua_event_node == NULL) {
+ continue;
+ }
+ ua_event = caa_container_of(ua_event_node, struct ust_app_event,
+ node);
+
+ ret = set_ust_app_event_filter(ua_sess, ua_event, bytecode, app);
+ if (ret < 0) {
+ continue;
+ }
+ }
+
+ rcu_read_unlock();
+ return ret;
+}
+