From f876fe80b7827fc0197a1ca3e7a88f4524f685d2 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Wed, 22 Feb 2012 14:11:35 +0100
Subject: [PATCH 019/109] scsi: add special traces for common commands

RH-Author: Paolo Bonzini <pbonzini@redhat.com>
Message-id: <1329919979-20948-19-git-send-email-pbonzini@redhat.com>
Patchwork-id: 37494
O-Subject: [RHEL 6.3 qemu-kvm PATCH v2 018/102] scsi: add special traces for common commands
Bugzilla: 782029
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>

Can be useful when debugging the device scan phase.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from 98254542f9aca81f136a96c82a9ae08e781a9baf)
---
 hw/scsi-bus.c |   17 +++++++++++++++++
 trace-events  |    4 ++++
 2 files changed, 21 insertions(+), 0 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/scsi-bus.c |   17 +++++++++++++++++
 trace-events  |    4 ++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 7ac8c1c..8b803a2 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -397,6 +397,23 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
     }
 
     req->cmd = cmd;
+    switch (buf[0]) {
+    case INQUIRY:
+        trace_scsi_inquiry(d->id, lun, tag, cmd.buf[1], cmd.buf[2]);
+        break;
+    case TEST_UNIT_READY:
+        trace_scsi_test_unit_ready(d->id, lun, tag);
+        break;
+    case REPORT_LUNS:
+        trace_scsi_report_luns(d->id, lun, tag);
+        break;
+    case REQUEST_SENSE:
+        trace_scsi_request_sense(d->id, lun, tag);
+        break;
+    default:
+        break;
+    }
+
     return req;
 }
 
diff --git a/trace-events b/trace-events
index c523039..1959d48 100644
--- a/trace-events
+++ b/trace-events
@@ -135,6 +135,10 @@ disable scsi_req_parsed(int target, int lun, int tag, int cmd, int mode, int xfe
 disable scsi_req_parsed_lba(int target, int lun, int tag, int cmd, uint64_t lba) "target %d lun %d tag %d command %d lba %"PRIu64""
 disable scsi_req_parse_bad(int target, int lun, int tag, int cmd) "target %d lun %d tag %d command %d"
 disable scsi_req_build_sense(int target, int lun, int tag, int key, int asc, int ascq) "target %d lun %d tag %d key %#02x asc %#02x ascq %#02x"
+disable scsi_report_luns(int target, int lun, int tag) "target %d lun %d tag %d"
+disable scsi_inquiry(int target, int lun, int tag, int cdb1, int cdb2) "target %d lun %d tag %d page %#02x/%#02x"
+disable scsi_test_unit_ready(int target, int lun, int tag) "target %d lun %d tag %d"
+disable scsi_request_sense(int target, int lun, int tag) "target %d lun %d tag %d"
 
 # vl.c
 disable vm_state_notify(int running, int reason) "running %d reason %d"
-- 
1.7.7.6

