Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libtracecmd for openSUSE:Factory 
checked in at 2022-12-16 21:26:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libtracecmd (Old)
 and      /work/SRC/openSUSE:Factory/.libtracecmd.new.1835 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libtracecmd"

Fri Dec 16 21:26:08 2022 rev:3 rq:1043362 version:1.3.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/libtracecmd/libtracecmd.changes  2022-12-04 
14:59:02.836509788 +0100
+++ /work/SRC/openSUSE:Factory/.libtracecmd.new.1835/libtracecmd.changes        
2022-12-16 21:26:09.351804697 +0100
@@ -1,0 +2,9 @@
+Fri Dec 16 14:59:50 UTC 2022 - Jan Engelhardt <jeng...@inai.de>
+
+- Update to release 1.3.0
+  * Only set trace-cmd log level (not libtracefs nor libtraceevent)
+  * Fix function graph plugin updating the next record
+  * Use libtracefs tracefs_cpu() interface for recording
+    (requires libtracefs 1.6)
+
+-------------------------------------------------------------------

Old:
----
  trace-cmd-libtracecmd-1.2.0.tar.gz

New:
----
  trace-cmd-libtracecmd-1.3.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libtracecmd.spec ++++++
--- /var/tmp/diff_new_pack.SXovtS/_old  2022-12-16 21:26:10.051808784 +0100
+++ /var/tmp/diff_new_pack.SXovtS/_new  2022-12-16 21:26:10.055808807 +0100
@@ -18,7 +18,7 @@
 
 Name:           libtracecmd
 %define lname   libtracecmd1
-Version:        1.2.0
+Version:        1.3.0
 Release:        0
 Summary:        Library for creating and reading trace-cmd data files
 License:        LGPL-2.1-only
@@ -29,7 +29,7 @@
 BuildRequires:  asciidoc
 BuildRequires:  fdupes
 BuildRequires:  libtraceevent-devel
-BuildRequires:  libtracefs-devel
+BuildRequires:  libtracefs-devel >= 1.6
 BuildRequires:  libzstd-devel
 BuildRequires:  source-highlight
 BuildRequires:  xmlto

++++++ trace-cmd-libtracecmd-1.2.0.tar.gz -> trace-cmd-libtracecmd-1.3.0.tar.gz 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/Documentation/libtracecmd/libtracecmd-iterate.txt
 
new/trace-cmd-libtracecmd-1.3.0/Documentation/libtracecmd/libtracecmd-iterate.txt
--- 
old/trace-cmd-libtracecmd-1.2.0/Documentation/libtracecmd/libtracecmd-iterate.txt
   2022-09-23 17:07:10.000000000 +0200
+++ 
new/trace-cmd-libtracecmd-1.3.0/Documentation/libtracecmd/libtracecmd-iterate.txt
   2022-12-12 00:10:26.000000000 +0100
@@ -4,7 +4,7 @@
 NAME
 ----
 tracecmd_iterate_events, tracecmd_iterate_events_multi, tracecmd_follow_event,
-tracecmd_filter_add - Read events from a trace file
+tracecmd_follow_missed_events, tracecmd_filter_add - Read events from a trace 
file
 
 SYNOPSIS
 --------
@@ -31,6 +31,12 @@
                                          struct tep_record pass:[*],
                                          int, void pass:[*]),
                          void pass:[*]_callback_data_);
+int *tracecmd_follow_missed_events*(struct tracecmd_input pass:[*]_handle_,
+                                  int (pass:[*]_callback_)(struct 
tracecmd_input pass:[*],
+                                                  struct tep_event pass:[*],
+                                                  struct tep_record pass:[*],
+                                                  int, void pass:[*]),
+                                  void pass:[*]_callback_data_);
 struct tracecmd_filter pass:[*]*tracecmd_filter_add*(struct tracecmd_input 
*_handle_,
                                            const char pass:[*]_filter_str_, 
bool _neg_);
 --
@@ -80,6 +86,9 @@
 The *tracecmd_follow_event()* function will attach to a trace file descriptor 
_handle_
 and call the _callback_ when the event described by _system_ and _name_ 
matches an event
 in the iteration of *tracecmd_iterate_events()* or 
*tracecmd_iterate_events_multi()*.
+Note, the _cpu_ is the nth CPU for both *tracecmd_iterate_events()* and
+*tracecmd_iterate_events_multi()*. If the actual CPU of the _record_ is 
needed, use
+_record_->cpu.
 For *tracecmd_iterate_events_multi()*, the _callback_ is only called if the 
_handle_
 matches the current trace file descriptor within _handles_. The 
_callback_data_ is
 passed as the last parameter to the _callback()_ function. Note, this 
_callback()_
@@ -90,6 +99,21 @@
 int _callback()_(struct tracecmd_input pass:[*]_handle_, struct tep_event 
pass:[*]_event,
                 struct tep_record pass:[*]_record_, int _cpu_, void 
pass:[*]_data_);
 
+The *tracecmd_follow_missed_events()* function will attach to a trace file 
descriptor
+_handle_ and call the _callback_ when missed events are detected. The _event_ 
will
+hold the type of event that the _record_ is. The _record_ will hold the 
information
+of the missed events. The _cpu_ is the nth CPU for both 
*tracecmd_iterate_events()*
+and *tracecmd_iterate_events_multi()*. If the CPU that the missed events are 
for is
+needed, use _record_->cpu. If _record_->missed_events is a positive number, 
then it
+holds the number of missed events since the last event on its CPU, otherwise it
+will be negative, and that will mean that the number of missed events is 
unknown but
+missed events exist since the last event on the CPU.
+The _callback_ and _callback_data_ is the same format as 
*tracecmd_follow_event()* above.
+The missed events _callback_ is called before any of the other _callbacks_ and 
any
+filters that were added by *tracecmd_filter_add()* are ignored.
+If _callback_ returns a non zero, it will stop the iterator before it calls 
any of the
+other iterator callbacks for the given record.
+
 The *tracecmd_filter_add()* function, adds a filter to _handle_ that affects
 both *tracecmd_iterate_events()* and *tracecmd_iterate_events_multi()*.
 The _filter_str_ is a character string defining a filter in a format that
@@ -148,6 +172,17 @@
        return print_events(handle, record, cpu, data);
 }
 
+static int missed_events(struct tracecmd_input *handle, struct tep_event 
*event,
+                        struct tep_record *record, int cpu, void *data)
+{
+       if (record->missed_events > 0)
+               printf("CPU [%03d] has %d missed events\n",
+                        record->cpu, record->missed_events);
+       else
+               printf("CPU [%03d] has missed events\n", record->cpu);
+       return 0;
+}
+
 static void usage(const char *argv0)
 {
        printf("usage: [-c cpu][-f filter][-e event] %s trace.dat [trace.dat 
...]\n",
@@ -218,6 +253,7 @@
                                exit(-1);
                        }
                }
