@@ -367,6 +367,11 @@ OPTIONS
Traces are extracted by busy waiting, which will hog the CPUs, so only use
when really needed.
+*--name*::
+ Give a specific name for the current agent being processed. Used after *-A* to
+ give the guest being traced a name. Useful when using the vsocket ID instead of
+ a name of the guest.
+
*--verbose*[='level']::
Set the log level. Supported log levels are "none", "critical", "error", "warning",
"info", "debug", "all" or their identifiers "0", "1", "2", "3", "4", "5", "6". Setting the log
@@ -5805,6 +5805,7 @@ enum {
OPT_nofifos = 257,
OPT_cmdlines_size = 258,
OPT_poll = 259,
+ OPT_name = 260,
};
void trace_stop(int argc, char **argv)
@@ -6222,6 +6223,7 @@ static void parse_record_options(int argc,
{"fork", no_argument, NULL, OPT_fork},
{"tsc2nsec", no_argument, NULL, OPT_tsc2nsec},
{"poll", no_argument, NULL, OPT_poll},
+ {"name", required_argument, NULL, OPT_name},
{"verbose", optional_argument, NULL, OPT_verbose},
{"compression", required_argument, NULL, OPT_compression},
{"file-version", required_argument, NULL, OPT_file_ver},
@@ -6240,7 +6242,7 @@ static void parse_record_options(int argc,
* If the current instance is to record a guest, then save
* all the arguments for this instance.
*/
- if (c != 'B' && c != 'A' && is_guest(ctx->instance)) {
+ if (c != 'B' && c != 'A' && c != OPT_name && is_guest(ctx->instance)) {
add_arg(ctx->instance, c, opts, long_options, optarg);
if (c == 'C')
ctx->instance->flags |= BUFFER_FL_HAS_CLOCK;
@@ -6301,6 +6303,17 @@ static void parse_record_options(int argc,
add_trigger(event, optarg);
break;
+ case OPT_name:
+ if (!ctx->instance)
+ die("No instance defined for name option\n");
+ if (!is_guest(ctx->instance))
+ die(" --name is only used for -A options\n");
+ free(ctx->instance->name);
+ ctx->instance->name = strdup(optarg);
+ if (!ctx->instance->name)
+ die("Failed to allocate name");
+ break;
+
case 'A': {
char *name = NULL;
int cid = -1, port = -1;
@@ -6316,8 +6329,13 @@ static void parse_record_options(int argc,
if (!name || !*name) {
ret = asprintf(&name, "unnamed-%d", name_counter++);
if (ret < 0)
- die("Failed to allocate guest name");
+ name = NULL;
+ } else {
+ /* Needs to be allocate */
+ name = strdup(name);
}
+ if (!name)
+ die("Failed to allocate guest name");
ctx->instance = allocate_instance(name);
ctx->instance->flags |= BUFFER_FL_GUEST;
@@ -69,6 +69,7 @@ static struct usage_help usage_help[] = {
" If 0 is specified, no loop is performed - timestamps offset is calculated only twice,"
" at the beginnig and at the end of the trace\n"
" --poll don't block while reading from the trace buffer\n"
+ " --name used with -A to give the agent a specific name\n"
" --file-version set the desired trace file version\n"
" --compression compress the trace output file, one of these strings can be passed:\n"
" any - auto select the best available compression algorithm\n"