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