bcddb9
From 8c7d0ccfbf1213a2986e8290b90f1b860fd5c3ce Mon Sep 17 00:00:00 2001
bcddb9
Message-Id: <8c7d0ccfbf1213a2986e8290b90f1b860fd5c3ce@dist-git>
bcddb9
From: John Ferlan <jferlan@redhat.com>
bcddb9
Date: Tue, 12 Mar 2019 13:55:56 -0400
bcddb9
Subject: [PATCH] util: Modify virStorageFileGetSCSIKey return
bcddb9
MIME-Version: 1.0
bcddb9
Content-Type: text/plain; charset=UTF-8
bcddb9
Content-Transfer-Encoding: 8bit
bcddb9
bcddb9
https://bugzilla.redhat.com/show_bug.cgi?id=1687715 (7.6.z)
bcddb9
https://bugzilla.redhat.com/show_bug.cgi?id=1657468 (7.7.0)
bcddb9
bcddb9
Alter the "real" code to return -2 on virCommandRun failure.
bcddb9
Alter the comments and function header to describe the function
bcddb9
and its returns.
bcddb9
bcddb9
Signed-off-by: John Ferlan <jferlan@redhat.com>
bcddb9
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
bcddb9
Reviewed-by: Ján Tomko <jtomko@redhat.com>
bcddb9
(cherry picked from commit 9b86bbccb371026d0ce7ab9a2ce685b1fae8a717)
bcddb9
bcddb9
Managed conflict from commit 34e9c29357ef5c293c8f998ef6911756cbb8b405
bcddb9
which changed the indention for the virCommandPtr cmd to keep spacing
bcddb9
defined in the next-7.6 tree.
bcddb9
bcddb9
Signed-off-by: John Ferlan <jferlan@redhat.com>
bcddb9
Message-Id: <20190312175559.13583-2-jferlan@redhat.com>
bcddb9
Reviewed-by: Ján Tomko <jtomko@redhat.com>
bcddb9
---
bcddb9
 src/util/virstoragefile.c | 20 +++++++++++++++++---
bcddb9
 1 file changed, 17 insertions(+), 3 deletions(-)
bcddb9
bcddb9
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
bcddb9
index 0b15219c3e..ed7266619d 100644
bcddb9
--- a/src/util/virstoragefile.c
bcddb9
+++ b/src/util/virstoragefile.c
bcddb9
@@ -1435,8 +1435,22 @@ int virStorageFileGetLVMKey(const char *path,
bcddb9
 #endif
bcddb9
 
bcddb9
 #ifdef WITH_UDEV
bcddb9
-int virStorageFileGetSCSIKey(const char *path,
bcddb9
-                             char **key)
bcddb9
+/* virStorageFileGetSCSIKey
bcddb9
+ * @path: Path to the SCSI device
bcddb9
+ * @key: Unique key to be returned
bcddb9
+ *
bcddb9
+ * Using a udev specific function, query the @path to get and return a
bcddb9
+ * unique @key for the caller to use.
bcddb9
+ *
bcddb9
+ * Returns:
bcddb9
+ *     0 On success, with the @key filled in or @key=NULL if the
bcddb9
+ *       returned string was empty.
bcddb9
+ *    -1 When WITH_UDEV is undefined and a system error is reported
bcddb9
+ *    -2 When WITH_UDEV is defined, but calling virCommandRun fails
bcddb9
+ */
bcddb9
+int
bcddb9
+virStorageFileGetSCSIKey(const char *path,
bcddb9
+                         char **key)
bcddb9
 {
bcddb9
     int status;
bcddb9
     virCommandPtr cmd = virCommandNewArgList(
bcddb9
@@ -1446,7 +1460,7 @@ int virStorageFileGetSCSIKey(const char *path,
bcddb9
         "--device", path,
bcddb9
         NULL
bcddb9
         );
bcddb9
-    int ret = -1;
bcddb9
+    int ret = -2;
bcddb9
 
bcddb9
     *key = NULL;
bcddb9
 
bcddb9
-- 
bcddb9
2.21.0
bcddb9