<div dir="ltr"><div>ping, any more reviews?<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 6, 2020 at 9:44 PM Daniel Henrique Barboza <<a href="mailto:danielhb413@gmail.com">danielhb413@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On 8/6/20 3:34 AM, Han Han wrote:<br>
> Signed-off-by: Han Han <<a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a>><br>
> ---<br>
>   docs/kbase.rst           |   3 ++<br>
>   docs/kbase/meson.build   |   1 +<br>
>   docs/kbase/systemtap.rst | 113 +++++++++++++++++++++++++++++++++++++++<br>
>   3 files changed, 117 insertions(+)<br>
>   create mode 100644 docs/kbase/systemtap.rst<br>
> <br>
> diff --git a/docs/kbase.rst b/docs/kbase.rst<br>
> index 78daaa5989..d8bff5d41e 100644<br>
> --- a/docs/kbase.rst<br>
> +++ b/docs/kbase.rst<br>
> @@ -36,6 +36,9 @@ Knowledge base<br>
>         Examination of the security protections used for QEMU and how they need<br>
>         configuring to allow use of QEMU passthrough with host files/devices.<br>
>   <br>
> +   `Systemtap <kbase/systemtap.html>`__<br>
> +      Explanation of how to use systemtap for libvirt tracing.<br>
> +<br>
>      `Virtio-FS <kbase/virtiofs.html>`__<br>
>         Share a filesystem between the guest and the host<br>
>   <br>
> diff --git a/docs/kbase/meson.build b/docs/kbase/meson.build<br>
> index d7f254e163..ca032a4b9b 100644<br>
> --- a/docs/kbase/meson.build<br>
> +++ b/docs/kbase/meson.build<br>
> @@ -13,6 +13,7 @@ docs_kbase_files = [<br>
>     'rpm-deployment',<br>
>     's390_protected_virt',<br>
>     'secureusage',<br>
> +  'systemtap',<br>
>     'virtiofs',<br>
>   ]<br>
>   <br>
> diff --git a/docs/kbase/systemtap.rst b/docs/kbase/systemtap.rst<br>
> new file mode 100644<br>
> index 0000000000..34420efbb2<br>
> --- /dev/null<br>
> +++ b/docs/kbase/systemtap.rst<br>
> @@ -0,0 +1,113 @@<br>
> +=======================<br>
> +Systemtap of Libvirt<br>
> +=======================<br>
> +<br>
> +.. contents::<br>
> +<br>
> +`Systemtap <<a href="https://sourceware.org/systemtap/" rel="noreferrer" target="_blank">https://sourceware.org/systemtap/</a>>`__ is a scripting<br>
> +language and tool for dynamically probing or tracing in Linux kernel<br>
> +space or user space. This page is about the usage of systemtap<br>
> +in libvirt tracing.<br>
> +<br>
> +Preparation<br>
> +===================<br>
> +<br>
> +Libvirt<br>
> +-------------------------<br>
> +<br>
> +Libvirt should be configured with the systemtap option to support libvirt<br>
> +probing events in systemtap.<br>
> +<br>
> +For libvirt before **6.7.0**, it can be configured by:<br>
> +<br>
> +::<br>
> +<br>
> +    mkdir build<br>
> +    cd build<br>
> +   ../configure --with-dtrace<br>
> +<br>
> +For libvirt **6.7.0** or later, configure it by the ``meson`` (seeing<br>
> +`libvirt compiling <<a href="https://libvirt.org/compiling.html" rel="noreferrer" target="_blank">https://libvirt.org/compiling.html</a>>`__):<br>
> +<br>
> +::<br>
> +<br>
> +   meson build -Ddtrace=enabled<br>
> +<br>
> +For the libvirt binaries installed by the package manager like ``dnf`` or<br>
> +``apt``, if libvirt systemtap tapset ``/usr/share/systemtap/tapset/libvirt_*``<br>
> +exists, it means the libvirt enables the systemtap feature.<br>
> +<br>
> +Systemtap<br>
> +------------------------<br>
> +<br>
> +For most of linux distributions, execute ``stap-prep`` by root to prepare the<br>
> +environment for systemtap after installing the systemtap. If your distribution<br>
> +doesn't have ``stap-prep``, install the ``kernel debuginfo`` packages manually.<br>
> +<br>
> +After these above, run this test command to confirm the systemtap works well:<br>
> +<br>
> +::<br>
> +<br>
> +   stap -e 'probe oneshot{ printf("hello world\n")}'<br>
> +<br>
> +<br>
> +Tracing events<br>
> +=======================<br>
> +<br>
> +The libvirt systemtap tracing events are defined in tapset<br>
> +``/usr/share/systemtap/tapset/libvirt_*``. Libvirt support these type of tracing<br>
<br>
s/type/types<br>
<br></blockquote><div>Thanks <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
With this nit fixed:<br>
<br>
<br>
Reviewed-by: Daniel Henrique Barboza <<a href="mailto:danielhb413@gmail.com" target="_blank">danielhb413@gmail.com</a>><br>
<br>
<br>
<br>
> +events: ``dbus``, ``event_glib``, ``object``, ``qemu``, ``rpc``.<br>
> +<br>
> +List all tracing events in libvirt:<br>
> +<br>
> +::<br>
> +<br>
> +   grep 'probe libvirt.[a-z_0-9.]*' /usr/share/systemtap/tapset/libvirt_* -o|cut -f 2 -d :<br>
> +<br>
> +<br>
> +Tracing examples<br>
> +==================<br>
> +<br>
> +Here is an example of the systemtap script to trace the QMP messages sent from libvirtd<br>
> +daemon to the qemu process.<br>
> +``qmp.stp``:<br>
> +<br>
> +::<br>
> +<br>
> +   probe begin<br>
> +   {<br>
> +     printf("Start tracing\n")<br>
> +   }<br>
> +   probe libvirt.qemu.monitor_send_msg<br>
> +   {<br>
> +     printf("QMPs: %s", msg);<br>
> +   }<br>
> +<br>
> +Then run the systemtap script attaching to the libvirtd process:<br>
> +<br>
> +::<br>
> +<br>
> +   stap qmp.stp -x `pidof libvirtd`<br>
> +<br>
> +<br>
> +To trace a libvirtd started from command line, use the option ``-c``<br>
> +<br>
> +::<br>
> +<br>
> +   stap qmp.stp -c "/usr/sbin/libvirtd"<br>
> +<br>
> +<br>
> +Then after seeing the welcome message "Start tracing" from systemtap, then execute a virsh<br>
> +command associated with QMP, for example ``virsh domstats``. Then get the QMP tracing logs<br>
> +from systemtap. For example, the result from ``virsh domstats``<br>
> +<br>
> +::<br>
> +<br>
> +   QMPs: {"execute":"query-balloon","id":"libvirt-393"}<br>
> +   QMPs: {"execute":"qom-get","arguments":{"path":"/machine/peripheral/balloon0","property":"guest-stats"},"id":"libvirt-394"}<br>
> +   QMPs: {"execute":"query-blockstats","id":"libvirt-395"}<br>
> +   QMPs: {"execute":"query-named-block-nodes","id":"libvirt-396"}<br>
> +   QMPs: {"execute":"query-iothreads","id":"libvirt-397"}<br>
> +<br>
> +For more examples of libvirt systemtap scripts, see the scripts in ``/usr/share/doc/libvirt-docs/examples/systemtap``<br>
> +For more details of systemtap language, see `document of systemtap <<a href="https://sourceware.org/systemtap/documentation.html" rel="noreferrer" target="_blank">https://sourceware.org/systemtap/documentation.html</a>>`__<br>
> <br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Best regards,</div><div dir="ltr">-----------------------------------<br></div><div dir="ltr">Han Han<br>Senior Quality Engineer<br>Redhat.<br><br>Email: <a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a><br>Phone: +861065339333<br></div></div></div></div></div></div></div>