[libvirt] [PATCH 3/3] util: Report error if vhost-scsi device file cannot be found

John Ferlan posted 3 patches 7 years, 5 months ago
[libvirt] [PATCH 3/3] util: Report error if vhost-scsi device file cannot be found
Posted by John Ferlan 7 years, 5 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=1523564

If the vhost-scsi device file cannot be found, the generic error

    "error: An error occurred, but the cause is unknown"

is returned.  Let's add a real error message to make it clear
why the failure occurred.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/util/virscsivhost.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
index d6fbf5ed5..5f176e177 100644
--- a/src/util/virscsivhost.c
+++ b/src/util/virscsivhost.c
@@ -86,8 +86,12 @@ VIR_ONCE_GLOBAL_INIT(virSCSIVHost)
 int
 virSCSIVHostOpenVhostSCSI(int *vhostfd)
 {
-    if (!virFileExists(VHOST_SCSI_DEVICE))
+    if (!virFileExists(VHOST_SCSI_DEVICE)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("vhost-scsi device file '%s' cannot be found"),
+                       VHOST_SCSI_DEVICE);
         return -1;
+    }
 
     *vhostfd = open(VHOST_SCSI_DEVICE, O_RDWR);
 
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] util: Report error if vhost-scsi device file cannot be found
Posted by Eric Farman 7 years, 5 months ago

On 12/12/2017 09:22 AM, John Ferlan wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1523564
> 
> If the vhost-scsi device file cannot be found, the generic error
> 
>      "error: An error occurred, but the cause is unknown"
> 
> is returned.  Let's add a real error message to make it clear
> why the failure occurred.
> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>

Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>

> ---
>   src/util/virscsivhost.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c
> index d6fbf5ed5..5f176e177 100644
> --- a/src/util/virscsivhost.c
> +++ b/src/util/virscsivhost.c
> @@ -86,8 +86,12 @@ VIR_ONCE_GLOBAL_INIT(virSCSIVHost)
>   int
>   virSCSIVHostOpenVhostSCSI(int *vhostfd)
>   {
> -    if (!virFileExists(VHOST_SCSI_DEVICE))
> +    if (!virFileExists(VHOST_SCSI_DEVICE)) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                       _("vhost-scsi device file '%s' cannot be found"),
> +                       VHOST_SCSI_DEVICE);
>           return -1;
> +    }
> 
>       *vhostfd = open(VHOST_SCSI_DEVICE, O_RDWR);
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list