Fix: sessions with agent channels fail to load
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 16 May 2018 22:32:38 +0000 (18:32 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 17 May 2018 03:20:14 +0000 (23:20 -0400)
Channels of the "agent" types cannot be created directly. They are
meant to be created implicitly through the activation of events in
their domain.

However, a user can override the default channel configuration
attributes by creating the underlying UST channel before enabling an
agent domain event.

Hence, the channel's type is substituted before the creation and
restored by the time events are created.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/config/session-config.c

index 8b91f32d5aebf47f6a05af102bb3358c069155b7..0d75a088d402e17076b53994fb6f6915b0d8f13c 100644 (file)
@@ -2437,10 +2437,31 @@ int process_domain_node(xmlNodePtr domain_node, const char *session_name)
        /* create all channels */
        for (node = xmlFirstElementChild(channels_node); node;
                node = xmlNextElementSibling(node)) {
        /* create all channels */
        for (node = xmlFirstElementChild(channels_node); node;
                node = xmlNextElementSibling(node)) {
+               const enum lttng_domain_type original_domain = domain.type;
                xmlNodePtr contexts_node = NULL;
                xmlNodePtr events_node = NULL;
                xmlNodePtr channel_attr_node;
 
                xmlNodePtr contexts_node = NULL;
                xmlNodePtr events_node = NULL;
                xmlNodePtr channel_attr_node;
 
+               /*
+                * Channels of the "agent" types cannot be created directly.
+                * They are meant to be created implicitly through the
+                * activation of events in their domain. However, a user
+                * can override the default channel configuration attributes
+                * by creating the underlying UST channel _before_ enabling
+                * an agent domain event.
+                *
+                * Hence, the channel's type is substituted before the creation
+                * and restored by the time the events are created.
+                */
+               switch (domain.type) {
+               case LTTNG_DOMAIN_JUL:
+               case LTTNG_DOMAIN_LOG4J:
+               case LTTNG_DOMAIN_PYTHON:
+                       domain.type = LTTNG_DOMAIN_UST;
+               default:
+                       break;
+               }
+
                channel = lttng_channel_create(&domain);
                if (!channel) {
                        ret = -1;
                channel = lttng_channel_create(&domain);
                if (!channel) {
                        ret = -1;
@@ -2462,6 +2483,9 @@ int process_domain_node(xmlNodePtr domain_node, const char *session_name)
                        goto end;
                }
 
                        goto end;
                }
 
+               /* Restore the original channel domain. */
+               domain.type = original_domain;
+
                ret = process_events_node(events_node, handle, channel->name);
                if (ret) {
                        goto end;
                ret = process_events_node(events_node, handle, channel->name);
                if (ret) {
                        goto end;
This page took 0.036391 seconds and 4 git commands to generate.