+               tracecmd_follow_missed_events(handles[nr_handles], 
missed_events, NULL);
                nr_handles++;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/Documentation/libtracecmd/libtracecmd.txt 
new/trace-cmd-libtracecmd-1.3.0/Documentation/libtracecmd/libtracecmd.txt
--- old/trace-cmd-libtracecmd-1.2.0/Documentation/libtracecmd/libtracecmd.txt   
2022-09-23 17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/Documentation/libtracecmd/libtracecmd.txt   
2022-12-12 00:10:26.000000000 +0100
@@ -47,6 +47,12 @@
                                                  struct tep_record pass:[*],
                                                  int, void pass:[*]),
                                  void pass:[*]_callback_data_);
+       int *tracecmd_follow_missed_events*(struct tracecmd_input 
pass:[*]_handle_,
+                                          int (pass:[*]_callback_)(struct 
tracecmd_input pass:[*],
+                                                          struct tep_event 
pass:[*],
+                                                          struct tep_record 
pass:[*],
+                                                          int, void pass:[*]),
+                                          void pass:[*]_callback_data_);
        struct tracecmd_filter pass:[*]*tracecmd_filter_add*(struct 
tracecmd_input *_handle_,
                                                    const char 
pass:[*]_filter_str_, bool _neg_);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/Documentation/trace-cmd/trace-cmd-convert.1.txt 
new/trace-cmd-libtracecmd-1.3.0/Documentation/trace-cmd/trace-cmd-convert.1.txt
--- 
old/trace-cmd-libtracecmd-1.2.0/Documentation/trace-cmd/trace-cmd-convert.1.txt 
    2022-09-23 17:07:10.000000000 +0200
+++ 
new/trace-cmd-libtracecmd-1.3.0/Documentation/trace-cmd/trace-cmd-convert.1.txt 
    2022-12-12 00:10:26.000000000 +0100
@@ -13,7 +13,8 @@
 -----------
 The trace-cmd(1) convert command converts trace file. It reads the input file 
and copies the data
 into an output file. The output file may be in different format, depending on 
the command line
-arguments.
+arguments. The default output is in version 7 and compressed (if
+compiled with compression support).
 
 OPTIONS
 -------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/trace-cmd-libtracecmd-1.2.0/Makefile 
new/trace-cmd-libtracecmd-1.3.0/Makefile
--- old/trace-cmd-libtracecmd-1.2.0/Makefile    2022-09-23 17:07:10.000000000 
+0200
+++ new/trace-cmd-libtracecmd-1.3.0/Makefile    2022-12-12 00:10:26.000000000 
+0100
@@ -2,7 +2,7 @@
 # trace-cmd version
 TC_VERSION = 3
 TC_PATCHLEVEL = 1
-TC_EXTRAVERSION = 3
+TC_EXTRAVERSION = 4
 TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION)
 
 export TC_VERSION
@@ -11,7 +11,7 @@
 export TRACECMD_VERSION
 
 LIBTC_VERSION = 1
-LIBTC_PATCHLEVEL = 2
+LIBTC_PATCHLEVEL = 3
 LIBTC_EXTRAVERSION = 0
 LIBTRACECMD_VERSION = 
$(LIBTC_VERSION).$(LIBTC_PATCHLEVEL).$(LIBTC_EXTRAVERSION)
 
@@ -23,7 +23,7 @@
 VERSION_FILE = ltc_version.h
 
 LIBTRACEEVENT_MIN_VERSION = 1.5
-LIBTRACEFS_MIN_VERSION = 1.4
+LIBTRACEFS_MIN_VERSION = 1.6
 
 MAKEFLAGS += --no-print-directory
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/include/trace-cmd/trace-cmd.h 
new/trace-cmd-libtracecmd-1.3.0/include/trace-cmd/trace-cmd.h
--- old/trace-cmd-libtracecmd-1.2.0/include/trace-cmd/trace-cmd.h       
2022-09-23 17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/include/trace-cmd/trace-cmd.h       
2022-12-12 00:10:26.000000000 +0100
@@ -63,6 +63,13 @@
                                          int, void *),
                          void *callback_data);
 
+int tracecmd_follow_missed_events(struct tracecmd_input *handle,
+                                 int (*callback)(struct tracecmd_input *handle,
+                                                 struct tep_event *,
+                                                 struct tep_record *,
+                                                 int, void *),
+                                 void *callback_data);
+
 int tracecmd_iterate_events(struct tracecmd_input *handle,
                            cpu_set_t *cpus, int cpu_size,
                            int (*callback)(struct tracecmd_input *handle,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/include/private/trace-cmd-private.h
 
new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/include/private/trace-cmd-private.h
--- 
old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/include/private/trace-cmd-private.h
   2022-09-23 17:07:10.000000000 +0200
+++ 
new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/include/private/trace-cmd-private.h
   2022-12-12 00:10:26.000000000 +0100
@@ -371,9 +371,9 @@
 struct tracecmd_recorder *tracecmd_create_recorder_fd(int fd, int cpu, 
unsigned flags);
 struct tracecmd_recorder *tracecmd_create_recorder_virt(const char *file, int 
cpu, unsigned flags, int trace_fd);
 struct tracecmd_recorder *tracecmd_create_recorder_maxkb(const char *file, int 
cpu, unsigned flags, int maxkb);
-struct tracecmd_recorder *tracecmd_create_buffer_recorder_fd(int fd, int cpu, 
unsigned flags, const char *buffer);
-struct tracecmd_recorder *tracecmd_create_buffer_recorder(const char *file, 
int cpu, unsigned flags, const char *buffer);
-struct tracecmd_recorder *tracecmd_create_buffer_recorder_maxkb(const char 
*file, int cpu, unsigned flags, const char *buffer, int maxkb);
+struct tracecmd_recorder *tracecmd_create_buffer_recorder_fd(int fd, int cpu, 
unsigned flags, struct tracefs_instance *instance);
+struct tracecmd_recorder *tracecmd_create_buffer_recorder(const char *file, 
int cpu, unsigned flags, struct tracefs_instance *instance);
+struct tracecmd_recorder *tracecmd_create_buffer_recorder_maxkb(const char 
*file, int cpu, unsigned flags, struct tracefs_instance *instance, int maxkb);
 
 int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long 
sleep);
 void tracecmd_stop_recording(struct tracecmd_recorder *recorder);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/trace-input.c 
new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/trace-input.c
--- old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/trace-input.c 2022-09-23 
17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/trace-input.c 2022-12-12 
00:10:26.000000000 +0100
@@ -171,6 +171,7 @@
        struct tracecmd_input   *parent;
        struct tracecmd_filter  *filter;
        struct follow_event     *followers;
+       struct follow_event     *missed_followers;
        struct tracecmd_cpu_map *map;
        unsigned long           file_state;
        unsigned long long      trace_id;
@@ -185,6 +186,7 @@
        int                     start_cpu;
        int                     ref;
        int                     nr_followers;
+       int                     nr_missed_followers;
        int                     nr_buffers;     /* buffer instances */
        bool                    use_trace_clock;
        bool                    read_page;
@@ -2626,6 +2628,57 @@
        return 0;
 }
 
