Backport: Use EXTRA_VERSION_NAME and EXTRA_VERSION_DESCRIPTION
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 4 May 2018 18:52:02 +0000 (14:52 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 21 Sep 2018 04:00:52 +0000 (00:00 -0400)
Backport:
    For sessiond add the sessiond_config_log function for verbose
    Printing of the version since config-sessiond does not exist in 2.9.
===

Add detailed version information to the debug log of lttng-relayd and
lttng-sessiond.

Append the extra version information at the end of the "version" command
of the lttng binary.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
src/bin/lttng-crash/lttng-crash.c
src/bin/lttng-relayd/main.c
src/bin/lttng-sessiond/main.c
src/bin/lttng/commands/version.c
src/bin/lttng/lttng.c

index ba28af9afa9003f2f92decb5ade2275634b38a02..5dbf41c583cf93437c97f62ed2566ef88cefa0d3 100644 (file)
@@ -219,9 +219,10 @@ static void usage(void)
 static void version(FILE *ofp)
 {
        fprintf(ofp, "%s (LTTng Crash Trace Viewer) " VERSION " - " VERSION_NAME
 static void version(FILE *ofp)
 {
        fprintf(ofp, "%s (LTTng Crash Trace Viewer) " VERSION " - " VERSION_NAME
-"%s\n",
+"%s%s\n",
                        progname,
                        progname,
-                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION);
+                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+                       EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
 }
 
 /*
 }
 
 /*
index c3c9a4fa667bd38c7ec0d866c402d5bf736d39f3..b44255779460289557b7f10640bf14da9f2a190a 100644 (file)
@@ -59,6 +59,7 @@
 #include <common/buffer-view.h>
 #include <urcu/rculist.h>
 
 #include <common/buffer-view.h>
 #include <urcu/rculist.h>
 
+#include "version.h"
 #include "cmd.h"
 #include "ctf-trace.h"
 #include "index.h"
 #include "cmd.h"
 #include "ctf-trace.h"
 #include "index.h"
@@ -84,7 +85,7 @@ enum relay_connection_status {
 
 /* command line options */
 char *opt_output_path, *opt_working_directory;
 
 /* command line options */
 char *opt_output_path, *opt_working_directory;
-static int opt_daemon, opt_background;
+static int opt_daemon, opt_background, opt_print_version;
 int opt_group_output_by_session;
 int opt_group_output_by_host;
 
 int opt_group_output_by_session;
 int opt_group_output_by_host;
 
@@ -179,6 +180,20 @@ static struct option long_options[] = {
 
 static const char *config_ignore_options[] = { "help", "config", "version" };
 
 
 static const char *config_ignore_options[] = { "help", "config", "version" };
 
+static void print_version(void) {
+       fprintf(stdout, "%s\n", VERSION);
+}
+
+static void relayd_config_log(void)
+{
+       DBG("LTTng-relayd " VERSION " - " VERSION_NAME "%s%s",
+                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+                       EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
+       if (EXTRA_VERSION_DESCRIPTION[0] != '\0') {
+               DBG("LTTng-relayd extra version description:\n\t" EXTRA_VERSION_DESCRIPTION "\n");
+       }
+}
+
 /*
  * Take an option from the getopt output and set it in the right variable to be
  * used later.
 /*
  * Take an option from the getopt output and set it in the right variable to be
  * used later.
@@ -269,8 +284,8 @@ static int set_option(int opt, const char *arg, const char *optname)
                }
                exit(EXIT_FAILURE);
        case 'V':
                }
                exit(EXIT_FAILURE);
        case 'V':
-               fprintf(stdout, "%s\n", VERSION);
-               exit(EXIT_SUCCESS);
+               opt_print_version = 1;
+               break;
        case 'o':
                if (lttng_is_setuid_setgid()) {
                        WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
        case 'o':
                if (lttng_is_setuid_setgid()) {
                        WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
@@ -3208,6 +3223,14 @@ int main(int argc, char **argv)
                goto exit_options;
        }
 
                goto exit_options;
        }
 
+       relayd_config_log();
+
+       if (opt_print_version) {
+               print_version();
+               retval = 0;
+               goto exit_options;
+       }
+
        /* Try to create directory if -o, --output is specified. */
        if (opt_output_path) {
                if (*opt_output_path != '/') {
        /* Try to create directory if -o, --output is specified. */
        if (opt_output_path) {
                if (*opt_output_path != '/') {
index 125a18769107269322813923d438e51f062694ae..6c890f1e22424e9da9d75077ac3db5818a26ab7a 100644 (file)
@@ -90,6 +90,7 @@ static pid_t ppid;          /* Parent PID for --sig-parent option */
 static pid_t child_ppid;    /* Internal parent PID use with daemonize. */
 static char *rundir;
 static int lockfile_fd = -1;
 static pid_t child_ppid;    /* Internal parent PID use with daemonize. */
 static char *rundir;
 static int lockfile_fd = -1;
+static int opt_print_version;
 
 /* Set to 1 when a SIGUSR1 signal is received. */
 static int recv_child_signal;
 
 /* Set to 1 when a SIGUSR1 signal is received. */
 static int recv_child_signal;
@@ -4760,8 +4761,7 @@ static int set_option(int opt, const char *arg, const char *optname)
                }
                exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
        } else if (string_match(optname, "version") || opt == 'V') {
                }
                exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
        } else if (string_match(optname, "version") || opt == 'V') {
-               fprintf(stdout, "%s\n", VERSION);
-               exit(EXIT_SUCCESS);
+               opt_print_version = 1;
        } else if (string_match(optname, "sig-parent") || opt == 'S') {
                opt_sig_parent = 1;
        } else if (string_match(optname, "kconsumerd-err-sock")) {
        } else if (string_match(optname, "sig-parent") || opt == 'S') {
                opt_sig_parent = 1;
        } else if (string_match(optname, "kconsumerd-err-sock")) {
@@ -5101,6 +5101,20 @@ end:
        return ret;
 }
 
        return ret;
 }
 
+static void sessiond_config_log(void)
+{
+       DBG("LTTng-sessiond " VERSION " - " VERSION_NAME "%s%s",
+                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+                       EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
+       if (EXTRA_VERSION_DESCRIPTION[0] != '\0') {
+               DBG("LTTng-sessiond extra version description:\n\t" EXTRA_VERSION_DESCRIPTION "\n");
+       }
+}
+
+static void print_version(void) {
+       fprintf(stdout, "%s\n", VERSION);
+}
+
 /*
  * daemon configuration loading and argument parsing
  */
 /*
  * daemon configuration loading and argument parsing
  */
@@ -5675,6 +5689,14 @@ int main(int argc, char **argv)
                goto exit_options;
        }
 
                goto exit_options;
        }
 
+       sessiond_config_log();
+
+       if (opt_print_version) {
+               print_version();
+               retval = 0;
+               goto exit_options;
+       }
+
        ret = set_clock_plugin_env();
        if (ret) {
                retval = -1;
        ret = set_clock_plugin_env();
        if (ret) {
                retval = -1;
index cf46a8cb0e32fe7f3e1b35ed1dffa43d41dd0a90..5264872b89f7d17abcefbe7969f565fa6e639b84 100644 (file)
@@ -154,6 +154,12 @@ int cmd_version(int argc, const char **argv)
                MSG("\n" VERSION_DESCRIPTION "\n");
                MSG("Web site: http://lttng.org");
                MSG("\n%s", lttng_license);
                MSG("\n" VERSION_DESCRIPTION "\n");
                MSG("Web site: http://lttng.org");
                MSG("\n%s", lttng_license);
+               if (EXTRA_VERSION_NAME[0] != '\0') {
+                       MSG("\nExtra version name: " EXTRA_VERSION_NAME);
+               }
+               if (EXTRA_VERSION_DESCRIPTION[0] != '\0') {
+                       MSG("\nExtra version description:\n\t" EXTRA_VERSION_DESCRIPTION);
+               }
        }
 
 end:
        }
 
 end:
index b3ee2428640f945d1b4bf68736f1c2a91469edc0..dcbffeb74c438e5b8a725a798c3e972506e4b856 100644 (file)
@@ -93,9 +93,10 @@ static struct cmd_struct commands[] =  {
 
 static void version(FILE *ofp)
 {
 
 static void version(FILE *ofp)
 {
-       fprintf(ofp, "%s (LTTng Trace Control) " VERSION" - " VERSION_NAME "%s\n",
+       fprintf(ofp, "%s (LTTng Trace Control) " VERSION" - " VERSION_NAME "%s%s\n",
                        progname,
                        progname,
-                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION);
+                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+                       EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
 }
 
 /*
 }
 
 /*
This page took 0.03408 seconds and 5 git commands to generate.