From: Jonathan Rajotte Date: Fri, 4 May 2018 18:52:02 +0000 (-0400) Subject: Backport: Use EXTRA_VERSION_NAME and EXTRA_VERSION_DESCRIPTION X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=8ff7624a471a53c1461e6c327ab62ef703feb174 Backport: Use EXTRA_VERSION_NAME and EXTRA_VERSION_DESCRIPTION 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 Signed-off-by: Michael Jeanson --- diff --git a/src/bin/lttng-crash/lttng-crash.c b/src/bin/lttng-crash/lttng-crash.c index ba28af9af..5dbf41c58 100644 --- a/src/bin/lttng-crash/lttng-crash.c +++ b/src/bin/lttng-crash/lttng-crash.c @@ -219,9 +219,10 @@ static void usage(void) static void version(FILE *ofp) { fprintf(ofp, "%s (LTTng Crash Trace Viewer) " VERSION " - " VERSION_NAME -"%s\n", +"%s%s\n", progname, - GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION); + GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION, + EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME); } /* diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index c3c9a4fa6..b44255779 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -59,6 +59,7 @@ #include #include +#include "version.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; -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; @@ -179,6 +180,20 @@ static struct option long_options[] = { 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. @@ -269,8 +284,8 @@ static int set_option(int opt, const char *arg, const char *optname) } 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.", @@ -3208,6 +3223,14 @@ int main(int argc, char **argv) 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 != '/') { diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 125a18769..6c890f1e2 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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 int opt_print_version; /* 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') { - 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")) { @@ -5101,6 +5101,20 @@ end: 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 */ @@ -5675,6 +5689,14 @@ int main(int argc, char **argv) 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; diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index cf46a8cb0..5264872b8 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -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); + 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: diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index b3ee24286..dcbffeb74 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -93,9 +93,10 @@ static struct cmd_struct commands[] = { 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, - GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION); + GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION, + EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME); } /*