+/**
+ * tracecmd_follow_missed_events - Add callback for missed events for iterators
+ * @handle: The handle to get a callback from
+ * @callback: The function to call when missed events is detected
+ * @callback_data: The data to pass to @callback
+ *
+ * This attaches a callback to @handle where if tracecmd_iterate_events()
+ * or tracecmd_iterate_events_multi() is called, that if missed events
+ * is detected, it will call @callback, with the following parameters:
+ *  @handle: Same handle as passed to this function.
+ *  @event: The event pointer of the record with the missing events
+ *  @record; The event instance of @event.
+ *  @cpu: The cpu that the event happened on.
+ *  @callback_data: The same as @callback_data passed to the function.
+ *
+ * Note that when used with tracecmd_iterate_events_multi() that @cpu
+ * may be the nth CPU of all handles it is processing, so if the CPU
+ * that the @record is on is desired, then use @record->cpu.
+ *
+ * If the count of missing events is available, @record->missed_events
+ * will have a positive number holding the number of missed events since
+ * the last event on the same CPU, or just -1 if that number is unknown
+ * but missed events did happen.
+ *
+ * Returns 0 on success and -1 on error.
+ */
+int tracecmd_follow_missed_events(struct tracecmd_input *handle,
+                                 int (*callback)(struct tracecmd_input *handle,
+                                                 struct tep_event *,
+                                                 struct tep_record *,
+                                                 int, void *),
+                                 void *callback_data)
+{
+       struct follow_event *followers;
+       struct follow_event follow;
+
+       follow.event = NULL;
+       follow.callback = callback;
+       follow.callback_data = callback_data;
+
+       followers = realloc(handle->missed_followers, sizeof(*followers) *
+                           (handle->nr_missed_followers + 1));
+       if (!followers)
+               return -1;
+
+       handle->missed_followers = followers;
+       followers[handle->nr_missed_followers++] = follow;
+
+       return 0;
+}
+
 static int call_followers(struct tracecmd_input *handle,
                          struct tep_record *record, int cpu)
 {
@@ -2648,6 +2701,56 @@
        return ret;
 }
 
+static int call_missed_events(struct tracecmd_input *handle,
+                             struct tep_record *record, int cpu)
+{
+       struct tep_handle *tep = tracecmd_get_tep(handle);
+       struct follow_event *followers = handle->missed_followers;
+       struct tep_event *event;
+       int ret = 0;
+       int i;
+
+       event = tep_find_event_by_record(tep, record);
+       if (!event)
+               return -1;
+
+       for (i = 0; i < handle->nr_missed_followers; i++) {
+               ret |= followers[i].callback(handle, event, record,
+                                            cpu, followers[i].callback_data);
+       }
+
+       return ret;
+}
+
+static int call_callbacks(struct tracecmd_input *handle, struct tep_record 
*record,
+                         int next_cpu,
+                         int (*callback)(struct tracecmd_input *handle,
+                                         struct tep_record *,
+                                         int, void *),
+                         void *callback_data)
+{
+       int ret = 0;
+
+       if (!record)
+               return 0;
+
+       if (record->missed_events)
+               ret = call_missed_events(handle, record, next_cpu);
+
+       if (ret)
+               return ret;
+
+       if (!handle->filter ||
+           tracecmd_filter_match(handle->filter, record) == 
TRACECMD_FILTER_MATCH) {
+               if (handle->nr_followers)
+                       ret = call_followers(handle, record, next_cpu);
+               if (!ret && callback)
+                       ret = callback(handle, record, next_cpu, callback_data);
+       }
+
+       return ret;
+}
+
 /**
  * tracecmd_iterate_events - iterate events over a given handle
  * @handle: The handle to iterate over
@@ -2707,15 +2810,11 @@
                if (next_cpu >= 0) {
                        /* Need to call read_data to increment to the next 
record */
                        record = tracecmd_read_data(handle, next_cpu);
-                       records[next_cpu] = tracecmd_peek_data(handle, 
next_cpu);
 
-                       if (!handle->filter ||
-                           tracecmd_filter_match(handle->filter, record) == 
TRACECMD_FILTER_MATCH) {
-                               if (handle->nr_followers)
-                                       ret = call_followers(handle, record, 
next_cpu);
-                               if (!ret && callback)
-                                       ret = callback(handle, record, 
next_cpu, callback_data);
-                       }
+                       ret = call_callbacks(handle, record, next_cpu,
+                                            callback, callback_data);
+
+                       records[next_cpu] = tracecmd_peek_data(handle, 
next_cpu);
                        tracecmd_free_record(record);
                }
        } while (next_cpu >= 0 && ret >= 0);
@@ -2801,17 +2900,12 @@
                        cpu = next_cpu - handle->start_cpu;
                        /* Need to call read_data to increment to the next 
record */
                        record = tracecmd_read_data(handle, cpu);
-                       records[next_cpu].record = tracecmd_peek_data(handle, 
cpu);
 
-                       if (!handle->filter ||
-                           tracecmd_filter_match(handle->filter, record) == 
TRACECMD_FILTER_MATCH) {
-                               if (handle->nr_followers)
-                                       ret = call_followers(handle, record, 
next_cpu);
+                       ret = call_callbacks(handle, record, next_cpu,
+                                            callback, callback_data);
 
-                               if (!ret && callback)
-                                       ret = callback(handle, record, 
next_cpu, callback_data);
-                       }
                        tracecmd_free_record(record);
+                       records[next_cpu].record = tracecmd_peek_data(handle, 
cpu);
                }
 
        } while (next_cpu >= 0 && ret >= 0);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/trace-recorder.c 
new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/trace-recorder.c
--- old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/trace-recorder.c      
2022-09-23 17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/trace-recorder.c      
2022-12-12 00:10:26.000000000 +0100
@@ -32,20 +32,17 @@
 #define POLL_TIMEOUT_MS                1000
 
 struct tracecmd_recorder {
+       struct tracefs_cpu *tcpu;
        int             fd;
        int             fd1;
        int             fd2;
-       int             trace_fd;
-       int             brass[2];
-       int             pipe_size;
        int             page_size;
+       int             subbuf_size;
        int             cpu;
        int             stop;
        int             max;
        int             pages;
        int             count;
-       unsigned        fd_flags;
-       unsigned        trace_fd_flags;
        unsigned        flags;
 };
 
