diff mbox series

[RFC,v5,22/23] vfio-user: add tracing to send/recv paths

Message ID 115153bd4c41c4b2e2d5b046e76fc0f06ea3bf78.1651709440.git.john.g.johnson@oracle.com (mailing list archive)
State New, archived
Headers show
Series [RFC,v5,01/23] vfio-user: introduce vfio-user protocol specification | expand

Commit Message

John Johnson May 5, 2022, 5:20 p.m. UTC
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
---
 hw/vfio/user.c       | 8 ++++++++
 hw/vfio/trace-events | 5 +++++
 2 files changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/hw/vfio/user.c b/hw/vfio/user.c
index ec2d89b..a3e4dc8 100644
--- a/hw/vfio/user.c
+++ b/hw/vfio/user.c
@@ -29,6 +29,8 @@ 
 #include "qapi/qmp/qstring.h"
 #include "qapi/qmp/qnum.h"
 #include "user.h"
+#include "trace.h"
+
 
 /*
  * These are to defend against a malign server trying
@@ -111,6 +113,8 @@  static int vfio_user_send_qio(VFIOProxy *proxy, VFIOUserMsg *msg)
         vfio_user_shutdown(proxy);
         error_report_err(local_err);
     }
+    trace_vfio_user_send_write(msg->hdr->id, ret);
+
     return ret;
 }
 
@@ -227,6 +231,7 @@  static int vfio_user_complete(VFIOProxy *proxy, Error **errp)
             }
             return ret;
         }
+        trace_vfio_user_recv_read(msg->hdr->id, ret);
 
         msgleft -= ret;
         data += ret;
@@ -334,6 +339,8 @@  static int vfio_user_recv_one(VFIOProxy *proxy)
         error_setg(&local_err, "unknown message type");
         goto fatal;
     }
+    trace_vfio_user_recv_hdr(proxy->sockname, hdr.id, hdr.command, hdr.size,
+                             hdr.flags);
 
     /*
      * For replies, find the matching pending request.
@@ -410,6 +417,7 @@  static int vfio_user_recv_one(VFIOProxy *proxy)
         if (ret <= 0) {
             goto fatal;
         }
+        trace_vfio_user_recv_read(hdr.id, ret);
 
         msgleft -= ret;
         data += ret;
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
index 0ef1b5f..ea4bd7e 100644
--- a/hw/vfio/trace-events
+++ b/hw/vfio/trace-events
@@ -165,3 +165,8 @@  vfio_load_state_device_data(const char *name, uint64_t data_offset, uint64_t dat
 vfio_load_cleanup(const char *name) " (%s)"
 vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start) "container fd=%d, iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64
 vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64
+
+# user.c
+vfio_user_recv_hdr(const char *name, uint16_t id, uint16_t cmd, uint32_t size, uint32_t flags) " (%s) id %x cmd %x size %x flags %x"
+vfio_user_recv_read(uint16_t id, int read) " id %x read %x"
+vfio_user_send_write(uint16_t id, int wrote) " id %x wrote %x"