提交 9e97c8c0 编写于 作者: P Peter Krempa

storage: gluster: Remove build-time dependency on the 'gluster' cli tool

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.
上级 ce5055d7
......@@ -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])
......
......@@ -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
......
......@@ -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,
......
......@@ -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,
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册