Skip to contentSkip to conversation

Add scsi-bus/scsi-disk trace calls.

PATCH New Don Koch 1 participant 3 messages Jan 16, 2015

lore
Share & tools
lore

Don Koch

author
#0 lore raw

cover Add scsi-bus/scsi-disk trace calls.

Adding some trace calls for scsi debug.

Don Koch (2):
Add trace calls to scsi-disk.c.
Add trace calls to scsi-bus.c.

 hw/scsi/scsi-bus.c  | 16 ++++++++++++++++
 hw/scsi/scsi-disk.c |  4 ++++
 trace-events        | 15 +++++++++++++++
 3 files changed, 35 insertions(+)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/2 Add trace calls to scsi-disk.c.

---
 hw/scsi/scsi-disk.c | 4 ++++
 trace-events        | 5 +++++
 2 files changed, 9 insertions(+)
hw/scsi/scsi-disk.c +4 -0
index f65618d..98bbead 100644
@@ -37,6 +37,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
 #include "sysemu/blockdev.h"
 #include "hw/block/block.h"
 #include "sysemu/dma.h"
+#include "trace.h"
 
 #ifdef __linux
 #include <scsi/sg.h>
@@ -533,6 +534,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
     int buflen = 0;
     int start;
 
+    trace_scsi_disk_inquiry(req->cmd.buf[1], req->cmd.buf[2]);
     if (req->cmd.buf[1] & 0x1) {
         /* Vital product data */
         uint8_t page_code = req->cmd.buf[2];
@@ -717,6 +719,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
 
     /* Standard INQUIRY data */
     if (req->cmd.buf[2] != 0) {
+        trace_scsi_disk_inquiry_err_standard(req->cmd.buf[2]);
         return -1;
     }
 
@@ -1843,6 +1846,7 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)
     case INQUIRY:
         buflen = scsi_disk_emulate_inquiry(req, outbuf);
         if (buflen < 0) {
+            trace_scsi_disk_inquiry_err_generic(buflen);
             goto illegal_request;
         }
         break;
trace-events +5 -0
index 6a60f19..43fb0db 100644
@@ -588,6 +588,11 @@ scsi_inquiry(int target, int lun, int tag, int cdb1, int cdb2) "target %d lun %d
 scsi_test_unit_ready(int target, int lun, int tag) "target %d lun %d tag %d"
 scsi_request_sense(int target, int lun, int tag) "target %d lun %d tag %d"
 
+# hw/scsi/scsi-disk.c
+scsi_disk_inquiry_err_standard(int buf2) "buf[2]=%u"
+scsi_disk_inquiry_err_generic(int buflen) "buflen=%d"
+scsi_disk_inquiry(int buf1, int buf2) "buf[1]=0x%x buf[2]=0x%x"
+
 # vl.c
 vm_state_notify(int running, int reason) "running %d reason %d"
 load_file(const char *name, const char *path) "name %s location %s"
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 2/2 Add trace calls to scsi-bus.c.

In reply to Don Koch
---
 hw/scsi/scsi-bus.c | 16 ++++++++++++++++
 trace-events       | 10 ++++++++++
 2 files changed, 26 insertions(+)
hw/scsi/scsi-bus.c +16 -0
index 24f7b74..5604b87 100644
@@ -278,6 +278,7 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp)
 
 static int32_t scsi_invalid_field(SCSIRequest *req, uint8_t *buf)
 {
+    trace_scsi_err_invalid_field(req);
     scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));
     scsi_req_complete(req, CHECK_CONDITION);
     return 0;
