From nobody Fri May 3 23:10:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1596695668; cv=none; d=zohomail.com; s=zohoarc; b=fgrxvHqqUradljcQmOiN+jLpGeuZttCs2eSZbjp5xXe6QuY/+ZDV/DCe/NqjPr9D1kiOp4xKwPctmHz9u3BGRQ3IyqNeoqjJjxHseBYDDUPi9iOAy7ulb/C7bDlIasxtfB8Zku0u21zfiySGcZoS/0b1lTReNBZ3gfnQE8bz540= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596695668; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=6uW1/zUBM8wFH3Ndpz98tMneZ3vV75mZD6c71mYbGUA=; b=PAxRsKtBefeajINngLiAxAcTMt5qBJVcyHXMXfNAfxfwOkpcNkwvFT/1m7oR6masK4H+yQyGdLsBNYwT2zKtopfoqD67NQFEBYRqPsTBHQLaOpqoSTdzuQUQ6TkKflj7osJTcAlfcVImoYgiccLlZd6D2ohI3siEpXJrVCVtUNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1596695668008434.83358401965506; Wed, 5 Aug 2020 23:34:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-178-KxAEMKaTNkylcTM3nIw6pQ-1; Thu, 06 Aug 2020 02:34:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 127DB106B24A; Thu, 6 Aug 2020 06:34:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 301B25FC36; Thu, 6 Aug 2020 06:34:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DF0279692E; Thu, 6 Aug 2020 06:34:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0766Y9j2029511 for ; Thu, 6 Aug 2020 02:34:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id C833E65C75; Thu, 6 Aug 2020 06:34:09 +0000 (UTC) Received: from hansolo.redhat.com (ovpn-13-2.pek2.redhat.com [10.72.13.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A58365C7E; Thu, 6 Aug 2020 06:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596695666; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6uW1/zUBM8wFH3Ndpz98tMneZ3vV75mZD6c71mYbGUA=; b=KQFCiy6ZR3jfdb9d3nePGZ3+FDxOPfm5S4xMTUMW+R+bNtyEeKAIE2+qRosIlGst4+JxPG fZ01XEiBy6ctw1d5VSJH/V4Cq9+EFyy6kqlRlx0ue9bfxmW/Areu0mzgyPXDR0rbwKWkYD ZKKN+/y76+vC1MUjPgifDLh5vm/qQE4= X-MC-Unique: KxAEMKaTNkylcTM3nIw6pQ-1 From: Han Han To: libvir-list@redhat.com Subject: [PATCH] kbase: Add knowledge base for libvirt systemtap Date: Thu, 6 Aug 2020 14:34:02 +0800 Message-Id: <20200806063402.1712156-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Han Han X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Han Han Reviewed-by: Daniel Henrique Barboza Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/kbase.rst | 3 ++ docs/kbase/meson.build | 1 + docs/kbase/systemtap.rst | 113 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 docs/kbase/systemtap.rst diff --git a/docs/kbase.rst b/docs/kbase.rst index 78daaa5989..d8bff5d41e 100644 --- a/docs/kbase.rst +++ b/docs/kbase.rst @@ -36,6 +36,9 @@ Knowledge base Examination of the security protections used for QEMU and how they n= eed configuring to allow use of QEMU passthrough with host files/devices. =20 + `Systemtap `__ + Explanation of how to use systemtap for libvirt tracing. + `Virtio-FS `__ Share a filesystem between the guest and the host =20 diff --git a/docs/kbase/meson.build b/docs/kbase/meson.build index d7f254e163..ca032a4b9b 100644 --- a/docs/kbase/meson.build +++ b/docs/kbase/meson.build @@ -13,6 +13,7 @@ docs_kbase_files =3D [ 'rpm-deployment', 's390_protected_virt', 'secureusage', + 'systemtap', 'virtiofs', ] =20 diff --git a/docs/kbase/systemtap.rst b/docs/kbase/systemtap.rst new file mode 100644 index 0000000000..34420efbb2 --- /dev/null +++ b/docs/kbase/systemtap.rst @@ -0,0 +1,113 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Systemtap of Libvirt +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. contents:: + +`Systemtap `__ is a scripting +language and tool for dynamically probing or tracing in Linux kernel +space or user space. This page is about the usage of systemtap +in libvirt tracing. + +Preparation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Libvirt +------------------------- + +Libvirt should be configured with the systemtap option to support libvirt +probing events in systemtap. + +For libvirt before **6.7.0**, it can be configured by: + +:: + + mkdir build + cd build + ../configure --with-dtrace + +For libvirt **6.7.0** or later, configure it by the ``meson`` (seeing +`libvirt compiling `__): + +:: + + meson build -Ddtrace=3Denabled + +For the libvirt binaries installed by the package manager like ``dnf`` or +``apt``, if libvirt systemtap tapset ``/usr/share/systemtap/tapset/libvirt= _*`` +exists, it means the libvirt enables the systemtap feature. + +Systemtap +------------------------ + +For most of linux distributions, execute ``stap-prep`` by root to prepare = the +environment for systemtap after installing the systemtap. If your distribu= tion +doesn't have ``stap-prep``, install the ``kernel debuginfo`` packages manu= ally. + +After these above, run this test command to confirm the systemtap works we= ll: + +:: + + stap -e 'probe oneshot{ printf("hello world\n")}' + + +Tracing events +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The libvirt systemtap tracing events are defined in tapset +``/usr/share/systemtap/tapset/libvirt_*``. Libvirt support these type of t= racing +events: ``dbus``, ``event_glib``, ``object``, ``qemu``, ``rpc``. + +List all tracing events in libvirt: + +:: + + grep 'probe libvirt.[a-z_0-9.]*' /usr/share/systemtap/tapset/libvirt_* = -o|cut -f 2 -d : + + +Tracing examples +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Here is an example of the systemtap script to trace the QMP messages sent = from libvirtd +daemon to the qemu process. +``qmp.stp``: + +:: + + probe begin + { + printf("Start tracing\n") + } + probe libvirt.qemu.monitor_send_msg + { + printf("QMPs: %s", msg); + } + +Then run the systemtap script attaching to the libvirtd process: + +:: + + stap qmp.stp -x `pidof libvirtd` + + +To trace a libvirtd started from command line, use the option ``-c`` + +:: + + stap qmp.stp -c "/usr/sbin/libvirtd" + + +Then after seeing the welcome message "Start tracing" from systemtap, then= execute a virsh +command associated with QMP, for example ``virsh domstats``. Then get the = QMP tracing logs +from systemtap. For example, the result from ``virsh domstats`` + +:: + + QMPs: {"execute":"query-balloon","id":"libvirt-393"} + QMPs: {"execute":"qom-get","arguments":{"path":"/machine/peripheral/bal= loon0","property":"guest-stats"},"id":"libvirt-394"} + QMPs: {"execute":"query-blockstats","id":"libvirt-395"} + QMPs: {"execute":"query-named-block-nodes","id":"libvirt-396"} + QMPs: {"execute":"query-iothreads","id":"libvirt-397"} + +For more examples of libvirt systemtap scripts, see the scripts in ``/usr/= share/doc/libvirt-docs/examples/systemtap`` +For more details of systemtap language, see `document of systemtap `__ --=20 2.27.0