The tool is used for pool discovery. Since we call an external binary we
don't really need to compile out the code that uses it. We can check
whether it exists at runtime.
---
configure.ac | 2 +-
src/storage/storage_backend.c | 29 ++++++++++++++++-------------
src/storage/storage_backend.h | 3 ++-
src/storage/storage_backend_fs.c | 4 +---
src/storage/storage_backend_gluster.c | 2 +-
5 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/configure.ac b/configure.ac
index c67ba79c7..9e41f8983 100644
--- a/configure.ac
+++ b/configure.ac
@@ -605,7 +605,7 @@ LIBVIRT_STORAGE_CHECK_ZFS
if test "$with_storage_fs" = "yes" ||
test "$with_storage_gluster" = "yes"; then
- AC_PATH_PROG([GLUSTER_CLI], [gluster], [], [$LIBVIRT_SBIN_PATH])
+ AC_PATH_PROG([GLUSTER_CLI], [gluster], [gluster], [$LIBVIRT_SBIN_PATH])
if test "x$GLUSTER_CLI" != "x"; then
AC_DEFINE_UNQUOTED([GLUSTER_CLI], ["$GLUSTER_CLI"],
[Location or name of the gluster command line tool])
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 6c9706897..65a893679 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -2548,12 +2548,12 @@ virStorageBackendVolWipeLocal(virConnectPtr conn
ATTRIBUTE_UNUSED,
}
-#ifdef GLUSTER_CLI
/**
* virStorageBackendFindGlusterPoolSources:
* @host: host to detect volumes on
* @pooltype: src->format is set to this value
* @list: list of storage pool sources to be filled
+ * @report: report error if the 'gluster' cli tool is missing
*
* Looks up gluster volumes on @host and fills them to @list.
*
@@ -2562,8 +2562,10 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
int
virStorageBackendFindGlusterPoolSources(const char *host,
int pooltype,
- virStoragePoolSourceListPtr list)
+ virStoragePoolSourceListPtr list,
+ bool report)
{
+ char *glusterpath = NULL;
char *outbuf = NULL;
virCommandPtr cmd = NULL;
xmlDocPtr doc = NULL;
@@ -2576,7 +2578,17 @@ virStorageBackendFindGlusterPoolSources(const char *host,
int ret = -1;
- cmd = virCommandNewArgList(GLUSTER_CLI,
+ if (!(glusterpath = virFindFileInPath(GLUSTER_CLI))) {
+ if (report) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("'gluster' command line tool not
found"));
+ return -1;
+ } else {
+ return 0;
+ }
+ }
+
+ cmd = virCommandNewArgList(glusterpath,
"--xml",
"--log-file=/dev/null",
"volume", "info", "all",
NULL);
@@ -2629,18 +2641,9 @@ virStorageBackendFindGlusterPoolSources(const char *host,
xmlFreeDoc(doc);
VIR_FREE(outbuf);
virCommandFree(cmd);
+ VIR_FREE(glusterpath);
return ret;
}
-#else /* #ifdef GLUSTER_CLI */
-int
-virStorageBackendFindGlusterPoolSources(const char *host ATTRIBUTE_UNUSED,
- int pooltype ATTRIBUTE_UNUSED,
- virStoragePoolSourceListPtr list
ATTRIBUTE_UNUSED)
-{
- VIR_INFO("gluster cli tool not installed");
- return 0;
-}
-#endif /* #ifdef GLUSTER_CLI */
#if WITH_BLKID
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index 7ae8d58db..3f0403907 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -135,7 +135,8 @@ virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
int virStorageBackendFindGlusterPoolSources(const char *host,
int pooltype,
- virStoragePoolSourceListPtr list);
+ virStoragePoolSourceListPtr list,
+ bool report);
int virStorageBackendVolUploadLocal(virConnectPtr conn,
virStoragePoolObjPtr pool,
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index b915fd58b..53c34335f 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -306,15 +306,13 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn
ATTRIBUTE_UNUSE
retNFS = virStorageBackendFileSystemNetFindNFSPoolSources(&state);
-# ifdef GLUSTER_CLI
retGluster = virStorageBackendFindGlusterPoolSources(state.host,
VIR_STORAGE_POOL_NETFS_GLUSTERFS,
- &state.list);
+ &state.list, false);
if (retGluster < 0)
goto cleanup;
-# endif
/* If both fail, then we won't return an empty list - return an error */
if (retNFS < 0 && retGluster == 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
diff --git a/src/storage/storage_backend_gluster.c
b/src/storage/storage_backend_gluster.c
index 0bd40f742..e819f6299 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -513,7 +513,7 @@ virStorageBackendGlusterFindPoolSources(virConnectPtr conn
ATTRIBUTE_UNUSED,
if ((rc = virStorageBackendFindGlusterPoolSources(source->hosts[0].name,
0, /* currently ignored */
- &list)) < 0)
+ &list, true)) < 0)
goto cleanup;
if (rc == 0) {
--
2.11.0