render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From abe590777bed20bca15d9cb07891cf863859a3c8 Mon Sep 17 00:00:00 2001
Message-Id: <abe590777bed20bca15d9cb07891cf863859a3c8.1385135432.git.jdenemar@redhat.com>
From: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Date: Fri, 15 Nov 2013 16:05:45 +0100
Subject: [PATCH] virscsi: hostdev SCSI AdapterId retrieval fix

https://bugzilla.redhat.com/show_bug.cgi?id=1031079

Fixed the retrieval of the AdapterId from the AdapterName of the
hostdev source so it does return an error instead of leaving the
adapter_id uninitialized.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
(cherry picked from commit 11d9dd7ba099c59bc3cb785ab574a84bdb255168)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/util/virscsi.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 32e438b..3950c62 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -88,16 +88,13 @@ static int
 virSCSIDeviceGetAdapterId(const char *adapter,
                           unsigned int *adapter_id)
 {
-    if (STRPREFIX(adapter, "scsi_host")) {
-        if (virStrToLong_ui(adapter + strlen("scsi_host"),
-                            NULL, 0, adapter_id) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Cannot parse adapter '%s'"), adapter);
-            return -1;
-        }
-    }
-
-    return 0;
+    if (STRPREFIX(adapter, "scsi_host") &&
+        virStrToLong_ui(adapter + strlen("scsi_host"),
+                        NULL, 0, adapter_id) == 0)
+        return 0;
+    virReportError(VIR_ERR_INTERNAL_ERROR,
+                   _("Cannot parse adapter '%s'"), adapter);
+    return -1;
 }
 
 char *
-- 
1.8.4.4