#include "../command.h"
#include "../utils.h"
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-
-static int opt_kernel;
-static int opt_userspace;
-static char *opt_session_name;
-
-static struct lttng_handle *handle;
-
-enum {
- OPT_HELP = 1,
- OPT_LIST_OPTIONS,
-};
-
-static struct poptOption long_options[] = {
- /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"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},
- {0, 0, 0, 0, 0, 0, 0}
-};
-
-/*
- * usage
- */
-static void usage(FILE *ofp)
-{
- fprintf(ofp, "usage: lttng disable-consumer [-u|-k] [OPTIONS]\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Disable the consumer for a tracing session. This call can\n");
- fprintf(ofp, "be done BEFORE tracing has started.\n");
- fprintf(ofp, "\n");
- 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, " -k, --kernel Apply to the kernel tracer\n");
- fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n");
- fprintf(ofp, "\n");
-}
-
-/*
- * Disable consumer command.
- */
-static int disable_consumer(char *session_name)
-{
- int ret = CMD_SUCCESS;
- struct lttng_domain dom;
-
- 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 {
- ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
- ret = CMD_ERROR;
- goto error;
- }
-
- handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
- ret = -1;
- goto error;
- }
-
- ret = lttng_disable_consumer(handle);
- if (ret < 0) {
- ERR("Disabling consumer for session %s: %s", session_name,
- lttng_strerror(ret));
- goto error;
- }
-
- MSG("Consumer disabled successfully");
-
-error:
- lttng_destroy_handle(handle);
- return ret;
-}
-
/*
* The 'disable-consumer <options>' first level command
*
*/
int cmd_disable_consumer(int argc, const char **argv)
{
- int opt, ret = CMD_SUCCESS;
- static poptContext pc;
- char *session_name = NULL;
-
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
- poptReadDefaultConfig(pc, 0);
-
- while ((opt = poptGetNextOpt(pc)) != -1) {
- switch (opt) {
- case OPT_HELP:
- usage(stdout);
- goto end;
- case OPT_LIST_OPTIONS:
- list_cmd_options(stdout, long_options);
- goto end;
- default:
- usage(stderr);
- ret = CMD_UNDEFINED;
- goto end;
- }
- }
-
- /* Get session name */
- if (!opt_session_name) {
- session_name = get_session_name();
- if (session_name == NULL) {
- ret = CMD_ERROR;
- goto end;
- }
- } else {
- session_name = opt_session_name;
- }
-
- ret = disable_consumer(session_name);
+ int ret;
-end:
- if (opt_session_name == NULL) {
- free(session_name);
- }
+ MSG("The disable-consumer command is now obsolete.");
+ ret = CMD_WARNING;
- poptFreeContext(pc);
return ret;
}