@@ -94,14 +91,7 @@
                append_file(recorder->page_size, recorder->fd1, recorder->fd2);
        }
  close:
-       if (recorder->brass[0] >= 0)
-               close(recorder->brass[0]);
-
-       if (recorder->brass[1] >= 0)
-               close(recorder->brass[1]);
-
-       if (recorder->trace_fd >= 0)
-               close(recorder->trace_fd);
+       tracefs_cpu_close(recorder->tcpu);
 
        if (recorder->fd1 >= 0)
                close(recorder->fd1);
@@ -114,44 +104,22 @@
 
 static void set_nonblock(struct tracecmd_recorder *recorder)
 {
-       long flags;
-
-       /* Do not block on reads */
-       flags = fcntl(recorder->trace_fd, F_GETFL);
-       fcntl(recorder->trace_fd, F_SETFL, flags | O_NONBLOCK);
-
-       /* Do not block on streams */
-       recorder->fd_flags |= SPLICE_F_NONBLOCK;
+       tracefs_cpu_stop(recorder->tcpu);
 }
 
-struct tracecmd_recorder *
-tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
-                                   const char *buffer, int maxkb)
+static struct tracecmd_recorder *
+create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
+                          struct tracefs_instance *instance, int maxkb, int 
tfd)
 {
        struct tracecmd_recorder *recorder;
-       char *path = NULL;
-       int pipe_size = 0;
-       int ret;
+       bool nonblock = false;
 
        recorder = malloc(sizeof(*recorder));
        if (!recorder)
                return NULL;
 
-       recorder->cpu = cpu;
        recorder->flags = flags;
 
-       recorder->fd_flags = SPLICE_F_MOVE;
-
-       if (!(recorder->flags & TRACECMD_RECORD_BLOCK_SPLICE))
-               recorder->fd_flags |= SPLICE_F_NONBLOCK;
-
-       recorder->trace_fd_flags = SPLICE_F_MOVE;
-
-       /* Init to know what to free and release */
-       recorder->trace_fd = -1;
-       recorder->brass[0] = -1;
-       recorder->brass[1] = -1;
-
        recorder->page_size = getpagesize();
        if (maxkb) {
                int kb_per_page = recorder->page_size >> 10;
@@ -174,45 +142,18 @@
        recorder->fd1 = fd;
        recorder->fd2 = fd2;
 
-       if (buffer) {
-               if (flags & TRACECMD_RECORD_SNAPSHOT)
-                       ret = asprintf(&path, "%s/per_cpu/cpu%d/snapshot_raw",
-                                      buffer, cpu);
-               else
-                       ret = asprintf(&path, "%s/per_cpu/cpu%d/trace_pipe_raw",
-                                      buffer, cpu);
-               if (ret < 0)
-                       goto out_free;
-
-               recorder->trace_fd = open(path, O_RDONLY);
-               free(path);
-
-               if (recorder->trace_fd < 0)
-                       goto out_free;
-       }
-
-       if (!(recorder->flags & (TRACECMD_RECORD_NOSPLICE |
-                                TRACECMD_RECORD_NOBRASS))) {
-               ret = pipe(recorder->brass);
-               if (ret < 0)
-                       goto out_free;
-
-               ret = fcntl(recorder->brass[0], F_GETPIPE_SZ, &pipe_size);
-               /*
-                * F_GETPIPE_SZ was introduced in 2.6.35, ftrace was introduced
-                * in 2.6.31. If we are running on an older kernel, just fall
-                * back to using page_size for splice(). It could also return
-                * success, but not modify pipe_size.
-                */
-               if (ret < 0 || !pipe_size)
-                       pipe_size = recorder->page_size;
+       if (recorder->flags & TRACECMD_RECORD_POLL)
+               nonblock = true;
 
-               recorder->pipe_size = pipe_size;
-       }
+       if (tfd >= 0)
+               recorder->tcpu = tracefs_cpu_alloc_fd(tfd, recorder->page_size, 
nonblock);
+       else
+               recorder->tcpu = tracefs_cpu_open(instance, cpu, nonblock);
 
-       if (recorder->flags & TRACECMD_RECORD_POLL)
-               set_nonblock(recorder);
+       if (!recorder->tcpu)
+               goto out_free;
 
+       recorder->subbuf_size = tracefs_cpu_read_size(recorder->tcpu);
        return recorder;
 
  out_free:
@@ -220,62 +161,31 @@
        return NULL;
 }
 
-static void verify_splice(const char *file, unsigned *flags)
+struct tracecmd_recorder *
+tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
+                                   struct tracefs_instance *instance, int 
maxkb)
 {
-       int brass[2];
-       int ret;
-       int fd;
-
-       fd = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
-       if (fd < 0)
-               return; /* Will fail by the caller too */
-
-       if (pipe(brass) < 0)
-               goto fail_pipe;
-
-       ret = splice(brass[0], NULL, fd, NULL, 0, SPLICE_F_NONBLOCK);
-       if (ret < 0)
-               goto fail_splice;
-
- out_pipe:
-       close(brass[0]);
-       close(brass[1]);
- out:
-       close(fd);
-       return;
-
- fail_pipe:
-       tracecmd_warning("Failed opening pipe, trying read/write");
-       *flags |= TRACECMD_RECORD_NOSPLICE;
-       goto out;
-
- fail_splice:
-       tracecmd_warning("Failed splice to file, trying read/write");
-       *flags |= TRACECMD_RECORD_NOSPLICE;
-       goto out_pipe;
+       return create_buffer_recorder_fd2(fd, fd2, cpu, flags, instance, maxkb, 
-1);
 }
 
 struct tracecmd_recorder *
