|
|
9bac43 |
From 671df2c5697b3509eb8a9e16e3b2ccc51f9719d7 Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
Date: Sat, 2 Dec 2017 12:19:45 +0100
|
|
|
9bac43 |
Subject: [PATCH 19/36] scsi: introduce scsi_build_sense
|
|
|
9bac43 |
MIME-Version: 1.0
|
|
|
9bac43 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9bac43 |
Content-Transfer-Encoding: 8bit
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
Message-id: <20171202121953.13317-10-pbonzini@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 78078
|
|
|
9bac43 |
O-Subject: [RHEL7.4 qemu-kvm-rhev PATCH 09/17] scsi: introduce scsi_build_sense
|
|
|
9bac43 |
Bugzilla: 1464908
|
|
|
9bac43 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
Move more knowledge of sense data format out of hw/scsi/scsi-bus.c
|
|
|
9bac43 |
for reusability.
|
|
|
9bac43 |
|
|
|
9bac43 |
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
|
|
9bac43 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit a3760467c6b0ff5d1ff952fdc8cec69c65e19499)
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
hw/scsi/scsi-bus.c | 8 +-------
|
|
|
9bac43 |
include/scsi/utils.h | 2 ++
|
|
|
9bac43 |
scsi/utils.c | 11 +++++++++++
|
|
|
9bac43 |
3 files changed, 14 insertions(+), 7 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
|
|
|
9bac43 |
index 635cdf6..f77e576 100644
|
|
|
9bac43 |
--- a/hw/scsi/scsi-bus.c
|
|
|
9bac43 |
+++ b/hw/scsi/scsi-bus.c
|
|
|
9bac43 |
@@ -826,13 +826,7 @@ void scsi_req_build_sense(SCSIRequest *req, SCSISense sense)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
trace_scsi_req_build_sense(req->dev->id, req->lun, req->tag,
|
|
|
9bac43 |
sense.key, sense.asc, sense.ascq);
|
|
|
9bac43 |
- memset(req->sense, 0, 18);
|
|
|
9bac43 |
- req->sense[0] = 0x70;
|
|
|
9bac43 |
- req->sense[2] = sense.key;
|
|
|
9bac43 |
- req->sense[7] = 10;
|
|
|
9bac43 |
- req->sense[12] = sense.asc;
|
|
|
9bac43 |
- req->sense[13] = sense.ascq;
|
|
|
9bac43 |
- req->sense_len = 18;
|
|
|
9bac43 |
+ req->sense_len = scsi_build_sense(req->sense, sense);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
static void scsi_req_enqueue_internal(SCSIRequest *req)
|
|
|
9bac43 |
diff --git a/include/scsi/utils.h b/include/scsi/utils.h
|
|
|
9bac43 |
index 90bf4dc..b49392d 100644
|
|
|
9bac43 |
--- a/include/scsi/utils.h
|
|
|
9bac43 |
+++ b/include/scsi/utils.h
|
|
|
9bac43 |
@@ -30,6 +30,8 @@ typedef struct SCSISense {
|
|
|
9bac43 |
uint8_t ascq;
|
|
|
9bac43 |
} SCSISense;
|
|
|
9bac43 |
|
|
|
9bac43 |
+int scsi_build_sense(uint8_t *buf, SCSISense sense);
|
|
|
9bac43 |
+
|
|
|
9bac43 |
/*
|
|
|
9bac43 |
* Predefined sense codes
|
|
|
9bac43 |
*/
|
|
|
9bac43 |
diff --git a/scsi/utils.c b/scsi/utils.c
|
|
|
9bac43 |
index 2327e06..89d9167 100644
|
|
|
9bac43 |
--- a/scsi/utils.c
|
|
|
9bac43 |
+++ b/scsi/utils.c
|
|
|
9bac43 |
@@ -96,6 +96,17 @@ int scsi_cdb_length(uint8_t *buf)
|
|
|
9bac43 |
return cdb_len;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
+int scsi_build_sense(uint8_t *buf, SCSISense sense)
|
|
|
9bac43 |
+{
|
|
|
9bac43 |
+ memset(buf, 0, 18);
|
|
|
9bac43 |
+ buf[0] = 0x70;
|
|
|
9bac43 |
+ buf[2] = sense.key;
|
|
|
9bac43 |
+ buf[7] = 10;
|
|
|
9bac43 |
+ buf[12] = sense.asc;
|
|
|
9bac43 |
+ buf[13] = sense.ascq;
|
|
|
9bac43 |
+ return 18;
|
|
|
9bac43 |
+}
|
|
|
9bac43 |
+
|
|
|
9bac43 |
/*
|
|
|
9bac43 |
* Predefined sense codes
|
|
|
9bac43 |
*/
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|