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