rotation-api: pass session name explicitly
[lttng-tools.git] / src / bin / lttng / commands / disable_rotation.c
index b0de06d9f99ec5399da5498da34d9009c86fd9df..b179e91ce33e8f91e94a3d741d9ef7a0a34e03ab 100644 (file)
 static char *opt_session_name;
 static struct mi_writer *writer;
 
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-disable-rotation.1.h>
+;
+#endif
+
 enum {
        OPT_HELP = 1,
        OPT_LIST_OPTIONS,
        OPT_TIMER,
+       OPT_SIZE,
 };
 
 static struct poptOption long_options[] = {
@@ -47,10 +54,11 @@ static struct poptOption long_options[] = {
        {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
        {"session",     's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
        {"timer",        0,   POPT_ARG_NONE, 0, OPT_TIMER, 0, 0},
+       {"size",         0,   POPT_ARG_NONE, 0, OPT_SIZE, 0, 0},
        {0, 0, 0, 0, 0, 0, 0}
 };
 
-static int setup_rotate(char *session_name, uint64_t timer)
+static int setup_rotate(char *session_name, uint64_t timer, uint64_t size)
 {
        int ret = 0;
        struct lttng_rotation_schedule_attr *attr = NULL;
@@ -69,11 +77,6 @@ static int setup_rotate(char *session_name, uint64_t timer)
                }
        }
 
-       ret = lttng_rotation_schedule_attr_set_session_name(attr, session_name);
-       if (ret < 0) {
-               goto error;
-       }
-
        if (lttng_opt_mi) {
                ret = mi_lttng_writer_write_element_string(writer,
                                mi_lttng_element_session_name, session_name);
@@ -86,8 +89,12 @@ static int setup_rotate(char *session_name, uint64_t timer)
                lttng_rotation_schedule_attr_set_timer_period(attr, timer);
                MSG("Disabling rotation timer on session %s", session_name);
        }
+       if (size == -1ULL) {
+               lttng_rotation_schedule_attr_set_size(attr, size);
+               MSG("Disabling rotation based on size on session %s", session_name);
+       }
 
-       ret = lttng_rotation_set_schedule(attr);
+       ret = lttng_rotation_set_schedule(session_name, attr);
        if (ret) {
                ERR("%s", lttng_strerror(ret));
                if (lttng_opt_mi) {
@@ -140,7 +147,7 @@ int cmd_disable_rotation(int argc, const char **argv)
        static poptContext pc;
        char *session_name = NULL;
        bool free_session_name = false;
-       uint64_t timer = 0;
+       uint64_t timer = 0, size = 0;
 
        pc = poptGetContext(NULL, argc, argv, long_options, 0);
        popt_ret = poptReadDefaultConfig(pc, 0);
@@ -161,6 +168,9 @@ int cmd_disable_rotation(int argc, const char **argv)
                case OPT_TIMER:
                        timer = -1ULL;
                        break;
+               case OPT_SIZE:
+                       size = -1ULL;
+                       break;
                default:
                        ret = CMD_UNDEFINED;
                        goto end;
@@ -203,12 +213,12 @@ int cmd_disable_rotation(int argc, const char **argv)
        }
 
        /* No config options, just rotate the session now */
-       if (timer == 0) {
-               ERR("No timer given");
+       if (timer == 0 && size == 0) {
+               ERR("Missing timer period (--timer) or size limit (--size) option");
                success = 0;
                command_ret = -1;
        } else {
-               command_ret = setup_rotate(session_name, timer);
+               command_ret = setup_rotate(session_name, timer, size);
        }
 
        if (command_ret) {
This page took 0.024161 seconds and 4 git commands to generate.