From a3760467c6b0ff5d1ff952fdc8cec69c65e19499 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 22 Aug 2017 09:42:59 +0200 Subject: scsi: introduce scsi_build_sense MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move more knowledge of sense data format out of hw/scsi/scsi-bus.c for reusability. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- scsi/utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'scsi') diff --git a/scsi/utils.c b/scsi/utils.c index 2327e06da0..89d9167d9d 100644 --- a/scsi/utils.c +++ b/scsi/utils.c @@ -96,6 +96,17 @@ int scsi_cdb_length(uint8_t *buf) return cdb_len; } +int scsi_build_sense(uint8_t *buf, SCSISense sense) +{ + memset(buf, 0, 18); + buf[0] = 0x70; + buf[2] = sense.key; + buf[7] = 10; + buf[12] = sense.asc; + buf[13] = sense.ascq; + return 18; +} + /* * Predefined sense codes */ -- cgit v1.2.3