Add create trace option validation
authorDavid Goulet <david.goulet@polymtl.ca>
Mon, 2 May 2011 15:23:29 +0000 (11:23 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Mon, 2 May 2011 15:23:29 +0000 (11:23 -0400)
Can't create a trace without a session ID for now.

Future works will create a session automatically.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
lttng/lttng.c

index 52c3e3873d27ce967f6cb3294126b64d269144b8..9751621ff84f2c4fceb2267c5dd1b1ec6f83e1ae 100644 (file)
@@ -46,6 +46,7 @@ static int process_opt_create_session(void);
 static void sighandler(int sig);
 static int set_signal_handler(void);
 static int get_cmdline_by_pid(pid_t pid, char **cmdline);
+static int validate_options(void);
 
 /*
  *  start_client
@@ -104,7 +105,7 @@ static int process_client_opt(void)
                if (ret < 0) {
                        goto end;
                }
-               MSG("Trace created successfully!\nUse --start PID to start tracing");
+               MSG("Trace created successfully!\nUse --start PID to start tracing.");
        }
 
        return 0;
@@ -242,6 +243,29 @@ not_running:
        return 0;
 }
 
+/*
+ *  validate_options
+ *
+ *  Make sure that all options passed to the command line
+ *  are compatible with each others.
+ *
+ *  On error, return -1
+ *  On success, return 0
+ */
+static int validate_options(void)
+{
+       if ((opt_session_uuid == NULL) &&
+                       (opt_create_trace)) {
+               ERR("Can't create trace without a session ID.\nPlease specify using --session UUID");
+               goto error;
+       }
+
+       return 0;
+
+error:
+       return -1;
+}
+
 /*
  *  spawn_sessiond
  *
@@ -421,6 +445,11 @@ int main(int argc, char *argv[])
                clean_exit(EXIT_FAILURE);
        }
 
+       ret = validate_options();
+       if (ret < 0) {
+               return EXIT_FAILURE;
+       }
+
        ret = set_signal_handler();
        if (ret < 0) {
                clean_exit(ret);
This page took 0.025932 seconds and 4 git commands to generate.