projects
/
lttng-tools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
27babd3
)
Implement lttng create --snapshot command
author
David Goulet
<dgoulet@efficios.com>
Mon, 8 Jul 2013 19:19:28 +0000
(15:19 -0400)
committer
David Goulet
<dgoulet@efficios.com>
Fri, 12 Jul 2013 15:06:38 +0000
(11:06 -0400)
This is to ease the life of the user creating a session in snapshot
mode using the new API call.
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng/commands/create.c
patch
|
blob
|
blame
|
history
diff --git
a/src/bin/lttng/commands/create.c
b/src/bin/lttng/commands/create.c
index 72702d5a54743a1d91a652ebb6707ff428f156bd..d9880504f80c0adca416c9f7b5a1cc67b82d8a36 100644
(file)
--- a/
src/bin/lttng/commands/create.c
+++ b/
src/bin/lttng/commands/create.c
@@
-33,6
+33,7
@@
#include <common/sessiond-comm/sessiond-comm.h>
#include <common/uri.h>
#include <common/utils.h>
#include <common/sessiond-comm/sessiond-comm.h>
#include <common/uri.h>
#include <common/utils.h>
+#include <lttng/snapshot.h>
static char *opt_output_path;
static char *opt_session_name;
static char *opt_output_path;
static char *opt_session_name;
@@
-41,6
+42,7
@@
static char *opt_ctrl_url;
static char *opt_data_url;
static int opt_no_consumer;
static int opt_no_output;
static char *opt_data_url;
static int opt_no_consumer;
static int opt_no_output;
+static int opt_snapshot;
static int opt_disable_consumer;
enum {
static int opt_disable_consumer;
enum {
@@
-59,6
+61,7
@@
static struct poptOption long_options[] = {
{"no-output", 0, POPT_ARG_VAL, &opt_no_output, 1, 0, 0},
{"no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0},
{"disable-consumer", 0, POPT_ARG_VAL, &opt_disable_consumer, 1, 0, 0},
{"no-output", 0, POPT_ARG_VAL, &opt_no_output, 1, 0, 0},
{"no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0},
{"disable-consumer", 0, POPT_ARG_VAL, &opt_disable_consumer, 1, 0, 0},
+ {"snapshot", 0, POPT_ARG_VAL, &opt_snapshot, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
};
{0, 0, 0, 0, 0, 0, 0}
};
@@
-83,6
+86,11
@@
static void usage(FILE *ofp)
fprintf(ofp, " --list-options Simple listing of options\n");
fprintf(ofp, " -o, --output PATH Specify output path for traces\n");
fprintf(ofp, " --no-output Traces will not be outputed\n");
fprintf(ofp, " --list-options Simple listing of options\n");
fprintf(ofp, " -o, --output PATH Specify output path for traces\n");
fprintf(ofp, " --no-output Traces will not be outputed\n");
+ fprintf(ofp, " --snasphot Set the session in snapshot mode.\n");
+ fprintf(ofp, " Created in no-output mode and uses the URL,\n");
+ fprintf(ofp, " if one, as the default snapshot output.\n");
+ fprintf(ofp, " Every channel will be set in overwrite mode\n");
+ fprintf(ofp, " and with mmap output (splice not supported).\n");
fprintf(ofp, "\n");
fprintf(ofp, "Extended Options:\n");
fprintf(ofp, "\n");
fprintf(ofp, "\n");
fprintf(ofp, "Extended Options:\n");
fprintf(ofp, "\n");
@@
-170,6
+178,46
@@
error:
return ret;
}
return ret;
}
+static int add_snapshot_output(const char *session_name, const char *ctrl_url,
+ const char *data_url)
+{
+ int ret;
+ struct lttng_snapshot_output *output = NULL;
+
+ assert(session_name);
+
+ output = lttng_snapshot_output_create();
+ if (!output) {
+ ret = CMD_FATAL;
+ goto error_create;
+ }
+
+ if (ctrl_url) {
+ ret = lttng_snapshot_output_set_ctrl_url(ctrl_url, output);
+ if (ret < 0) {
+ goto error;
+ }
+ }
+
+ if (data_url) {
+ ret = lttng_snapshot_output_set_data_url(data_url, output);
+ if (ret < 0) {
+ goto error;
+ }
+ }
+
+ /* This call, if successful, populates the id of the output object. */
+ ret = lttng_snapshot_add_output(session_name, output);
+ if (ret < 0) {
+ goto error;
+ }
+
+error:
+ lttng_snapshot_output_destroy(output);
+error_create:
+ return ret;
+}
+
/*
* Create a tracing session.
* If no name is specified, a default name is generated.
/*
* Create a tracing session.
* If no name is specified, a default name is generated.
@@
-276,7
+324,7
@@
static int create_session(void)
print_str_url = alloc_url + strlen("file://");
}
} else {
print_str_url = alloc_url + strlen("file://");
}
} else {
- /* No output means --no-output. */
+ /* No output means --no-output
or --snapshot mode
. */
url = NULL;
}
url = NULL;
}
@@
-286,7
+334,20
@@
static int create_session(void)
goto error;
}
goto error;
}
- ret = _lttng_create_session_ext(session_name, url, datetime);
+ if (opt_snapshot) {
+ /* No output by default. */
+ const char *snapshot_url = NULL;
+
+ if (opt_url) {
+ snapshot_url = url;
+ } else if (!opt_data_url && !opt_ctrl_url) {
+ /* This is the session path that we need to use as output. */
+ snapshot_url = url;
+ }
+ ret = lttng_create_session_snapshot(session_name, snapshot_url);
+ } else {
+ ret = _lttng_create_session_ext(session_name, url, datetime);
+ }
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
switch (-ret) {
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
switch (-ret) {
@@
-300,8
+361,13
@@
static int create_session(void)
}
if (opt_ctrl_url && opt_data_url) {
}
if (opt_ctrl_url && opt_data_url) {
- /* Setting up control URI (-C or/and -D opt) */
- ret = set_consumer_url(session_name, opt_ctrl_url, opt_data_url);
+ if (opt_snapshot) {
+ ret = add_snapshot_output(session_name, opt_ctrl_url,
+ opt_data_url);
+ } else {
+ /* Setting up control URI (-C or/and -D opt) */
+ ret = set_consumer_url(session_name, opt_ctrl_url, opt_data_url);
+ }
if (ret < 0) {
/* Destroy created session because the URL are not valid. */
lttng_destroy_session(session_name);
if (ret < 0) {
/* Destroy created session because the URL are not valid. */
lttng_destroy_session(session_name);
@@
-310,8
+376,14
@@
static int create_session(void)
}
MSG("Session %s created.", session_name);
}
MSG("Session %s created.", session_name);
- if (print_str_url) {
+ if (print_str_url
&& !opt_snapshot
) {
MSG("Traces will be written in %s", print_str_url);
MSG("Traces will be written in %s", print_str_url);
+ } else if (opt_snapshot) {
+ if (print_str_url) {
+ MSG("Default snapshot output set to: %s", print_str_url);
+ }
+ MSG("Snapshot mode set. Every channel enabled for that session will "
+ "be set in overwrite mode and mmap output");
}
/* Init lttng session config */
}
/* Init lttng session config */
This page took
0.028435 seconds
and
4
git commands to generate.