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

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

 



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@xxxxxxxxxx>
---
 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

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux