diff --git a/configure.ac b/configure.ac index c67ba79c74..9e41f8983f 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 868c98e16b..453f20acf0 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 7ae8d58dbc..3f04039074 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 6f30351e5a..c3f7959380 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 0bd40f742b..e819f62996 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) {