X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fenable_consumer.c;h=6a635f424bb9c90b0693f6b8a35eb58b7396c371;hp=0a61362220b80138dde5ee4a192ddb29639f0662;hb=81ffed9c49284d91e2fa05a88050e187d5b325ae;hpb=a4b92340642035d1eafeb1eead0ad01f64d2007d diff --git a/src/bin/lttng/commands/enable_consumer.c b/src/bin/lttng/commands/enable_consumer.c index 0a6136222..6a635f424 100644 --- a/src/bin/lttng/commands/enable_consumer.c +++ b/src/bin/lttng/commands/enable_consumer.c @@ -78,7 +78,7 @@ static void usage(FILE *ofp) fprintf(ofp, "Options:\n"); fprintf(ofp, " -h, --help Show this help\n"); fprintf(ofp, " --list-options Simple listing of options\n"); - fprintf(ofp, " -s, --session=NAME Apply to session name\n"); + fprintf(ofp, " -s, --session NAME Apply to session name\n"); fprintf(ofp, " -k, --kernel Apply to the kernel tracer\n"); fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n"); fprintf(ofp, "\n"); @@ -107,7 +107,7 @@ static void usage(FILE *ofp) fprintf(ofp, " > file://...\n"); fprintf(ofp, " Local filesystem full path.\n"); fprintf(ofp, "\n"); - fprintf(ofp, " > net[4|6]://...\n"); + fprintf(ofp, " > net[6]://...\n"); fprintf(ofp, " This will use the default network transport layer which is\n"); fprintf(ofp, " TCP for both control (PORT1) and data port (PORT2).\n"); fprintf(ofp, " The default ports are respectively 5342 and 5343.\n"); @@ -126,7 +126,7 @@ static void usage(FILE *ofp) /* * Enable consumer command. */ -static int enable_consumer(char *session_name) +static int enable_consumer(char *session_name, int domain) { int ret = CMD_SUCCESS; int run_enable_cmd = 1; @@ -134,21 +134,7 @@ static int enable_consumer(char *session_name) memset(&dom, 0, sizeof(dom)); - /* Create lttng domain */ - if (opt_kernel) { - dom.type = LTTNG_DOMAIN_KERNEL; - } else if (opt_userspace) { - dom.type = LTTNG_DOMAIN_UST; - } else { - /* - * Set handle with domain set to 0. This means to the session daemon - * that the next action applies on the tracing session rather then the - * domain specific session. - * - * XXX: This '0' value should be a domain enum value. - */ - dom.type = 0; - } + dom.type = domain; handle = lttng_create_handle(session_name, &dom); if (handle == NULL) { @@ -164,7 +150,9 @@ static int enable_consumer(char *session_name) goto error; } - MSG("URL %s set for session %s.", opt_url_arg, session_name); + MSG("URL %s set for %s session %s.", opt_url_arg, + (domain == LTTNG_DOMAIN_KERNEL) ? "kernel" : "UST", + session_name); } /* Handling URLs (-U opt) */ @@ -178,7 +166,9 @@ static int enable_consumer(char *session_name) /* opt_enable will tell us to run or not the enable_consumer cmd. */ run_enable_cmd = 0; - MSG("URL %s set for session %s.", opt_url, session_name); + MSG("URL %s set for %s session %s.", opt_url, + (domain == LTTNG_DOMAIN_KERNEL) ? "kernel" : "UST", + session_name); } /* Setting up control URL (-C or/and -D opt) */ @@ -193,12 +183,15 @@ static int enable_consumer(char *session_name) run_enable_cmd = 0; if (opt_ctrl_url) { - MSG("Control URL %s set for session %s.", opt_ctrl_url, + MSG("Control URL %s set for %s session %s.", opt_ctrl_url, + (domain == LTTNG_DOMAIN_KERNEL) ? "kernel" : "UST", session_name); } if (opt_data_url) { - MSG("Data URL %s set for session %s.", opt_data_url, session_name); + MSG("Data URL %s set for %s session %s.", opt_data_url, + (domain == LTTNG_DOMAIN_KERNEL) ? "kernel" : "UST", + session_name); } } @@ -208,7 +201,7 @@ static int enable_consumer(char *session_name) if (ret < 0) { ERR("Enabling consumer for session %s: %s", session_name, lttng_strerror(ret)); - if (ret == -LTTCOMM_ENABLE_CONSUMER_FAIL) { + if (ret == -LTTNG_ERR_ENABLE_CONSUMER_FAIL) { ERR("Perhaps the session was previously started?"); } goto error; @@ -265,7 +258,19 @@ int cmd_enable_consumer(int argc, const char **argv) session_name = opt_session_name; } - ret = enable_consumer(session_name); + if (opt_kernel || (!opt_kernel && !opt_userspace)) { + ret = enable_consumer(session_name, LTTNG_DOMAIN_KERNEL); + if (ret < 0) { + goto end; + } + } + + if (opt_userspace || (!opt_kernel && !opt_userspace)) { + ret = enable_consumer(session_name, LTTNG_DOMAIN_UST); + if (ret < 0) { + goto end; + } + } end: if (opt_session_name == NULL) {