diff mbox

scsi: Improve error messages more

Message ID 1398680130-12942-1-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini April 28, 2014, 10:15 a.m. UTC
Make the message the same for both scsi-block and scsi-generic,
including the strerror() output in both and making an explicit
reference to SG_IO.  Also s/can not/cannot/.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/scsi-disk.c    | 5 +++--
 hw/scsi/scsi-generic.c | 8 ++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Markus Armbruster April 28, 2014, 11:03 a.m. UTC | #1
Paolo Bonzini <pbonzini@redhat.com> writes:

> Make the message the same for both scsi-block and scsi-generic,
> including the strerror() output in both and making an explicit
> reference to SG_IO.  Also s/can not/cannot/.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/scsi/scsi-disk.c    | 5 +++--
>  hw/scsi/scsi-generic.c | 8 ++++++--
>  2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index d2e532e..342a78b 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -2463,9 +2463,10 @@ static int scsi_block_initfn(SCSIDevice *dev)
>      }
>  
>      /* check we are using a driver managing SG_IO (version 3 and after) */
> -    rc =  bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version);
> +    rc = bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version);
>      if (rc < 0) {
> -        error_report("scsi-block: can not get version number: %s",
> +        error_report("scsi-block: cannot get SG_IO version number: %s.  "
> +                     "Is this a SCSI device?",
>                       strerror(-rc));
>          return -1;
>      }

While you're improving: is the scsi-block: prefix still useful?  The
error message comes out like this for me:

    qemu: -device scsi-block,drive=foo: scsi-block: cannot get SG_IO version number: Operation not supported.  Is this a SCSI device?

[...]
diff mbox

Patch

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index d2e532e..342a78b 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2463,9 +2463,10 @@  static int scsi_block_initfn(SCSIDevice *dev)
     }
 
     /* check we are using a driver managing SG_IO (version 3 and after) */
-    rc =  bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version);
+    rc = bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version);
     if (rc < 0) {
-        error_report("scsi-block: can not get version number: %s",
+        error_report("scsi-block: cannot get SG_IO version number: %s.  "
+                     "Is this a SCSI device?",
                      strerror(-rc));
         return -1;
     }
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 8d92e0d..14a88e1 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -394,6 +394,7 @@  static void scsi_destroy(SCSIDevice *s)
 
 static int scsi_generic_initfn(SCSIDevice *s)
 {
+    int rc;
     int sg_version;
     struct sg_scsi_id scsiid;
 
@@ -412,8 +413,11 @@  static int scsi_generic_initfn(SCSIDevice *s)
     }
 
     /* check we are using a driver managing SG_IO (version 3 and after */
-    if (bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version) < 0) {
-        error_report("scsi generic interface not supported");
+    rc = bdrv_ioctl(s->conf.bs, SG_GET_VERSION_NUM, &sg_version);
+    if (rc < 0) {
+        error_report("scsi-generic: cannot get SG_IO version number: %s.  "
+                     "Is this a SCSI device?",
+                     strerror(-rc));
         return -1;
     }
     if (sg_version < 30000) {