@@ -604,6 +604,9 @@ static int put_together_file(int cpus, int ofd, const char *node,
if (write_options) {
ret = tracecmd_write_cpus(handle, cpus);
+ if (ret)
+ goto out;
+ ret = tracecmd_write_buffer_info(handle);
if (ret)
goto out;
ret = tracecmd_write_options(handle);
@@ -612,6 +615,9 @@ static int put_together_file(int cpus, int ofd, const char *node,
}
ret = tracecmd_write_cpu_data(handle, cpus, temp_files, "");
+ if (!ret && tracecmd_get_out_file_version(handle) >= FILE_VERSION_SECTIONS)
+ tracecmd_write_options(handle);
+
out:
tracecmd_output_close(handle);
for (cpu--; cpu >= 0; cpu--) {
@@ -3729,6 +3729,9 @@ setup_connection(struct buffer_instance *instance, struct common_record_context
if (ret)
goto error;
ret = tracecmd_write_cpus(network_handle, instance->cpu_count);
+ if (ret)
+ goto error;
+ ret = tracecmd_write_buffer_info(network_handle);
if (ret)
goto error;
ret = tracecmd_write_options(network_handle);
@@ -4092,6 +4095,7 @@ static void setup_agent(struct buffer_instance *instance,
add_options(network_handle, ctx);
tracecmd_write_cmdlines(network_handle);
tracecmd_write_cpus(network_handle, instance->cpu_count);
+ tracecmd_write_buffer_info(network_handle);
tracecmd_write_options(network_handle);
tracecmd_msg_finish_sending_data(instance->msg_handle);
instance->network_handle = network_handle;
@@ -163,6 +163,7 @@ void trace_restore (int argc, char **argv)
if (tracecmd_append_cpu_data(handle, args, &argv[first_arg]) < 0)
die("failed to append data");
-
+ if (tracecmd_get_out_file_version(handle) >= FILE_VERSION_SECTIONS)
+ tracecmd_write_options(handle);
return;
}
@@ -391,6 +391,9 @@ static double parse_file(struct tracecmd_input *handle,
if (tracecmd_append_cpu_data(ohandle, cpus, cpu_list) < 0)
die("Failed to append tracing data\n");
+ if (tracecmd_get_out_file_version(ohandle) >= FILE_VERSION_SECTIONS)
+ tracecmd_write_options(ohandle);
+
current = end;
for (cpu = 0; cpu < cpus; cpu++) {
/* Set the tracecmd cursor to the next set of records */
When creating a trace file, two more APIs should be called, compared to the old flow: - tracecmd_write_buffer_info(), to write version 6 buffers metadata in the file. - tracecmd_write_options() after the trace data is written, for version 7 trace files, as the buffer metadata is appended to the options at the end. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- tracecmd/trace-listen.c | 6 ++++++ tracecmd/trace-record.c | 4 ++++ tracecmd/trace-restore.c | 3 ++- tracecmd/trace-split.c | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-)