[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 1/4] util: Modify virStorageFileGetSCSIKey return



Alter the "real" code to return -2 on virCommandRun failure.
Alter the comments and function header to describe the function
and it's returns.

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/util/virstoragefile.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index bd4b0274df..2511511d14 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1425,9 +1425,24 @@ int virStorageFileGetLVMKey(const char *path,
 }
 #endif
 
+
 #ifdef WITH_UDEV
-int virStorageFileGetSCSIKey(const char *path,
-                             char **key)
+/* virStorageFileGetSCSIKey
+ * @path: Path to the SCSI device
+ * @key: Unique key to be returned
+ *
+ * Using a udev specific function, query the @path to get and return a
+ * unique @key for the caller to use.
+ *
+ * Returns:
+ *     0 On success, with the @key filled in or @key=NULL if the
+ *       returned string was empty.
+ *    -1 When WITH_UDEV is undefined and a system error is reported
+ *    -2 When WITH_UDEV is defined, but calling virCommandRun fails
+ */
+int
+virStorageFileGetSCSIKey(const char *path,
+                         char **key)
 {
     int status;
     virCommandPtr cmd = virCommandNewArgList("/lib/udev/scsi_id",
@@ -1436,7 +1451,7 @@ int virStorageFileGetSCSIKey(const char *path,
                                              "--device", path,
                                              NULL
                                              );
-    int ret = -1;
+    int ret = -2;
 
     *key = NULL;
 
-- 
2.20.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]