]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: gluster: Remove build-time dependency on the 'gluster' cli tool
authorPeter Krempa <pkrempa@redhat.com>
Mon, 9 Jan 2017 14:56:12 +0000 (15:56 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 18 Jan 2017 09:45:15 +0000 (10:45 +0100)
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
src/storage/storage_backend.c
src/storage/storage_backend.h
src/storage/storage_backend_fs.c
src/storage/storage_backend_gluster.c

index c67ba79c74af303cc337950e7118cb8869a80a3d..9e41f8983f634237ba62e2961f9580dd5a7b4800 100644 (file)
@@ -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])
index 868c98e16b5e04379a1a06a4e3424b883b655615..453f20acf02f8b62658831156cfa84ab83800fa8 100644 (file)
@@ -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
index 7ae8d58dbc29775f596655734071378605159ef9..3f0403907474ddd4f2023057a6941154c8e8b93a 100644 (file)
@@ -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,
index 6f30351e5ade897543e41d910765a56f793b9d56..c3f7959380c66bf3c4bd9e773f3ef5894a7a9e4e 100644 (file)
@@ -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,
index 0bd40f742b5c5f0d70d5b4a94028fecab86bee8f..e819f62996d0d3b904e86ed4df6830333752da06 100644 (file)
@@ -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) {