[PATCH 2/4] Add systemd/dtrace probes for DBus APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When debugging libvirt it is helpful to set probes around RPC
calls. We already have probes for libvirt's native RPC layer,
so it makes sense to add them for the DBus RPC layer too.
---
 src/libvirt_probes.d |  5 +++++
 src/util/virdbus.c   | 26 +++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/libvirt_probes.d b/src/libvirt_probes.d
index 340d665..c5bda5c 100644
--- a/src/libvirt_probes.d
+++ b/src/libvirt_probes.d
@@ -15,6 +15,11 @@ provider libvirt {
 
 	probe event_poll_run(int nfds, int timeout);
 
+	# file: src/util/virdbus.c
+	# prefix: dbus
+	probe dbus_method_call(const char *interface, const char *member, const char *object, const char *destination);
+	probe dbus_method_error(const char *interface, const char *member, const char *object, const char *destination, const char *name, const char *message);
+	probe dbus_method_reply(const char *interface, const char *member, const char *object, const char *destination);
 
         # file: src/util/virobject.c
         # prefix: object
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index ee8732c..d9665c1 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -27,6 +27,7 @@
 #include "virlog.h"
 #include "virthread.h"
 #include "virstring.h"
+#include "virprobe.h"
 
 #define VIR_FROM_THIS VIR_FROM_DBUS
 
@@ -1521,20 +1522,35 @@ static int
 virDBusCall(DBusConnection *conn,
             DBusMessage *call,
             DBusMessage **replyout,
-            DBusError *error,
-            const char *member)
+            DBusError *error)
+
 {
     DBusMessage *reply = NULL;
     DBusError localerror;
     int ret = -1;
+    const char *iface, *member, *path, *dest;
 
     if (!error)
         dbus_error_init(&localerror);
 
+    iface = dbus_message_get_interface(call);
+    member = dbus_message_get_member(call);
+    path = dbus_message_get_path(call);
+    dest = dbus_message_get_destination(call);
+
+    PROBE(DBUS_METHOD_CALL,
+          "'%s.%s' on '%s' at '%s'",
+          iface, member, path, dest);
+
     if (!(reply = dbus_connection_send_with_reply_and_block(conn,
                                                             call,
                                                             VIR_DBUS_METHOD_CALL_TIMEOUT_MILLIS,
                                                             error ? error : &localerror))) {
+        PROBE(DBUS_METHOD_ERROR,
+              "'%s.%s' on '%s' at '%s' error %s: %s",
+              iface, member, path, dest,
+              error ? error->name : localerror.name,
+              error ? error->message : localerror.message);
         if (error) {
             ret = 0;
         } else {
@@ -1544,6 +1560,10 @@ virDBusCall(DBusConnection *conn,
         goto cleanup;
     }
 
+    PROBE(DBUS_METHOD_REPLY,
+          "'%s.%s' on '%s' at '%s'",
+          iface, member, path, dest);
+
     ret = 0;
 
  cleanup:
@@ -1616,7 +1636,7 @@ int virDBusCallMethod(DBusConnection *conn,
 
     ret = -1;
 
-    ret = virDBusCall(conn, call, replyout, error, member);
+    ret = virDBusCall(conn, call, replyout, error);
 
  cleanup:
     if (call)
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]