9ae3a8
From 3560dd9e730c41824fcaa9aeb9b4ee503aa98de1 Mon Sep 17 00:00:00 2001
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Fri, 6 Jun 2014 04:11:39 +0200
9ae3a8
Subject: [PATCH 10/13] scsi: Improve error messages more
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1402027899-1917-3-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 59164
9ae3a8
O-Subject: [RHEL-7 qemu-kvm PATCH 2/2] scsi: Improve error messages more
9ae3a8
Bugzilla: 1021788
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Amos Kong <akong@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
From: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
Remove the "scsi-block:" prefix for error messages as suggested
9ae3a8
by Markus.
9ae3a8
9ae3a8
Improve the previous patch by making the message the same for both
9ae3a8
scsi-block and scsi-generic, including the strerror() output in both
9ae3a8
and making an explicit reference to SG_IO.  Also s/can not/cannot/.
9ae3a8
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
(cherry picked from commit 6ee143a0a4f8b5c437ac327e3d694a6a0e5380ad)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
---
9ae3a8
 hw/scsi/scsi-disk.c    | 11 ++++++-----
9ae3a8
 hw/scsi/scsi-generic.c |  8 ++++++--
9ae3a8
 2 files changed, 12 insertions(+), 7 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/scsi/scsi-disk.c    |   11 ++++++-----
9ae3a8
 hw/scsi/scsi-generic.c |    8 ++++++--
9ae3a8
 2 files changed, 12 insertions(+), 7 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
9ae3a8
index 5a6384e..1d41db2 100644
9ae3a8
--- a/hw/scsi/scsi-disk.c
9ae3a8
+++ b/hw/scsi/scsi-disk.c
9ae3a8
@@ -2434,26 +2434,27 @@ static int scsi_block_initfn(SCSIDevice *dev)
9ae3a8
     int rc;
9ae3a8
 
9ae3a8
     if (!s->qdev.conf.bs) {
9ae3a8
-        error_report("scsi-block: drive property not set");
9ae3a8
+        error_report("drive property not set");
9ae3a8
         return -1;
9ae3a8
     }
9ae3a8
 
9ae3a8
     /* check we are using a driver managing SG_IO (version 3 and after) */
9ae3a8
-    rc =  bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version);
9ae3a8
+    rc = bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version);
9ae3a8
     if (rc < 0) {
9ae3a8
-        error_report("scsi-block: can not get version number: %s",
9ae3a8
+        error_report("cannot get SG_IO version number: %s.  "
9ae3a8
+                     "Is this a SCSI device?",
9ae3a8
                      strerror(-rc));
9ae3a8
         return -1;
9ae3a8
     }
9ae3a8
     if (sg_version < 30000) {
9ae3a8
-        error_report("scsi-block: scsi generic interface too old");
9ae3a8
+        error_report("scsi generic interface too old");
9ae3a8
         return -1;
9ae3a8
     }
9ae3a8
 
9ae3a8
     /* get device type from INQUIRY data */
9ae3a8
     rc = get_device_type(s);
9ae3a8
     if (rc < 0) {
9ae3a8
-        error_report("scsi-block: INQUIRY failed");
9ae3a8
+        error_report("INQUIRY failed");
9ae3a8
         return -1;
9ae3a8
     }
9ae3a8
 
9ae3a8
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
9ae3a8
index 8d92e0d..3733d2c 100644
9ae3a8
--- a/hw/scsi/scsi-generic.c
9ae3a8
+++ b/hw/scsi/scsi-generic.c
9ae3a8
@@ -394,6 +394,7 @@ static void scsi_destroy(SCSIDevice *s)
9ae3a8
 
9ae3a8
 static int scsi_generic_initfn(SCSIDevice *s)
9ae3a8
 {
9ae3a8
+    int rc;
9ae3a8
     int sg_version;
9ae3a8
     struct sg_scsi_id scsiid;
9ae3a8
 
9ae3a8
@@ -412,8 +413,11 @@ static int scsi_generic_initfn(SCSIDevice *s)
9ae3a8
     }
9ae3a8
 
9ae3a8
     /* check we are using a driver managing SG_IO (version 3 and after */
9ae3a8
-    if (bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version) < 0) {
9ae3a8
-        error_report("scsi generic interface not supported");
9ae3a8
+    rc = bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version);
9ae3a8
+    if (rc < 0) {
9ae3a8
+        error_report("cannot get SG_IO version number: %s.  "
9ae3a8
+                     "Is this a SCSI device?",
9ae3a8
+                     strerror(-rc));
9ae3a8
         return -1;
9ae3a8
     }
9ae3a8
     if (sg_version < 30000) {
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8