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

John Ferlan posted 4 patches 7 years ago
[libvirt] [PATCH v2 1/4] util: Modify virStorageFileGetSCSIKey return
Posted by John Ferlan 7 years ago
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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/4] util: Modify virStorageFileGetSCSIKey return
Posted by Ján Tomko 7 years ago
On Fri, Jan 18, 2019 at 09:42:34AM -0500, John Ferlan wrote:
>Alter the "real" code to return -2 on virCommandRun failure.
>Alter the comments and function header to describe the function
>and it's returns.

*its

>
>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
>
>+

Unrelated whitespace change

> #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",

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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