lib: Remove dtrace/systemtap probes

These were added in libguestfs 1.14, but never really used.  Only a
handful of probes were available.  When I was benchmarking libguestfs
in 2016 I didn't even use these probes because better/simpler
techniques were available.
This commit is contained in:
Richard W.M. Jones
2022-08-16 15:32:06 +01:00
parent df5805df63
commit b018b35bd4
8 changed files with 0 additions and 193 deletions

View File

@@ -218,10 +218,6 @@ eg. F</etc/libguestfs-tools.conf>.
Optional. Used by the L<libvirt backend|guestfs(3)/BACKEND> to Optional. Used by the L<libvirt backend|guestfs(3)/BACKEND> to
securely confine the appliance (sVirt). securely confine the appliance (sVirt).
=item systemtap
Optional. For userspace probes.
=item readline =item readline
Optional. For nicer command line editing in L<guestfish(1)>. Optional. For nicer command line editing in L<guestfish(1)>.

View File

@@ -434,72 +434,6 @@ timings:
The timestamps are seconds (incrementally since the previous line). The timestamps are seconds (incrementally since the previous line).
=head2 Detailed timings using SystemTap
You can use SystemTap (L<stap(1)>) to get detailed timings from
libguestfs programs.
Save the following script as F<time.stap>:
global last;
function display_time () {
now = gettimeofday_us ();
delta = 0;
if (last > 0)
delta = now - last;
last = now;
printf ("%d (+%d):", now, delta);
}
probe begin {
last = 0;
printf ("ready\n");
}
/* Display all calls to static markers. */
probe process("/usr/lib*/libguestfs.so.0")
.provider("guestfs").mark("*") ? {
display_time();
printf ("\t%s %s\n", $$name, $$parms);
}
/* Display all calls to guestfs_* functions. */
probe process("/usr/lib*/libguestfs.so.0")
.function("guestfs_[a-z]*") ? {
display_time();
printf ("\t%s %s\n", probefunc(), $$parms);
}
Run it as root in one window:
# stap time.stap
ready
It prints "ready" when SystemTap has loaded the program. Run your
libguestfs program, guestfish or a virt tool in another window. For
example:
$ guestfish -a /dev/null run
In the stap window you will see a large amount of output, with the
time taken for each step shown (microseconds in parenthesis). For
example:
xxxx (+0): guestfs_create
xxxx (+29): guestfs_set_pgroup g=0x17a9de0 pgroup=0x1
xxxx (+9): guestfs_add_drive_opts_argv g=0x17a9de0 [...]
xxxx (+8): guestfs_int_safe_strdup g=0x17a9de0 str=0x7f8a153bed5d
xxxx (+19): guestfs_int_safe_malloc g=0x17a9de0 nbytes=0x38
xxxx (+5): guestfs_int_safe_strdup g=0x17a9de0 str=0x17a9f60
xxxx (+10): guestfs_launch g=0x17a9de0
xxxx (+4): launch_start
[etc]
You will need to consult, and even modify, the source to libguestfs to
fully understand the output.
=head2 Detailed debugging using gdb =head2 Detailed debugging using gdb
You can attach to the appliance BIOS/kernel using gdb. If you know You can attach to the appliance BIOS/kernel using gdb. If you know

View File

@@ -63,26 +63,6 @@ typedef struct hash_table Hash_table;
#endif #endif
#endif #endif
#if ENABLE_PROBES
#include <sys/sdt.h>
/* NB: The 'name' parameter is a literal identifier, NOT a string! */
#define TRACE0(name) DTRACE_PROBE(guestfs, name)
#define TRACE1(name, arg1) \
DTRACE_PROBE(guestfs, name, (arg1))
#define TRACE2(name, arg1, arg2) \
DTRACE_PROBE(guestfs, name, (arg1), (arg2))
#define TRACE3(name, arg1, arg2, arg3) \
DTRACE_PROBE(guestfs, name, (arg1), (arg2), (arg3))
#define TRACE4(name, arg1, arg2, arg3, arg4) \
DTRACE_PROBE(guestfs, name, (arg1), (arg2), (arg3), (arg4))
#else /* !ENABLE_PROBES */
#define TRACE0(name)
#define TRACE1(name, arg1)
#define TRACE2(name, arg1, arg2)
#define TRACE3(name, arg1, arg2, arg3)
#define TRACE4(name, arg1, arg2, arg3, arg4)
#endif
/* https://stackoverflow.com/a/1597129 */ /* https://stackoverflow.com/a/1597129 */
#define XXUNIQUE_VAR(name, line) name ## line #define XXUNIQUE_VAR(name, line) name ## line
#define XUNIQUE_VAR(name, line) XXUNIQUE_VAR (name, line) #define XUNIQUE_VAR(name, line) XXUNIQUE_VAR (name, line)

