diff mbox

scsi-disk: Improve error messager if can't get version number

Message ID 1397614156-18920-1-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng April 16, 2014, 2:09 a.m. UTC
More often it is that bdrv_ioctl fails due to not supported by driver or
whatever reason, in this case we should be specific, because "interface
too old" is very confusing.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 hw/scsi/scsi-disk.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Markus Armbruster April 16, 2014, 7:03 a.m. UTC | #1
Fam Zheng <famz@redhat.com> writes:

> More often it is that bdrv_ioctl fails due to not supported by driver or
> whatever reason, in this case we should be specific, because "interface
> too old" is very confusing.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  hw/scsi/scsi-disk.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index 48a28ae..d2e532e 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -2463,8 +2463,13 @@ static int scsi_block_initfn(SCSIDevice *dev)
>      }
>  
>      /* check we are using a driver managing SG_IO (version 3 and after) */
> -    if (bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version) < 0 ||
> -        sg_version < 30000) {
> +    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",
> +                     strerror(-rc));
> +        return -1;
> +    }
> +    if (sg_version < 30000) {
>          error_report("scsi-block: scsi generic interface too old");
>          return -1;
>      }

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Paolo Bonzini April 28, 2014, 10:09 a.m. UTC | #2
Il 16/04/2014 04:09, Fam Zheng ha scritto:
> More often it is that bdrv_ioctl fails due to not supported by driver or
> whatever reason, in this case we should be specific, because "interface
> too old" is very confusing.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  hw/scsi/scsi-disk.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index 48a28ae..d2e532e 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -2463,8 +2463,13 @@ static int scsi_block_initfn(SCSIDevice *dev)
>      }
>
>      /* check we are using a driver managing SG_IO (version 3 and after) */
> -    if (bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version) < 0 ||
> -        sg_version < 30000) {
> +    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",
> +                     strerror(-rc));
> +        return -1;
> +    }
> +    if (sg_version < 30000) {
>          error_report("scsi-block: scsi generic interface too old");
>          return -1;
>      }
>

Applied to scsi-next, thanks.

Paolo
diff mbox

Patch

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 48a28ae..d2e532e 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2463,8 +2463,13 @@  static int scsi_block_initfn(SCSIDevice *dev)
     }
 
     /* check we are using a driver managing SG_IO (version 3 and after) */
-    if (bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version) < 0 ||
-        sg_version < 30000) {
+    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",
+                     strerror(-rc));
+        return -1;
+    }
+    if (sg_version < 30000) {
         error_report("scsi-block: scsi generic interface too old");
         return -1;
     }