|
|
bba56f |
From 4b841d996f9e1181e6a0614eb0bc9a35d5f7c372 Mon Sep 17 00:00:00 2001
|
|
|
bba56f |
Message-Id: <4b841d996f9e1181e6a0614eb0bc9a35d5f7c372@dist-git>
|
|
|
bba56f |
From: John Ferlan <jferlan@redhat.com>
|
|
|
bba56f |
Date: Tue, 12 Mar 2019 13:55:57 -0400
|
|
|
bba56f |
Subject: [PATCH] storage: Rework virStorageBackendSCSISerial
|
|
|
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 code to use the virStorageFileGetSCSIKey helper
|
|
|
bba56f |
to fetch the unique key for the SCSI disk. Alter the logic
|
|
|
bba56f |
to follow the former code which would return a duplicate
|
|
|
bba56f |
of @dev when either the virCommandRun succeeded, but returned
|
|
|
bba56f |
an empty string or when WITH_UDEV was not true.
|
|
|
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 8bf89dc83729aaa0388f89e972a4847fd1e267c6)
|
|
|
bba56f |
|
|
|
bba56f |
Managed conflict in src/locking/lock_driver_lockd.c as a result of
|
|
|
bba56f |
commit e9e904b3b70533982954ab39ccb81122e8dad338 which changed from
|
|
|
bba56f |
using "goto error" to using "goto cleanup" by using the error label.
|
|
|
bba56f |
|
|
|
bba56f |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
bba56f |
Message-Id: <20190312175559.13583-3-jferlan@redhat.com>
|
|
|
bba56f |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
bba56f |
---
|
|
|
bba56f |
src/locking/lock_driver_lockd.c | 2 +-
|
|
|
bba56f |
src/storage/storage_util.c | 33 +++++++--------------------------
|
|
|
bba56f |
src/util/virstoragefile.c | 10 +++++++---
|
|
|
bba56f |
src/util/virstoragefile.h | 3 ++-
|
|
|
bba56f |
4 files changed, 17 insertions(+), 31 deletions(-)
|
|
|
bba56f |
|
|
|
bba56f |
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
|
|
|
bba56f |
index 957a963a7b..1b9341ceba 100644
|
|
|
bba56f |
--- a/src/locking/lock_driver_lockd.c
|
|
|
bba56f |
+++ b/src/locking/lock_driver_lockd.c
|
|
|
bba56f |
@@ -517,7 +517,7 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
|
|
|
bba56f |
if (STRPREFIX(name, "/dev") &&
|
|
|
bba56f |
driver->scsiLockSpaceDir) {
|
|
|
bba56f |
VIR_DEBUG("Trying to find an SCSI ID for %s", name);
|
|
|
bba56f |
- if (virStorageFileGetSCSIKey(name, &newName) < 0)
|
|
|
bba56f |
+ if (virStorageFileGetSCSIKey(name, &newName, false) < 0)
|
|
|
bba56f |
goto error;
|
|
|
bba56f |
|
|
|
bba56f |
if (newName) {
|
|
|
bba56f |
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
|
|
|
bba56f |
index 5dc22d3182..d1659c0c8d 100644
|
|
|
bba56f |
--- a/src/storage/storage_util.c
|
|
|
bba56f |
+++ b/src/storage/storage_util.c
|
|
|
bba56f |
@@ -3696,36 +3696,17 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
|
|
|
bba56f |
static char *
|
|
|
bba56f |
virStorageBackendSCSISerial(const char *dev)
|
|
|
bba56f |
{
|
|
|
bba56f |
+ int rc;
|
|
|
bba56f |
char *serial = NULL;
|
|
|
bba56f |
-#ifdef WITH_UDEV
|
|
|
bba56f |
- virCommandPtr cmd = virCommandNewArgList(
|
|
|
bba56f |
- "/lib/udev/scsi_id",
|
|
|
bba56f |
- "--replace-whitespace",
|
|
|
bba56f |
- "--whitelisted",
|
|
|
bba56f |
- "--device", dev,
|
|
|
bba56f |
- NULL
|
|
|
bba56f |
- );
|
|
|
bba56f |
|
|
|
bba56f |
- /* Run the program and capture its output */
|
|
|
bba56f |
- virCommandSetOutputBuffer(cmd, &serial);
|
|
|
bba56f |
- if (virCommandRun(cmd, NULL) < 0)
|
|
|
bba56f |
- goto cleanup;
|
|
|
bba56f |
-#endif
|
|
|
bba56f |
+ rc = virStorageFileGetSCSIKey(dev, &serial, true);
|
|
|
bba56f |
+ if (rc == 0 && serial)
|
|
|
bba56f |
+ return serial;
|
|
|
bba56f |
|
|
|
bba56f |
- if (serial && STRNEQ(serial, "")) {
|
|
|
bba56f |
- char *nl = strchr(serial, '\n');
|
|
|
bba56f |
- if (nl)
|
|
|
bba56f |
- *nl = '\0';
|
|
|
bba56f |
- } else {
|
|
|
bba56f |
- VIR_FREE(serial);
|
|
|
bba56f |
- ignore_value(VIR_STRDUP(serial, dev));
|
|
|
bba56f |
- }
|
|
|
bba56f |
-
|
|
|
bba56f |
-#ifdef WITH_UDEV
|
|
|
bba56f |
- cleanup:
|
|
|
bba56f |
- virCommandFree(cmd);
|
|
|
bba56f |
-#endif
|
|
|
bba56f |
+ if (rc == -2)
|
|
|
bba56f |
+ return NULL;
|
|
|
bba56f |
|
|
|
bba56f |
+ ignore_value(VIR_STRDUP(serial, dev));
|
|
|
bba56f |
return serial;
|
|
|
bba56f |
}
|
|
|
bba56f |
|
|
|
bba56f |
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
|
|
bba56f |
index ed7266619d..56d38b467e 100644
|
|
|
bba56f |
--- a/src/util/virstoragefile.c
|
|
|
bba56f |
+++ b/src/util/virstoragefile.c
|
|
|
bba56f |
@@ -1438,6 +1438,7 @@ int virStorageFileGetLVMKey(const char *path,
|
|
|
bba56f |
/* virStorageFileGetSCSIKey
|
|
|
bba56f |
* @path: Path to the SCSI device
|
|
|
bba56f |
* @key: Unique key to be returned
|
|
|
bba56f |
+ * @ignoreError: Used to not report ENOSYS
|
|
|
bba56f |
*
|
|
|
bba56f |
* Using a udev specific function, query the @path to get and return a
|
|
|
bba56f |
* unique @key for the caller to use.
|
|
|
bba56f |
@@ -1450,7 +1451,8 @@ int virStorageFileGetLVMKey(const char *path,
|
|
|
bba56f |
*/
|
|
|
bba56f |
int
|
|
|
bba56f |
virStorageFileGetSCSIKey(const char *path,
|
|
|
bba56f |
- char **key)
|
|
|
bba56f |
+ char **key,
|
|
|
bba56f |
+ bool ignoreError ATTRIBUTE_UNUSED)
|
|
|
bba56f |
{
|
|
|
bba56f |
int status;
|
|
|
bba56f |
virCommandPtr cmd = virCommandNewArgList(
|
|
|
bba56f |
@@ -1491,9 +1493,11 @@ virStorageFileGetSCSIKey(const char *path,
|
|
|
bba56f |
}
|
|
|
bba56f |
#else
|
|
|
bba56f |
int virStorageFileGetSCSIKey(const char *path,
|
|
|
bba56f |
- char **key ATTRIBUTE_UNUSED)
|
|
|
bba56f |
+ char **key ATTRIBUTE_UNUSED,
|
|
|
bba56f |
+ bool ignoreError)
|
|
|
bba56f |
{
|
|
|
bba56f |
- virReportSystemError(ENOSYS, _("Unable to get SCSI key for %s"), path);
|
|
|
bba56f |
+ if (!ignoreError)
|
|
|
bba56f |
+ virReportSystemError(ENOSYS, _("Unable to get SCSI key for %s"), path);
|
|
|
bba56f |
return -1;
|
|
|
bba56f |
}
|
|
|
bba56f |
#endif
|
|
|
bba56f |
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
|
|
|
bba56f |
index 991098e6c6..bbb0b8b3c1 100644
|
|
|
bba56f |
--- a/src/util/virstoragefile.h
|
|
|
bba56f |
+++ b/src/util/virstoragefile.h
|
|
|
bba56f |
@@ -384,7 +384,8 @@ bool virStorageIsRelative(const char *backing);
|
|
|
bba56f |
int virStorageFileGetLVMKey(const char *path,
|
|
|
bba56f |
char **key);
|
|
|
bba56f |
int virStorageFileGetSCSIKey(const char *path,
|
|
|
bba56f |
- char **key);
|
|
|
bba56f |
+ char **key,
|
|
|
bba56f |
+ bool ignoreError);
|
|
|
bba56f |
|
|
|
bba56f |
void virStorageAuthDefFree(virStorageAuthDefPtr def);
|
|
|
bba56f |
virStorageAuthDefPtr virStorageAuthDefCopy(const virStorageAuthDef *src);
|
|
|
bba56f |
--
|
|
|
bba56f |
2.21.0
|
|
|
bba56f |
|