-tracecmd_create_buffer_recorder_fd(int fd, int cpu, unsigned flags, const char 
*buffer)
+tracecmd_create_buffer_recorder_fd(int fd, int cpu, unsigned flags, struct 
tracefs_instance *instance)
 {
-       return tracecmd_create_buffer_recorder_fd2(fd, -1, cpu, flags, buffer, 
0);
+       return tracecmd_create_buffer_recorder_fd2(fd, -1, cpu, flags, 
instance, 0);
 }
 
 static struct tracecmd_recorder *
 __tracecmd_create_buffer_recorder(const char *file, int cpu, unsigned flags,
-                                 const char *buffer)
+                                 struct tracefs_instance *instance, int tfd)
 {
        struct tracecmd_recorder *recorder;
        int fd;
 
-       if (!(flags & TRACECMD_RECORD_NOSPLICE))
-               verify_splice(file, &flags);
-
        fd = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
        if (fd < 0)
                return NULL;
 
-       recorder = tracecmd_create_buffer_recorder_fd(fd, cpu, flags, buffer);
+       recorder = create_buffer_recorder_fd2(fd, -1, cpu, flags, instance, 0, 
tfd);
        if (!recorder) {
                close(fd);
                unlink(file);
@@ -286,7 +196,7 @@
 
 struct tracecmd_recorder *
 tracecmd_create_buffer_recorder_maxkb(const char *file, int cpu, unsigned 
flags,
-                                     const char *buffer, int maxkb)
+                                     struct tracefs_instance *instance, int 
maxkb)
 {
        struct tracecmd_recorder *recorder = NULL;
        char *file2;
@@ -295,7 +205,7 @@
        int fd2;
 
        if (!maxkb)
-               return tracecmd_create_buffer_recorder(file, cpu, flags, 
buffer);
+               return tracecmd_create_buffer_recorder(file, cpu, flags, 
instance);
 
        len = strlen(file);
        file2 = malloc(len + 3);
@@ -312,7 +222,7 @@
        if (fd2 < 0)
                goto err;
 
-       recorder = tracecmd_create_buffer_recorder_fd2(fd, fd2, cpu, flags, 
buffer, maxkb);
+       recorder = tracecmd_create_buffer_recorder_fd2(fd, fd2, cpu, flags, 
instance, maxkb);
        if (!recorder)
                goto err2;
  out:
@@ -331,9 +241,9 @@
 
 struct tracecmd_recorder *
 tracecmd_create_buffer_recorder(const char *file, int cpu, unsigned flags,
-                               const char *buffer)
+                               struct tracefs_instance *instance)
 {
-       return __tracecmd_create_buffer_recorder(file, cpu, flags, buffer);
+       return __tracecmd_create_buffer_recorder(file, cpu, flags, instance, 
-1);
 }
 
 /**
@@ -348,53 +258,23 @@
 tracecmd_create_recorder_virt(const char *file, int cpu, unsigned flags,
                              int trace_fd)
 {
-       struct tracecmd_recorder *recorder;
-
-       recorder = __tracecmd_create_buffer_recorder(file, cpu, flags, NULL);
-       if (recorder)
-               recorder->trace_fd = trace_fd;
-
-       return recorder;
+       return __tracecmd_create_buffer_recorder(file, cpu, flags, NULL, 
trace_fd);
 }
 
 struct tracecmd_recorder *tracecmd_create_recorder_fd(int fd, int cpu, 
unsigned flags)
 {
-       const char *tracing;
-
-       tracing = tracefs_tracing_dir();
-       if (!tracing) {
-               errno = ENODEV;
-               return NULL;
-       }
-
-       return tracecmd_create_buffer_recorder_fd(fd, cpu, flags, tracing);
+       return tracecmd_create_buffer_recorder_fd(fd, cpu, flags, NULL);
 }
 
 struct tracecmd_recorder *tracecmd_create_recorder(const char *file, int cpu, 
unsigned flags)
 {
-       const char *tracing;
-
-       tracing = tracefs_tracing_dir();
-       if (!tracing) {
-               errno = ENODEV;
-               return NULL;
-       }
-
-       return tracecmd_create_buffer_recorder(file, cpu, flags, tracing);
+       return tracecmd_create_buffer_recorder(file, cpu, flags, NULL);
 }
 
 struct tracecmd_recorder *
 tracecmd_create_recorder_maxkb(const char *file, int cpu, unsigned flags, int 
maxkb)
 {
-       const char *tracing;
-
-       tracing = tracefs_tracing_dir();
-       if (!tracing) {
-               errno = ENODEV;
-               return NULL;
-       }
-
-       return tracecmd_create_buffer_recorder_maxkb(file, cpu, flags, tracing, 
maxkb);
+       return tracecmd_create_buffer_recorder_maxkb(file, cpu, flags, NULL, 
maxkb);
 }
 
 static inline void update_fd(struct tracecmd_recorder *recorder, int size)
@@ -407,8 +287,8 @@
        recorder->count += size;
 
        if (recorder->count >= recorder->page_size) {
+               recorder->pages += recorder->count / recorder->page_size;
                recorder->count = 0;
-               recorder->pages++;
        }
 
        if (recorder->pages < recorder->max)
@@ -435,101 +315,13 @@
  * Returns -1 on error.
  *          or bytes of data read.
  */
-static long splice_data(struct tracecmd_recorder *recorder)
-{
-       long total_read = 0;
-       long read;
-       long ret;
-
-       read = splice(recorder->trace_fd, NULL, recorder->brass[1], NULL,
-                     recorder->pipe_size, recorder->trace_fd_flags);
-       if (read < 0) {
-               if (errno == EAGAIN || errno == EINTR || errno == ENOTCONN)
-                       return 0;
-
-               tracecmd_warning("recorder error in splice input");
-               return -1;
-       } else if (read == 0)
-               return 0;
-
- again:
-       ret = splice(recorder->brass[0], NULL, recorder->fd, NULL,
-                    read, recorder->fd_flags);
-       if (ret < 0) {
-               if (errno != EAGAIN && errno != EINTR) {
-                       tracecmd_warning("recorder error in splice output");
-                       return -1;
-               }
-               return total_read;
-       } else
-               update_fd(recorder, ret);
-       total_read = ret;
-       read -= ret;
-       if (read)
-               goto again;
-
-       return total_read;
-}
-
-/*
- * Returns -1 on error.
- *          or bytes of data read.
- */
-static long direct_splice_data(struct tracecmd_recorder *recorder)
-{
-       struct pollfd pfd = {
-               .fd = recorder->trace_fd,
-               .events = POLLIN,
-       };
-       long read;
-       int ret;
-
-       /*
-        * splice(2) in Linux used to not check O_NONBLOCK flag of pipe file
-        * descriptors before [1]. To avoid getting blocked in the splice(2)
-        * call below after the user had requested to stop tracing, we poll(2)
-        * here. This poll() is not necessary on newer kernels.
-        *
-        * [1] 
https://github.com/torvalds/linux/commit/ee5e001196d1345b8fee25925ff5f1d67936081e
-        */
-       ret = poll(&pfd, 1, POLL_TIMEOUT_MS);
-       if (ret < 0)
-               return -1;
-
-       if (!(pfd.revents | POLLIN))
-               return 0;
-
-       read = splice(recorder->trace_fd, NULL, recorder->fd, NULL,
-                     recorder->pipe_size, recorder->fd_flags);
-       if (read < 0) {
-               if (errno == EAGAIN || errno == EINTR || errno == ENOTCONN)
-                       return 0;
-
-               tracecmd_warning("recorder error in splice input");
-               return -1;
-       }
-
-       return read;
-}
-
-/*
- * Returns -1 on error.
- *          or bytes of data read.
- */
 static long read_data(struct tracecmd_recorder *recorder)
 {
-       char buf[recorder->page_size];
+       char buf[recorder->subbuf_size];
        long left;
        long r, w;
 
-       r = read(recorder->trace_fd, buf, recorder->page_size);
-       if (r < 0) {
-               if (errno == EAGAIN || errno == EINTR || errno == ENOTCONN)
-                       return 0;
-
-               tracecmd_warning("recorder error in read input");
-               return -1;
-       }
+       r = tracefs_cpu_read(recorder->tcpu, buf, false);
 
        left = r;
        do {
@@ -546,20 +338,34 @@
        return r;
 }
 
+/*
+ * Returns -1 on error.
+ *          or bytes of data read.
+ */
+static long direct_splice_data(struct tracecmd_recorder *recorder)
+{
+       return tracefs_cpu_pipe(recorder->tcpu, recorder->fd, false);
+}
+
 static long move_data(struct tracecmd_recorder *recorder)
 {
+       long ret;
+
        if (recorder->flags & TRACECMD_RECORD_NOSPLICE)
                return read_data(recorder);
 
        if (recorder->flags & TRACECMD_RECORD_NOBRASS)
                return direct_splice_data(recorder);
 
-       return splice_data(recorder);
+       ret = tracefs_cpu_write(recorder->tcpu, recorder->fd, false);
+       if (ret > 0)
+               update_fd(recorder, ret);
+       return ret;
 }
 
 long tracecmd_flush_recording(struct tracecmd_recorder *recorder)
 {
-       char buf[recorder->page_size];
+       char buf[recorder->subbuf_size];
        long total = 0;
        long wrote = 0;
        long ret;
@@ -567,28 +373,17 @@
        set_nonblock(recorder);
 
        do {
-               ret = move_data(recorder);
-               if (ret < 0)
-                       return ret;
-               total += ret;
-       } while (ret);
-
-       /* splice only reads full pages */
-       do {
-               ret = read(recorder->trace_fd, buf, recorder->page_size);
-               if (ret > 0) {
-                       write(recorder->fd, buf, ret);
+               ret = tracefs_cpu_flush_write(recorder->tcpu, recorder->fd);
+               if (ret > 0)
                        wrote += ret;
-               }
-
        } while (ret > 0);
 
        /* Make sure we finish off with a page size boundary */
-       wrote &= recorder->page_size - 1;
+       wrote &= recorder->subbuf_size - 1;
        if (wrote) {
-               memset(buf, 0, recorder->page_size);
-               write(recorder->fd, buf, recorder->page_size - wrote);
-               total += recorder->page_size;
+               memset(buf, 0, recorder->subbuf_size);
+               write(recorder->fd, buf, recorder->subbuf_size - wrote);
+               total += recorder->subbuf_size;
        }
 
        return total;
@@ -613,10 +408,13 @@
                read = 0;
                do {
                        ret = move_data(recorder);
-                       if (ret < 0)
+                       if (ret < 0) {
+                               if (errno == EINTR)
+                                       continue;
                                return ret;
+                       }
                        read += ret;
-               } while (ret);
+               } while (ret > 0 && !recorder->stop);
        } while (!recorder->stop);
 
        /* Flush out the rest */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/trace-timesync-kvm.c 
new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/trace-timesync-kvm.c
--- old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/trace-timesync-kvm.c  
2022-09-23 17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/trace-timesync-kvm.c  
2022-12-12 00:10:26.000000000 +0100
@@ -10,6 +10,7 @@
 #include <sys/stat.h>
 #include <dirent.h>
 #include <ctype.h>
+#include <limits.h>
 
 #include "trace-cmd.h"
 #include "trace-cmd-private.h"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/trace-util.c 
new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/trace-util.c
--- old/trace-cmd-libtracecmd-1.2.0/lib/trace-cmd/trace-util.c  2022-09-23 
17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/lib/trace-cmd/trace-util.c  2022-12-12 
00:10:26.000000000 +0100
@@ -31,7 +31,7 @@
 
 static bool debug;
 static bool notimeout;
-static int log_level = TEP_LOG_INFO;
+static int log_level = TEP_LOG_WARNING;
 static FILE *logfp;
 
 const static struct {
@@ -393,8 +393,6 @@
 void tracecmd_set_loglevel(enum tep_loglevel level)
 {
        log_level = level;
-       tracefs_set_loglevel(level);
-       tep_set_loglevel(level);
 }
 
 void __weak tracecmd_warning(const char *fmt, ...)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/tracecmd/include/trace-local.h 
new/trace-cmd-libtracecmd-1.3.0/tracecmd/include/trace-local.h
--- old/trace-cmd-libtracecmd-1.2.0/tracecmd/include/trace-local.h      
2022-09-23 17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/tracecmd/include/trace-local.h      
2022-12-12 00:10:26.000000000 +0100
@@ -40,6 +40,7 @@
 extern int silence_warnings;
 extern int show_status;
 
+void trace_set_loglevel(int level);
 int trace_set_verbose(char *level);
 
 enum port_type {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-cmd.c 
new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-cmd.c
--- old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-cmd.c        2022-09-23 
17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-cmd.c        2022-12-12 
00:10:26.000000000 +0100
@@ -76,6 +76,13 @@
        { .id = TEP_LOG_ALL, .name = "all" },
 };
 
+void trace_set_loglevel(int level)
+{
+       tracecmd_set_loglevel(level);
+       tracefs_set_loglevel(level);
+       tep_set_loglevel(level);
+}
+
 int trace_set_verbose(char *level)
 {
        int id;
@@ -89,7 +96,7 @@
                if (id >= TEP_LOG_NONE) {
                        if (id > TEP_LOG_ALL)
                                id = TEP_LOG_ALL;
-                       tracecmd_set_loglevel(id);
+                       trace_set_loglevel(id);
                        return 0;
                }
        } else {
@@ -98,7 +105,7 @@
 
                for (i = 0; i < size; i++) {
                        if (!strncmp(level, log_severity[i].name, 
strlen(log_severity[i].name))) {
-                               tracecmd_set_loglevel(log_severity[i].id);
+                               trace_set_loglevel(log_severity[i].id);
                                return 0;
                        }
                }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-convert.c 
new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-convert.c
--- old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-convert.c    2022-09-23 
17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-convert.c    2022-12-12 
00:10:26.000000000 +0100
@@ -104,6 +104,8 @@
                input_file = DEFAULT_INPUT_FILE;
        if (!output_file)
                usage(argv);
+       if (file_version >= FILE_VERSION_COMPRESSION && !compression)
+               compression = "any";
 
        convert_file(input_file, output_file, file_version, compression);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-read.c 
new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-read.c
--- old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-read.c       2022-09-23 
17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-read.c       2022-12-12 
00:10:26.000000000 +0100
@@ -1565,6 +1565,8 @@
 
        signal(SIGINT, sig_end);
 
+       trace_set_loglevel(TEP_LOG_ERROR);
+
        for (;;) {
                int option_index = 0;
                static struct option long_options[] = {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-record.c 
new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-record.c
--- old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-record.c     2022-09-23 
17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-record.c     2022-12-12 
00:10:26.000000000 +0100
@@ -3326,19 +3326,11 @@
 {
        struct tracecmd_recorder *recorder;
        unsigned flags = recorder_flags | TRACECMD_RECORD_BLOCK_SPLICE;
-       char *path;
-
-       path = tracefs_instance_get_dir(instance->tracefs);
-
-       if (!path)
-               die("malloc");
 
        /* This is already the child */
        close(brass[0]);
 
-       recorder = tracecmd_create_buffer_recorder_fd(brass[1], cpu, flags, 
path);
-
-       tracefs_put_tracing_file(path);
+       recorder = tracecmd_create_buffer_recorder_fd(brass[1], cpu, flags, 
instance->tracefs);
 
        return recorder;
 }
@@ -3349,7 +3341,6 @@
 {
        struct tracecmd_recorder *record;
        struct addrinfo *result;
-       char *path;
 
        if (is_guest(instance)) {
                int fd;
@@ -3386,12 +3377,8 @@
        if (!tracefs_instance_get_name(instance->tracefs))
                return tracecmd_create_recorder_maxkb(file, cpu, 
recorder_flags, max_kb);
 
-       path = tracefs_instance_get_dir(instance->tracefs);
-
        record = tracecmd_create_buffer_recorder_maxkb(file, cpu, 
recorder_flags,
-                                                      path, max_kb);
-       tracefs_put_tracing_file(path);
-
+                                                      instance->tracefs, 
max_kb);
        return record;
 }
 
@@ -3402,6 +3389,7 @@
 static int create_recorder(struct buffer_instance *instance, int cpu,
                           enum trace_type type, int *brass)
 {
+       struct tracefs_instance *recorder_instance = NULL;
        long ret;
        char *file;
        pid_t pid;
@@ -3427,7 +3415,6 @@
 
        if ((instance->client_ports && !is_guest(instance)) || 
is_agent(instance)) {
                unsigned int flags = recorder_flags;
-               char *path = NULL;
                int fd;
 
                if (is_agent(instance)) {
@@ -3449,19 +3436,10 @@
                }
                if (fd < 0)
                        die("Failed connecting to client");
-               if (tracefs_instance_get_name(instance->tracefs) && 
!is_agent(instance)) {
-                       path = tracefs_instance_get_dir(instance->tracefs);
-               } else {
-                       const char *dir = tracefs_tracing_dir();
-
-                       if (dir)
-                               path = strdup(dir);
-               }
-               if (!path)
-                       die("can't get the tracing directory");
+               if (tracefs_instance_get_name(instance->tracefs) && 
!is_agent(instance))
+                       recorder_instance = instance->tracefs;
 
-               recorder = tracecmd_create_buffer_recorder_fd(fd, cpu, flags, 
path);
-               tracefs_put_tracing_file(path);
+               recorder = tracecmd_create_buffer_recorder_fd(fd, cpu, flags, 
recorder_instance);
        } else {
                file = get_temp_file(instance, cpu);
                recorder = create_recorder_instance(instance, file, cpu, brass);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-setup-guest.c 
new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-setup-guest.c
--- old/trace-cmd-libtracecmd-1.2.0/tracecmd/trace-setup-guest.c        
2022-09-23 17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/tracecmd/trace-setup-guest.c        
2022-12-12 00:10:26.000000000 +0100
@@ -121,7 +121,7 @@
                "  <target type='virtio' name='%s%d'/>\n"
                "</channel>";
        char tmp_path[PATH_MAX], path[PATH_MAX];
-       char cmd[PATH_MAX], xml[PATH_MAX];
+       char cmd[PATH_MAX + 256], xml[PATH_MAX + 256];
        int i, fd, ret = 0;
 
        strcpy(tmp_path, "/tmp/pipexmlXXXXXX");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/trace-cmd-libtracecmd-1.2.0/utest/Makefile 
new/trace-cmd-libtracecmd-1.3.0/utest/Makefile
--- old/trace-cmd-libtracecmd-1.2.0/utest/Makefile      2022-09-23 
17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/utest/Makefile      2022-12-12 
00:10:26.000000000 +0100
@@ -23,7 +23,7 @@
 $(OBJS): | $(bdir)
 $(DEPS): | $(bdir)
 
-$(bdir)/trace-utest: $(OBJS)
+$(bdir)/trace-utest: $(OBJS) $(LIBTRACECMD_STATIC)
        $(Q)$(do_app_build)
 
 $(bdir)/%.o: %.c
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/trace-cmd-libtracecmd-1.2.0/utest/tracecmd-utest.c 
new/trace-cmd-libtracecmd-1.3.0/utest/tracecmd-utest.c
--- old/trace-cmd-libtracecmd-1.2.0/utest/tracecmd-utest.c      2022-09-23 
17:07:10.000000000 +0200
+++ new/trace-cmd-libtracecmd-1.3.0/utest/tracecmd-utest.c      2022-12-12 
00:10:26.000000000 +0100
@@ -10,6 +10,7 @@
 #include <time.h>
 #include <dirent.h>
 #include <unistd.h>
+#include <ctype.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/types.h>
@@ -111,9 +112,9 @@
        return ret;
 }
 
-static int pipe_it(int *ofd, int *efd, const char *cmd, va_list ap)
+static int pipe_it(int *ofd, int *efd, int (*func)(void *),
+                  void *data)
 {
-       char **argv;
        int obrass[2];
        int ebrass[2];
        pid_t pid;
@@ -130,9 +131,6 @@
                goto fail;
 
        if (!pid) {
-               argv = get_args(cmd, ap);
-               if (!argv)
-                       exit(-1);
 
                close(obrass[0]);
                close(STDOUT_FILENO);
@@ -144,7 +142,7 @@
                if (dup2(obrass[1], STDERR_FILENO) < 0)
                        exit(-1);
 
-               ret = execvp(tracecmd_exec, argv);
+               ret = func(data);
                exit(ret);
        }
 
@@ -165,26 +163,52 @@
        return -1;
 }
 
-static int grep_it(const char *match, const char *cmd, ...)
+struct do_grep {
+       const char              *cmd;
+       va_list                 *ap;
+};
+
+static int do_grep(void *data)
+{
+       struct do_grep *gdata = data;
+       char **argv;
+       int ret;
+
+       argv = get_args(gdata->cmd, *gdata->ap);
+       if (!argv)
+               exit(-1);
+
+       ret = execvp(tracecmd_exec, argv);
+       tracefs_list_free(argv);
+       return ret;
+}
+
+struct do_grep_it {
+       const char              *match;
+       const char              *cmd;
+       va_list                 *ap;
+};
+
+static int do_grep_it(void *data)
 {
+       struct do_grep_it *dgdata = data;
+       struct do_grep gdata;
        FILE *fp;
        regex_t reg;
-       va_list ap;
        char *buf = NULL;
        ssize_t n;
        size_t l = 0;
-       bool found = false;
        int ofd;
        int efd;
        int pid;
        int ret;
 
-       if (regcomp(&reg, match, REG_ICASE|REG_NOSUB))
+       if (regcomp(&reg, dgdata->match, REG_ICASE|REG_NOSUB))
                return -1;
 
-       va_start(ap, cmd);
-       pid = pipe_it(&ofd, &efd, cmd, ap);
-       va_end(ap);
+       gdata.cmd = dgdata->cmd;
+       gdata.ap = dgdata->ap;
+       pid = pipe_it(&ofd, &efd, do_grep, &gdata);
 
        if (pid < 0) {
                regfree(&reg);
@@ -197,10 +221,65 @@
 
        do {
                n = getline(&buf, &l, fp);
-               if (show_output && n > 0)
-                       printf("%s", buf);
                if (n > 0 && regexec(&reg, buf, 0, NULL, 0) == 0)
+                       printf("%s", buf);
+       } while (n >= 0);
+
+       free(buf);
+ out:
+       ret = wait_for_exec(pid);
+       if (fp)
+               fclose(fp);
+       else
+               perror("fp");
+       close(ofd);
+       close(efd);
+       regfree(&reg);
+
+       return ret > 0 ? 0 : ret;
+}
+
+struct do_grep_match {
+       const char              *match;
+       const char              *cmd;
+       va_list                 *ap;
+};
+
+static int grep_match(const char *match, const char *cmd, ...)
+{
+       struct do_grep_it gdata;
+       FILE *fp;
+       va_list ap;
+       char *buf = NULL;
+       ssize_t n;
+       size_t l = 0;
+       bool found = false;
+       int ofd;
+       int efd;
+       int pid;
+       int ret;
+
+       va_start(ap, cmd);
+       gdata.match = match;
+       gdata.cmd = cmd;
+       gdata.ap = &ap;
+       pid = pipe_it(&ofd, &efd, do_grep_it, &gdata);
+       va_end(ap);
+
+       if (pid < 0)
+               return -1;
+
+       fp = fdopen(ofd, "r");
+       if (!fp)
+               goto out;
+
+       do {
+               n = getline(&buf, &l, fp);
+               if (n > 0) {
+                       if (show_output)
+                               printf("%s", buf);
                        found = true;
+               }
        } while (n >= 0);
 
        free(buf);
@@ -215,7 +294,6 @@
                close(ofd);
        }
        close(efd);
-       regfree(&reg);
 
        return found ? 0 : 1;
 }
@@ -230,6 +308,76 @@
        CU_TEST(ret == 0);
 }
 
+static int read_stats(const char *out, const char *match, const char *cmd, ...)
+{
+       struct do_grep_it gdata;
+       FILE *fp;
+       va_list ap;
+       bool found = false;
+       char *buf = NULL;
+       char *p;
+       ssize_t n;
+       size_t l = 0;
+       int ofd;
+       int efd;
+       int pid;
+       int ret;
+       int val;
+
+       va_start(ap, cmd);
+       gdata.match = match;
+       gdata.cmd = cmd;
+       gdata.ap = &ap;
+       pid = pipe_it(&ofd, &efd, do_grep_it, &gdata);
+       va_end(ap);
+
+       if (pid < 0)
+               return -1;
+
+       fp = fdopen(ofd, "r");
+       if (!fp)
+               goto out;
+
+       do {
+               n = getline(&buf, &l, fp);
+               if (n > 0) {
+                       for (p = buf; isspace(*p); p++)
+                               ;
+                       val = atoi(p);
+                       found = true;
+                       if (show_output)
+                               printf("%s", buf);
+                       CU_TEST(val < 10000000);
+               }
+       } while (n >= 0);
+
+       free(buf);
+ out:
+       ret = wait_for_exec(pid);
+       if (fp)
+               fclose(fp);
+       else {
+               perror("fp");
+       }
+       if (!found)
+               ret = -1;
+       close(ofd);
+       close(efd);
+       return ret > 0 ? 0 : ret;
+}
+
+static void test_trace_record_max(void)
+{
+       int ret;
+
+       ret = run_trace("record", TRACECMD_OUT, "-p", "function", "-m", "5000",
+                       "sleep", "10", NULL);
+       CU_TEST(ret == 0);
+
+       ret = read_stats(TRACECMD_FILE, ".*bytes in size.*", "report", 
TRACECMD_IN, "--stat", NULL);
+       CU_TEST(ret == 0);
+}
+
 static void test_trace_convert6(void)
 {
        struct stat st;
@@ -240,7 +388,7 @@
                ret = run_trace("record", TRACECMD_OUT, "-e", "sched", "sleep", 
"1", NULL);
                CU_TEST(ret == 0);
        }
-       ret = grep_it("[ \t]6[ \t]*\\[Version\\]", "dump", TRACECMD_IN2, NULL);
+       ret = grep_match("[ \t]6[ \t]*\\[Version\\]", "dump", TRACECMD_IN2, 
NULL);
        CU_TEST(ret == 0);
 }
 
@@ -264,7 +412,8 @@
        tep_print_event(tep, seq, record, "%s-%d %s %s\n",
                        TEP_PRINT_COMM, TEP_PRINT_PID,
                        TEP_PRINT_NAME, TEP_PRINT_INFO);
-       trace_seq_do_printf(seq);
+       if (show_output)
+               trace_seq_do_printf(seq);
        return 0;
 }
 
@@ -343,4 +492,6 @@
                    test_trace_convert6);
        CU_add_test(suite, "Use libraries to read file",
                    test_trace_library_read);
+       CU_add_test(suite, "Test max length",
+                   test_trace_record_max);
 }

Reply via email to