X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fdisable_consumer.c;h=ca649ecd1518a4df17bde05c010522675df803db;hp=58361db1e7b3a711bed1a4c33f791d2b6c989231;hb=785d2d0dc3aec3a4e44fcf677155dd07e8e4cc1f;hpb=00e2e675d54dc726a7c8f8887c889cc8ef022003 diff --git a/src/bin/lttng/commands/disable_consumer.c b/src/bin/lttng/commands/disable_consumer.c index 58361db1e..ca649ecd1 100644 --- a/src/bin/lttng/commands/disable_consumer.c +++ b/src/bin/lttng/commands/disable_consumer.c @@ -28,91 +28,6 @@ #include "../command.h" #include "../utils.h" -#include -#include -#include - -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 ' first level command * @@ -120,46 +35,10 @@ error: */ 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 obselete."); + ret = CMD_WARNING; - poptFreeContext(pc); return ret; }