|
Paolo Bonzini |
0fb2b2 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
Date: Tue, 22 Aug 2017 09:42:59 +0200
|
|
|
59eb7a |
Subject: [PATCH] scsi: introduce scsi_build_sense
|
|
Paolo Bonzini |
0fb2b2 |
MIME-Version: 1.0
|
|
Paolo Bonzini |
0fb2b2 |
Content-Type: text/plain; charset=UTF-8
|
|
Paolo Bonzini |
0fb2b2 |
Content-Transfer-Encoding: 8bit
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
Move more knowledge of sense data format out of hw/scsi/scsi-bus.c
|
|
Paolo Bonzini |
0fb2b2 |
for reusability.
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
|
Paolo Bonzini |
0fb2b2 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
---
|
|
Paolo Bonzini |
0fb2b2 |
hw/scsi/scsi-bus.c | 8 +-------
|
|
Paolo Bonzini |
0fb2b2 |
include/scsi/utils.h | 2 ++
|
|
Paolo Bonzini |
0fb2b2 |
scsi/utils.c | 11 +++++++++++
|
|
Paolo Bonzini |
0fb2b2 |
3 files changed, 14 insertions(+), 7 deletions(-)
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
|
|
Paolo Bonzini |
0fb2b2 |
index 42920d5422..652ab046ab 100644
|
|
Paolo Bonzini |
0fb2b2 |
--- a/hw/scsi/scsi-bus.c
|
|
Paolo Bonzini |
0fb2b2 |
+++ b/hw/scsi/scsi-bus.c
|
|
Paolo Bonzini |
0fb2b2 |
@@ -818,13 +818,7 @@ void scsi_req_build_sense(SCSIRequest *req, SCSISense sense)
|
|
Paolo Bonzini |
0fb2b2 |
{
|
|
Paolo Bonzini |
0fb2b2 |
trace_scsi_req_build_sense(req->dev->id, req->lun, req->tag,
|
|
Paolo Bonzini |
0fb2b2 |
sense.key, sense.asc, sense.ascq);
|
|
Paolo Bonzini |
0fb2b2 |
- memset(req->sense, 0, 18);
|
|
Paolo Bonzini |
0fb2b2 |
- req->sense[0] = 0x70;
|
|
Paolo Bonzini |
0fb2b2 |
- req->sense[2] = sense.key;
|
|
Paolo Bonzini |
0fb2b2 |
- req->sense[7] = 10;
|
|
Paolo Bonzini |
0fb2b2 |
- req->sense[12] = sense.asc;
|
|
Paolo Bonzini |
0fb2b2 |
- req->sense[13] = sense.ascq;
|
|
Paolo Bonzini |
0fb2b2 |
- req->sense_len = 18;
|
|
Paolo Bonzini |
0fb2b2 |
+ req->sense_len = scsi_build_sense(req->sense, sense);
|
|
Paolo Bonzini |
0fb2b2 |
}
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
static void scsi_req_enqueue_internal(SCSIRequest *req)
|
|
Paolo Bonzini |
0fb2b2 |
diff --git a/include/scsi/utils.h b/include/scsi/utils.h
|
|
Paolo Bonzini |
0fb2b2 |
index 90bf4dce6e..b49392d841 100644
|
|
Paolo Bonzini |
0fb2b2 |
--- a/include/scsi/utils.h
|
|
Paolo Bonzini |
0fb2b2 |
+++ b/include/scsi/utils.h
|
|
Paolo Bonzini |
0fb2b2 |
@@ -30,6 +30,8 @@ typedef struct SCSISense {
|
|
Paolo Bonzini |
0fb2b2 |
uint8_t ascq;
|
|
Paolo Bonzini |
0fb2b2 |
} SCSISense;
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
+int scsi_build_sense(uint8_t *buf, SCSISense sense);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
/*
|
|
Paolo Bonzini |
0fb2b2 |
* Predefined sense codes
|
|
Paolo Bonzini |
0fb2b2 |
*/
|
|
Paolo Bonzini |
0fb2b2 |
diff --git a/scsi/utils.c b/scsi/utils.c
|
|
Paolo Bonzini |
0fb2b2 |
index 2327e06da0..89d9167d9d 100644
|
|
Paolo Bonzini |
0fb2b2 |
--- a/scsi/utils.c
|
|
Paolo Bonzini |
0fb2b2 |
+++ b/scsi/utils.c
|
|
Paolo Bonzini |
0fb2b2 |
@@ -96,6 +96,17 @@ int scsi_cdb_length(uint8_t *buf)
|
|
Paolo Bonzini |
0fb2b2 |
return cdb_len;
|
|
Paolo Bonzini |
0fb2b2 |
}
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
+int scsi_build_sense(uint8_t *buf, SCSISense sense)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ memset(buf, 0, 18);
|
|
Paolo Bonzini |
0fb2b2 |
+ buf[0] = 0x70;
|
|
Paolo Bonzini |
0fb2b2 |
+ buf[2] = sense.key;
|
|
Paolo Bonzini |
0fb2b2 |
+ buf[7] = 10;
|
|
Paolo Bonzini |
0fb2b2 |
+ buf[12] = sense.asc;
|
|
Paolo Bonzini |
0fb2b2 |
+ buf[13] = sense.ascq;
|
|
Paolo Bonzini |
0fb2b2 |
+ return 18;
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
/*
|
|
Paolo Bonzini |
0fb2b2 |
* Predefined sense codes
|
|
Paolo Bonzini |
0fb2b2 |
*/
|