View File

@@ -2879,77 +2879,6 @@ are being deleted, but other manipulations of keys within the loop
might not terminate unless you also maintain an indication of which might not terminate unless you also maintain an indication of which
keys have been visited. keys have been visited.
=head1 SYSTEMTAP
The libguestfs C library can be probed using systemtap or DTrace.
This is true of any library, not just libguestfs. However libguestfs
also contains static markers to help in probing internal operations.
You can list all the static markers by doing:
stap -l 'process("/usr/lib*/libguestfs.so.0")
.provider("guestfs").mark("*")'
B<Note:> These static markers are I<not> part of the stable API and
may change in future versions.
=head2 SYSTEMTAP SCRIPT EXAMPLE
This script contains examples of displaying both the static markers
and some ordinary C entry points:
global last;
function display_time () {
now = gettimeofday_us ();
delta = 0;
if (last > 0)
delta = now - last;
last = now;
printf ("%d (+%d):", now, delta);
}
probe begin {
last = 0;
printf ("ready\n");
}
/* Display all calls to static markers. */
probe process("/usr/lib*/libguestfs.so.0")
.provider("guestfs").mark("*") ? {
display_time();
printf ("\t%s %s\n", $$name, $$parms);
}
/* Display all calls to guestfs_mkfs* functions. */
probe process("/usr/lib*/libguestfs.so.0")
.function("guestfs_mkfs*") ? {
display_time();
printf ("\t%s %s\n", probefunc(), $$parms);
}
The script above can be saved to F<test.stap> and run using the
L<stap(1)> program. Note that you either have to be root, or you have
to add yourself to several special stap groups. Consult the systemtap
documentation for more information.
# stap /tmp/test.stap
ready
In another terminal, run a guestfish command such as this:
guestfish -N fs
In the first terminal, stap trace output similar to this is shown:
1318248056692655 (+0): launch_start
1318248056692850 (+195): launch_build_appliance_start
1318248056818285 (+125435): launch_build_appliance_end
1318248056838059 (+19774): launch_run_qemu
1318248061071167 (+4233108): launch_end
1318248061280324 (+209157): guestfs_mkfs g=0x1024ab0 fstype=0x46116f device=0x1024e60
=head1 LIBGUESTFS VERSION NUMBERS =head1 LIBGUESTFS VERSION NUMBERS
Since April 2010, libguestfs has started to make separate development Since April 2010, libguestfs has started to make separate development

View File

@@ -365,15 +365,11 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
guestfs_int_launch_send_progress (g, 0); guestfs_int_launch_send_progress (g, 0);
TRACE0 (launch_build_appliance_start);
/* Locate and/or build the appliance. */ /* Locate and/or build the appliance. */
if (guestfs_int_build_appliance (g, &kernel, &initrd, &appliance) == -1) if (guestfs_int_build_appliance (g, &kernel, &initrd, &appliance) == -1)
return -1; return -1;
has_appliance_drive = appliance != NULL; has_appliance_drive = appliance != NULL;
TRACE0 (launch_build_appliance_end);
guestfs_int_launch_send_progress (g, 3); guestfs_int_launch_send_progress (g, 3);
debug (g, "begin testing qemu features"); debug (g, "begin testing qemu features");
@@ -760,8 +756,6 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
setenv ("LC_ALL", "C", 1); setenv ("LC_ALL", "C", 1);
setenv ("QEMU_AUDIO_DRV", "none", 1); /* Prevents qemu opening /dev/dsp */ setenv ("QEMU_AUDIO_DRV", "none", 1); /* Prevents qemu opening /dev/dsp */
TRACE0 (launch_run_qemu);
execv (g->hv, argv); /* Run qemu. */ execv (g->hv, argv); /* Run qemu. */
perror (g->hv); perror (g->hv);
_exit (EXIT_FAILURE); _exit (EXIT_FAILURE);
@@ -902,8 +896,6 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
goto cleanup1; goto cleanup1;
} }
TRACE0 (launch_end);
guestfs_int_launch_send_progress (g, 12); guestfs_int_launch_send_progress (g, 12);
if (has_appliance_drive) if (has_appliance_drive)