@@ -292,6 +293,7 @@ static const struct SCSIReqOps reqops_invalid_field = {
 
 static int32_t scsi_invalid_command(SCSIRequest *req, uint8_t *buf)
 {
+    trace_scsi_err_invalid_command(req);
     scsi_req_build_sense(req, SENSE_CODE(INVALID_OPCODE));
     scsi_req_complete(req, CHECK_CONDITION);
     return 0;
@@ -306,6 +308,10 @@ static const struct SCSIReqOps reqops_invalid_opcode = {
 
 static int32_t scsi_unit_attention(SCSIRequest *req, uint8_t *buf)
 {
+    trace_scsi_err_unit_attention(req,
+        (req->dev && req->dev->unit_attention.key == UNIT_ATTENTION),
+        (req->bus && req->bus->unit_attention.key == UNIT_ATTENTION));
+
     if (req->dev->unit_attention.key == UNIT_ATTENTION) {
         scsi_req_build_sense(req, req->dev->unit_attention);
     } else if (req->bus->unit_attention.key == UNIT_ATTENTION) {
@@ -391,6 +397,7 @@ static bool scsi_target_emulate_report_luns(SCSITargetReq *r)
     }
     assert(i == n + 8);
     r->len = len;
+    trace_scsi_report_luns_extra(channel, id, i, n, found_lun0, len);
     return true;
 }
 
@@ -402,6 +409,7 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r)
 
     if (r->req.cmd.buf[1] & 0x2) {
         /* Command support data - optional, not implemented */
+        trace_scsi_inquiry_err_support(r->req.lun, r->req.dev->lun);
         return false;
     }
 
@@ -421,6 +429,8 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r)
             break;
         }
         default:
+            trace_scsi_inquiry_err_page_code(r->req.lun, r->req.dev->lun,
+                                             page_code);
             return false;
         }
         /* done with EVPD */
@@ -431,6 +441,8 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r)
 
     /* Standard INQUIRY data */
     if (r->req.cmd.buf[2] != 0) {
+        trace_scsi_inquiry_err_standard(r->req.lun, r->req.dev->lun,
+                                        r->req.cmd.buf[2]);
         return false;
     }
 
@@ -481,10 +493,12 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
     case TEST_UNIT_READY:
         break;
     default:
+        trace_scsi_err_lun_not_supported(req);
         scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
         scsi_req_complete(req, CHECK_CONDITION);
         return 0;
     illegal_request:
+        trace_scsi_err_illegal_field(req);
         scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));
         scsi_req_complete(req, CHECK_CONDITION);
         return 0;
@@ -691,6 +705,8 @@ static void scsi_clear_unit_attention(SCSIRequest *req)
         return;
     }
 
+    trace_scsi_clear_unit_attention(req, (req->dev &&
+                                          ua == &req->dev->unit_attention));
     *ua = SENSE_CODE(NO_SENSE);
 }
 
trace-events +10 -0
index 43fb0db..6c8f26a 100644
@@ -587,6 +587,16 @@ scsi_report_luns(int target, int lun, int tag) "target %d lun %d tag %d"
 scsi_inquiry(int target, int lun, int tag, int cdb1, int cdb2) "target %d lun %d tag %d page %#02x/%#02x"
 scsi_test_unit_ready(int target, int lun, int tag) "target %d lun %d tag %d"
 scsi_request_sense(int target, int lun, int tag) "target %d lun %d tag %d"
+scsi_report_luns_extra(int channel, int id, int i, int n, int found_lun0, int len) "channel=%d id=%d i=%d n=%d found_lun0=%d len=%d"
+scsi_err_invalid_field(void *req) "req=%p"
+scsi_err_invalid_command(void *req) "req=%p"
+scsi_err_unit_attention(void *req, int dev_attention, int bus_attention) "req=%p dev_attention=%d bus_attention=%d"
+scsi_err_lun_not_supported(void *req) "req=%p"
+scsi_err_illegal_field(void *req) "req=%p"
+scsi_clear_unit_attention(void *req, int isdev) "req=%p isdev=%d"
+scsi_inquiry_err_support(int reqlun, int devlun) "req.lun=%u dev.lun=%u"
+scsi_inquiry_err_page_code(int reqlun, int devlun, int page_code) "req.lun=%u dev.lun=%u page_code=0x%x"
+scsi_inquiry_err_standard(int reqlun, int devlun, int cmd2) "req.lun=%u dev.lun=%u buf[2]=%u"
 
 # hw/scsi/scsi-disk.c
 scsi_disk_inquiry_err_standard(int buf2) "buf[2]=%u"
Signature · 1 line
1.8.3.1