[PATCH] Re-add DTrace probes on 'dispose' functions

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

When converting to virObject, the probes on the 'Free' functions
were removed on the basis that there is a probe on virObjectFree
that suffices. This puts a burden on people writing probe scripts
to identify which object is being dispose. This adds back probes
in the 'Dispose' functions and updates the rpc monitor systemtap
example to use them

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 examples/systemtap/rpc-monitor.stp | 32 +++++++++++++-------------------
 src/libvirt_probes.d               | 10 ++++++----
 src/rpc/virkeepalive.c             |  3 +++
 src/rpc/virnetclient.c             |  3 +++
 src/rpc/virnetserverclient.c       |  3 +++
 src/rpc/virnetsocket.c             |  4 +++-
 src/rpc/virnettlscontext.c         |  6 ++++++
 7 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/examples/systemtap/rpc-monitor.stp b/examples/systemtap/rpc-monitor.stp
index 4695c10..c8d5c17 100644
--- a/examples/systemtap/rpc-monitor.stp
+++ b/examples/systemtap/rpc-monitor.stp
@@ -117,11 +117,9 @@ probe libvirt.rpc.socket_new {
    remoteAddrs[pid(), sock] = remoteAddr;
 }
 
-probe libvirt.rpc.socket_free {
-   if (refs == 1) {
-      delete localAddrs[pid(), sock];
-      delete remoteAddrs[pid(), sock];
-  }
+probe libvirt.rpc.socket_dispose {
+   delete localAddrs[pid(), sock];
+   delete remoteAddrs[pid(), sock];
 }
 
 
@@ -131,13 +129,11 @@ probe libvirt.rpc.client_new {
    print_ts(sprintf("C + %-16p local=%s remote=%s", client, localAddrs[pid(), sock], remoteAddrs[pid(), sock]));
 }
 
-probe libvirt.rpc.client_free {
-   if (refs == 1) {
-     print_ts(sprintf("C - %-16p local=%s remote=%s", client,
-              localAddrs[pid(), clientSocks[pid(), client]],
-	      remoteAddrs[pid(), clientSocks[pid(), client]]));
-     delete clientSocks[pid(), client];
-   }
+probe libvirt.rpc.client_dispose {
+   print_ts(sprintf("C - %-16p local=%s remote=%s", client,
+            localAddrs[pid(), clientSocks[pid(), client]],
+	    remoteAddrs[pid(), clientSocks[pid(), client]]));
+   delete clientSocks[pid(), client];
 }
 
 
@@ -147,13 +143,11 @@ probe libvirt.rpc.server_client_new {
    print_ts(sprintf("+ S %-16p local=%s remote=%s", client, localAddrs[pid(), sock], remoteAddrs[pid(), sock]));
 }
 
-probe libvirt.rpc.server_client_free {
-   if (refs == 1) {
-     print_ts(sprintf("- S %-16p local=%s remote=%s", client,
-              localAddrs[pid(), serverSocks[pid(), client]],
-              remoteAddrs[pid(), serverSocks[pid(), client]]));
-     delete serverSocks[pid(), client];
-   }
+probe libvirt.rpc.server_client_dispose {
+   print_ts(sprintf("- S %-16p local=%s remote=%s", client,
+            localAddrs[pid(), serverSocks[pid(), client]],
+            remoteAddrs[pid(), serverSocks[pid(), client]]));
+   delete serverSocks[pid(), client];
 }
 
 
diff --git a/src/libvirt_probes.d b/src/libvirt_probes.d
index 9343fa4..340d665 100644
--- a/src/libvirt_probes.d
+++ b/src/libvirt_probes.d
@@ -26,6 +26,7 @@ provider libvirt {
 	# file: src/rpc/virnetsocket.c
 	# prefix: rpc
 	probe rpc_socket_new(void *sock, int fd, int errfd, pid_t pid, const char *localAddr, const char *remoteAddr);
+	probe rpc_socket_dispose(void *sock);
 	probe rpc_socket_send_fd(void *sock, int fd);
 	probe rpc_socket_recv_fd(void *sock, int fd);
 
@@ -33,7 +34,7 @@ provider libvirt {
 	# file: src/rpc/virnetserverclient.c
 	# prefix: rpc
 	probe rpc_server_client_new(void *client, void *sock);
-
+	probe rpc_server_client_dispose(void *client);
 	probe rpc_server_client_msg_tx_queue(void *client, int len, int prog, int vers, int proc, int type, int status, int serial);
 	probe rpc_server_client_msg_rx(void *client, int len, int prog, int vers, int proc, int type, int status, int serial);
 
@@ -41,7 +42,7 @@ provider libvirt {
 	# file: src/rpc/virnetclient.c
 	# prefix: rpc
 	probe rpc_client_new(void *client, void *sock);
-
+	probe rpc_client_dispose(void *client);
 	probe rpc_client_msg_tx_queue(void *client, int len, int prog, int vers, int proc, int type, int status, int serial);
 	probe rpc_client_msg_rx(void *client, int len, int prog, int vers, int proc, int type, int status, int serial);
 
@@ -57,14 +58,14 @@ provider libvirt {
 	# prefix: rpc
 	probe rpc_tls_context_new(void *ctxt, const char *cacert, const char *cacrl,
 				  const char *cert, const char *key, int sanityCheckCert, int requireValidCert, int isServer);
-
+	probe rpc_tls_context_dispose(void *ctxt);
 	probe rpc_tls_context_session_allow(void *ctxt, void *sess, const char *dname);
 	probe rpc_tls_context_session_deny(void *ctxt, void *sess, const char *dname);
 	probe rpc_tls_context_session_fail(void *ctxt, void *sess);
 
 
 	probe rpc_tls_session_new(void *sess, void *ctxt, const char *hostname, int isServer);
-
+	probe rpc_tls_session_dispose(void *sess);
 	probe rpc_tls_session_handshake_pass(void *sess);
 	probe rpc_tls_session_handshake_fail(void *sess);
 
@@ -72,6 +73,7 @@ provider libvirt {
 	# file: src/rpc/virkeepalive.c
 	# prefix: rpc
 	probe rpc_keepalive_new(void *ka, void *client);
+	probe rpc_keepalive_dispose(void *ka);
 	probe rpc_keepalive_start(void *ka, void *client, int interval, int count);
 	probe rpc_keepalive_stop(void *ka, void *client);
 	probe rpc_keepalive_send(void *ka, void *client, int prog, int vers, int proc);
diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index 71dd904..d49082c 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -224,6 +224,9 @@ virKeepAliveDispose(void *obj)
 {
     virKeepAlivePtr ka = obj;
 
+    PROBE(RPC_KEEPALIVE_DISPOSE,
+          "ka=%p", ka);
+
     ka->freeCB(ka->client);
 }
 
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index bfa1624..1379078 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -596,6 +596,9 @@ void virNetClientDispose(void *obj)
     virNetClientPtr client = obj;
     int i;
 
+    PROBE(RPC_CLIENT_DISPOSE,
+          "client=%p", client);
+
     if (client->closeFf)
         client->closeFf(client->closeOpaque);
 
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 9e519e6..19063ef 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -704,6 +704,9 @@ void virNetServerClientDispose(void *obj)
 {
     virNetServerClientPtr client = obj;
 
+    PROBE(RPC_SERVER_CLIENT_DISPOSE,
+          "client=%p", client);
+
     if (client->privateData &&
         client->privateDataFreeFunc)
         client->privateDataFreeFunc(client->privateData);
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 93980d6..fe4ac71 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -996,7 +996,9 @@ void virNetSocketDispose(void *obj)
 {
     virNetSocketPtr sock = obj;
 
-    VIR_DEBUG("sock=%p fd=%d", sock, sock->fd);
+    PROBE(RPC_SOCKET_DISPOSE,
+          "sock=%p", sock);
+
     if (sock->watch > 0) {
         virEventRemoveHandle(sock->watch);
         sock->watch = -1;
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 6665268..ece4620 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -1114,6 +1114,9 @@ void virNetTLSContextDispose(void *obj)
 {
     virNetTLSContextPtr ctxt = obj;
 
+    PROBE(RPC_TLS_CONTEXT_DISPOSE,
+          "ctxt=%p", ctxt);
+
     gnutls_dh_params_deinit(ctxt->dhParams);
     gnutls_certificate_free_credentials(ctxt->x509cred);
 }
@@ -1366,6 +1369,9 @@ void virNetTLSSessionDispose(void *obj)
 {
     virNetTLSSessionPtr sess = obj;
 
+    PROBE(RPC_TLS_SESSION_DISPOSE,
+          "sess=%p", sess);
+
     VIR_FREE(sess->hostname);
     gnutls_deinit(sess->session);
 }
-- 
1.8.1.4

--
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]