View File

@@ -362,7 +362,6 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
} }
guestfs_int_launch_send_progress (g, 0); guestfs_int_launch_send_progress (g, 0);
TRACE0 (launch_libvirt_start);
/* Create a random name for the guest. */ /* Create a random name for the guest. */
memcpy (data->name, "guestfs-", 8); memcpy (data->name, "guestfs-", 8);
@@ -481,8 +480,6 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
guestfs_pop_error_handler (g); guestfs_pop_error_handler (g);
/* Locate and/or build the appliance. */ /* Locate and/or build the appliance. */
TRACE0 (launch_build_libvirt_appliance_start);
debug (g, "build appliance"); debug (g, "build appliance");
if (guestfs_int_build_appliance (g, &params.kernel, &params.initrd, if (guestfs_int_build_appliance (g, &params.kernel, &params.initrd,
@@ -490,7 +487,6 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
goto cleanup; goto cleanup;
guestfs_int_launch_send_progress (g, 3); guestfs_int_launch_send_progress (g, 3);
TRACE0 (launch_build_libvirt_appliance_end);
/* Note that appliance can be NULL if using the old-style appliance. */ /* Note that appliance can be NULL if using the old-style appliance. */
if (params.appliance) { if (params.appliance) {
@@ -503,8 +499,6 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
goto cleanup; goto cleanup;
} }
TRACE0 (launch_build_libvirt_qcow2_overlay_end);
/* Using virtio-serial, we need to create a local Unix domain socket /* Using virtio-serial, we need to create a local Unix domain socket
* for qemu to connect to. * for qemu to connect to.
*/ */
@@ -717,8 +711,6 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
if (params.appliance) if (params.appliance)
guestfs_int_add_dummy_appliance_drive (g); guestfs_int_add_dummy_appliance_drive (g);
TRACE0 (launch_libvirt_end);
guestfs_int_launch_send_progress (g, 12); guestfs_int_launch_send_progress (g, 12);
data->conn = conn; data->conn = conn;

View File

@@ -79,7 +79,6 @@ guestfs_impl_launch (guestfs_h *g)
/* Start the clock ... */ /* Start the clock ... */
gettimeofday (&g->launch_t, NULL); gettimeofday (&g->launch_t, NULL);
TRACE0 (launch_start);
/* Make the temporary directory. */ /* Make the temporary directory. */
if (guestfs_int_lazy_make_tmpdir (g) == -1) if (guestfs_int_lazy_make_tmpdir (g) == -1)

View File

@@ -225,21 +225,6 @@ if test "x$have_libselinux" = "xyes"; then
fi fi
AC_SUBST([SELINUX_LIBS]) AC_SUBST([SELINUX_LIBS])
dnl Check for systemtap/DTrace userspace probes (optional).
dnl Since the probe points break under clang, allow this to be disabled.
AC_ARG_ENABLE([probes],
AS_HELP_STRING([--disable-probes], [disable systemtap/DTrace userspace probes]),
[],
[enable_probes=yes])
AS_IF([test "x$enable_probes" != "xno"],[
dnl http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps
AC_CHECK_HEADERS([sys/sdt.h])
dnl AC_CHECK_PROG([DTRACE],[dtrace],[dtrace],[no])
AS_IF([test "x$ac_cv_header_sys_sdt_h" = "xyes"],[
AC_DEFINE([ENABLE_PROBES],[1],[Enable systemtap/DTrace userspace probes.])
])
])
dnl Enable packet dumps when in verbose mode. This generates lots dnl Enable packet dumps when in verbose mode. This generates lots
dnl of debug info, only useful for people debugging the RPC mechanism. dnl of debug info, only useful for people debugging the RPC mechanism.
AC_ARG_ENABLE([packet-dump],[ AC_ARG_ENABLE([packet-dump],[