{"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
{"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
{"userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0},
- {"set-uri", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0},
- {"ctrl-uri", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0},
- {"data-uri", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0},
+ {"set-url", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0},
+ {"ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0},
+ {"data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0},
{"enable", 'e', POPT_ARG_VAL, &opt_enable, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
};
fprintf(ofp, "Using these options, each API call can be controlled individually.\n");
fprintf(ofp, "For instance, -C does not enable the consumer automatically.\n");
fprintf(ofp, "\n");
- fprintf(ofp, " -U, --set-uri=URL Set URL for the enable-consumer destination.\n");
+ fprintf(ofp, " -U, --set-url=URL Set URL for the enable-consumer destination.\n");
fprintf(ofp, " It is persistent for the session lifetime.\n");
fprintf(ofp, " Redo the command to change it.\n");
fprintf(ofp, " This will set both data and control URL for network.\n");
/*
* 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;
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) {
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) */
/* 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) */
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);
}
}
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) {