]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add systemd/dtrace probes for DBus APIs
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 11 Nov 2014 18:39:19 +0000 (18:39 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 15 Jan 2015 11:07:13 +0000 (11:07 +0000)
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
src/util/virdbus.c

index 340d665e82bae8fdc74db42ade96a8af3895a1a7..c5bda5c974bbf1552cdb9cf928e0b974e360bf27 100644 (file)
@@ -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
index ee8732c23354bec0ede275a987044553b6db9081..d9665c1f7ff74ff1ed43ff011df6505539771afc 100644 (file)
@@ -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)