Blame SOURCES/kvm-scsi-Improve-scsi_sense_to_errno.patch

4a2fec
From bc3855000036c3abe2a440d3cb65a9fbd90745fb Mon Sep 17 00:00:00 2001
4a2fec
From: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
Date: Sat, 2 Dec 2017 12:19:41 +0100
4a2fec
Subject: [PATCH 15/36] scsi: Improve scsi_sense_to_errno
4a2fec
4a2fec
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
Message-id: <20171202121953.13317-6-pbonzini@redhat.com>
4a2fec
Patchwork-id: 78077
4a2fec
O-Subject: [RHEL7.4 qemu-kvm-rhev PATCH 05/17] scsi: Improve scsi_sense_to_errno
4a2fec
Bugzilla: 1464908
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
4a2fec
From: Fam Zheng <famz@redhat.com>
4a2fec
4a2fec
Tweak the errno mapping to return more accurate/appropriate values.
4a2fec
4a2fec
Signed-off-by: Fam Zheng <famz@redhat.com>
4a2fec
Message-Id: <20170821141008.19383-3-famz@redhat.com>
4a2fec
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
(cherry picked from commit 5efa3c04483d408a03ff5f018842501a2048a51b)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 util/scsi.c | 16 ++++++++++++----
4a2fec
 1 file changed, 12 insertions(+), 4 deletions(-)
4a2fec
4a2fec
diff --git a/util/scsi.c b/util/scsi.c
4a2fec
index a671079..472eb5b 100644
4a2fec
--- a/util/scsi.c
4a2fec
+++ b/util/scsi.c
4a2fec
@@ -18,13 +18,16 @@
4a2fec
 int scsi_sense_to_errno(int key, int asc, int ascq)
4a2fec
 {
4a2fec
     switch (key) {
4a2fec
-    case 0x02: /* NOT READY */
4a2fec
-        return EBUSY;
4a2fec
-    case 0x07: /* DATA PROTECTION */
4a2fec
-        return EACCES;
4a2fec
+    case 0x00: /* NO SENSE */
4a2fec
+    case 0x01: /* RECOVERED ERROR */
4a2fec
+    case 0x06: /* UNIT ATTENTION */
4a2fec
+        /* These sense keys are not errors */
4a2fec
+        return 0;
4a2fec
     case 0x0b: /* COMMAND ABORTED */
4a2fec
         return ECANCELED;
4a2fec
+    case 0x02: /* NOT READY */
4a2fec
     case 0x05: /* ILLEGAL REQUEST */
4a2fec
+    case 0x07: /* DATA PROTECTION */
4a2fec
         /* Parse ASCQ */
4a2fec
         break;
4a2fec
     default:
4a2fec
@@ -37,6 +40,7 @@ int scsi_sense_to_errno(int key, int asc, int ascq)
4a2fec
     case 0x2600: /* INVALID FIELD IN PARAMETER LIST */
4a2fec
         return EINVAL;
4a2fec
     case 0x2100: /* LBA OUT OF RANGE */
4a2fec
+    case 0x2707: /* SPACE ALLOC FAILED */
4a2fec
         return ENOSPC;
4a2fec
     case 0x2500: /* LOGICAL UNIT NOT SUPPORTED */
4a2fec
         return ENOTSUP;
4a2fec
@@ -46,6 +50,10 @@ int scsi_sense_to_errno(int key, int asc, int ascq)
4a2fec
         return ENOMEDIUM;
4a2fec
     case 0x2700: /* WRITE PROTECTED */
4a2fec
         return EACCES;
4a2fec
+    case 0x0401: /* NOT READY, IN PROGRESS OF BECOMING READY */
4a2fec
+        return EAGAIN;
4a2fec
+    case 0x0402: /* NOT READY, INITIALIZING COMMAND REQUIRED */
4a2fec
+        return ENOTCONN;
4a2fec
     default:
4a2fec
         return EIO;
4a2fec
     }
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec