diff options
author | Hannes Reinecke <hare@suse.de> | 2020-11-16 19:31:12 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-01-12 12:38:03 +0100 |
commit | eb8cb3d9dcfbcc74ebaabed4ef0d915eeffa4da1 (patch) | |
tree | 9e84d84e34a9b8462287eab6d6d24cb7116cd46b /hw/scsi/virtio-scsi.c | |
parent | 3eacf70bb5a83e4775ad8003cbca63a40f70c8c2 (diff) | |
download | qemu-eb8cb3d9dcfbcc74ebaabed4ef0d915eeffa4da1.zip qemu-eb8cb3d9dcfbcc74ebaabed4ef0d915eeffa4da1.tar.gz qemu-eb8cb3d9dcfbcc74ebaabed4ef0d915eeffa4da1.tar.bz2 |
virtio-scsi: trace events
Add trace events for virtio command and response tracing.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Message-Id: <20201116183114.55703-2-hare@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi/virtio-scsi.c')
-rw-r--r-- | hw/scsi/virtio-scsi.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 3db9a8a..9690bc6 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -27,6 +27,7 @@ #include "scsi/constants.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" +#include "trace.h" static inline int virtio_scsi_get_lun(uint8_t *lun) { @@ -239,7 +240,11 @@ static void virtio_scsi_cancel_notify(Notifier *notifier, void *data) notifier); if (--n->tmf_req->remaining == 0) { - virtio_scsi_complete_req(n->tmf_req); + VirtIOSCSIReq *req = n->tmf_req; + + trace_virtio_scsi_tmf_resp(virtio_scsi_get_lun(req->req.tmf.lun), + req->req.tmf.tag, req->resp.tmf.response); + virtio_scsi_complete_req(req); } g_free(n); } @@ -273,6 +278,9 @@ static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req) req->req.tmf.subtype = virtio_tswap32(VIRTIO_DEVICE(s), req->req.tmf.subtype); + trace_virtio_scsi_tmf_req(virtio_scsi_get_lun(req->req.tmf.lun), + req->req.tmf.tag, req->req.tmf.subtype); + switch (req->req.tmf.subtype) { case VIRTIO_SCSI_T_TMF_ABORT_TASK: case VIRTIO_SCSI_T_TMF_QUERY_TASK: @@ -429,11 +437,23 @@ static void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req) virtio_scsi_bad_req(req); return; } else { + req->req.an.event_requested = + virtio_tswap32(VIRTIO_DEVICE(s), req->req.an.event_requested); + trace_virtio_scsi_an_req(virtio_scsi_get_lun(req->req.an.lun), + req->req.an.event_requested); req->resp.an.event_actual = 0; req->resp.an.response = VIRTIO_SCSI_S_OK; } } if (r == 0) { + if (type == VIRTIO_SCSI_T_TMF) + trace_virtio_scsi_tmf_resp(virtio_scsi_get_lun(req->req.tmf.lun), + req->req.tmf.tag, + req->resp.tmf.response); + else if (type == VIRTIO_SCSI_T_AN_QUERY || + type == VIRTIO_SCSI_T_AN_SUBSCRIBE) + trace_virtio_scsi_an_resp(virtio_scsi_get_lun(req->req.an.lun), + req->resp.an.response); virtio_scsi_complete_req(req); } else { assert(r == -EINPROGRESS); @@ -469,6 +489,10 @@ static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) static void virtio_scsi_complete_cmd_req(VirtIOSCSIReq *req) { + trace_virtio_scsi_cmd_resp(virtio_scsi_get_lun(req->req.cmd.lun), + req->req.cmd.tag, + req->resp.cmd.response, + req->resp.cmd.status); /* Sense data is not in req->resp and is copied separately * in virtio_scsi_command_complete. */ @@ -566,6 +590,8 @@ static int virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req) return -EINVAL; } } + trace_virtio_scsi_cmd_req(virtio_scsi_get_lun(req->req.cmd.lun), + req->req.cmd.tag, req->req.cmd.cdb[0]); d = virtio_scsi_device_get(s, req->req.cmd.lun); if (!d) { @@ -767,6 +793,8 @@ void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, } evt->lun[3] = dev->lun & 0xFF; } + trace_virtio_scsi_event(virtio_scsi_get_lun(evt->lun), event, reason); + virtio_scsi_complete_req(req); } |