]> xenbits.xensource.com Git - libvirt.git/commitdiff
Search for schemas and cpu_map.xml in source tree
authorJiri Denemark <jdenemar@redhat.com>
Fri, 13 Feb 2015 13:25:27 +0000 (14:25 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 19 Feb 2015 14:25:04 +0000 (15:25 +0100)
Not all files we want to find using virFileFindResource{,Full} are
generated when libvirt is built, some of them (such as RNG schemas) are
distributed with sources. The current API was not able to find source
files if libvirt was built in VPATH.

Both RNG schemas and cpu_map.xml are distributed in source tarball.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
12 files changed:
src/Makefile.am
src/conf/domain_conf.c
src/cpu/cpu_map.c
src/driver.c
src/fdstream.c
src/locking/lock_driver_lockd.c
src/locking/lock_manager.c
src/lxc/lxc_conf.c
src/network/bridge_driver.c
src/remote/remote_driver.c
src/storage/storage_backend_disk.c
src/util/virfile.c

index b41c6d4236768a966c19e6f4c45458c9a48f8791..a938d7ea7fb3039f932a717e93ab79bbd8231d4f 100644 (file)
@@ -20,6 +20,7 @@
 abs_builddir = $(shell pwd)
 abs_topbuilddir = $(shell cd .. && pwd)
 abs_srcdir = $(shell cd $(srcdir) && pwd)
+abs_topsrcdir = $(shell cd $(srcdir)/.. && pwd)
 
 # No libraries with the exception of LIBXML should be listed
 # here. List them against the individual XXX_la_CFLAGS targets
@@ -32,6 +33,7 @@ INCLUDES =    -I../gnulib/lib                                 \
                -I$(srcdir)/util                                \
                -DIN_LIBVIRT                                    \
                -Dabs_topbuilddir="\"$(abs_topbuilddir)\""      \
+               -Dabs_topsrcdir="\"$(abs_topsrcdir)\""          \
                $(GETTEXT_CPPFLAGS)
 
 AM_CFLAGS =    $(LIBXML_CFLAGS)                                \
index b13cae87e1a542fa6990d02fdbd79c6776699cf9..2e352934cae003eda5a2a47e7891eaee5711397a 100644 (file)
@@ -12887,7 +12887,7 @@ virDomainDefParseXML(xmlDocPtr xml,
 
     if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE) {
         char *schema = virFileFindResource("domain.rng",
-                                           "docs/schemas",
+                                           abs_topsrcdir "/docs/schemas",
                                            PKGDATADIR "/schemas");
         if (!schema)
             return NULL;
index b77f68847eba014d60c596e1ce55c5b8f478c7bc..6130f8a5307132ae0c0d61eae3d5a6970302bb0d 100644 (file)
@@ -87,7 +87,7 @@ int cpuMapLoad(const char *arch,
     char *mapfile;
 
     if (!(mapfile = virFileFindResource("cpu_map.xml",
-                                        "src/cpu",
+                                        abs_topsrcdir "/src/cpu",
                                         PKGDATADIR)))
         return -1;
 
index 1be32efbeeaf1a1839b0a865a3ea6a999e093f7f..db03438ba3619f6f0c9bf4cd59886e314cade992 100644 (file)
@@ -56,7 +56,7 @@ virDriverLoadModule(const char *name)
     if (!(modfile = virFileFindResourceFull(name,
                                             "libvirt_driver_",
                                             ".so",
-                                            "src/.libs",
+                                            abs_topbuilddir "/src/.libs",
                                             LIBDIR "/libvirt/connection-driver",
                                             "LIBVIRT_DRIVER_DIR")))
         return NULL;
index 18bd35973980322bafaaedf9576ace6d1a9c04b0..5d80fc23fcdb520fa733e7d7b9cb635549e23e0b 100644 (file)
@@ -641,7 +641,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
         }
 
         if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
-                                                  "src",
+                                                  abs_topbuilddir "/src",
                                                   LIBEXECDIR)))
             goto error;
 
index 2af3f224105d83ccb75b9402beeff25203f311f7..8d184fec9a8b79f7a38e8310c585b976889f19ff 100644 (file)
@@ -253,7 +253,7 @@ static virNetClientPtr virLockManagerLockDaemonConnectionNew(bool privileged,
     if (!privileged &&
         !(daemonPath = virFileFindResourceFull("virtlockd",
                                                NULL, NULL,
-                                               "src",
+                                               abs_topbuilddir "/src",
                                                SBINDIR,
                                                "VIRTLOCKD_PATH")))
         goto error;
index ec90d0417649e671ce6bd25cc3e45193375a17d3..f277f22cba1790d18fe58c02d5b8e7d3a318974e 100644 (file)
@@ -142,7 +142,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
         if (!(modfile = virFileFindResourceFull(name,
                                                 NULL,
                                                 ".so",
-                                                "src/.libs",
+                                                abs_topbuilddir "/src/.libs",
                                                 LIBDIR "/libvirt/lock-driver",
                                                 "LIBVIRT_LOCK_MANAGER_PLUGIN_DIR")))
             goto cleanup;
index b6d17972841663ac4c75b7eee09002033becaf3f..d1a3be551c3b9707793819e9318515d2dd1f8313 100644 (file)
@@ -94,7 +94,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
     }
 
     if (!(lxc_path = virFileFindResource("libvirt_lxc",
-                                         "src",
+                                         abs_topbuilddir "/src",
                                          LIBEXECDIR)))
         goto error;
 
index 2798010c4f622b764004950b0fc831833b850726..404e90b6398e1859d9a4307bc53e2178c1d3be12 100644 (file)
@@ -1289,7 +1289,7 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network,
 
     /* This helper is used to create custom leases file for libvirt */
     if (!(leaseshelper_path = virFileFindResource("libvirt_leaseshelper",
-                                                  "src",
+                                                  abs_topbuilddir "/src",
                                                   LIBEXECDIR)))
         goto cleanup;
 
index d4fd658089a7d837c1317315217dee4fee0696e5..76c1d0c2d1cd9cc44a1986c58720534de9189012 100644 (file)
@@ -887,7 +887,7 @@ doRemoteOpen(virConnectPtr conn,
         if ((flags & VIR_DRV_OPEN_REMOTE_AUTOSTART) &&
             !(daemonPath = virFileFindResourceFull("libvirtd",
                                                    NULL, NULL,
-                                                   "daemon",
+                                                   abs_topbuilddir "/daemon",
                                                    SBINDIR,
                                                    "LIBVIRTD_PATH")))
             goto failed;
index 9f4d76a9b3148c43fce0f41efdf42a397a4d5014..39082cc5bd944cc61a97c5276231d587f1c4de3d 100644 (file)
@@ -301,7 +301,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
     int ret;
 
     if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
-                                                "src",
+                                                abs_topbuilddir "/src",
                                                 LIBEXECDIR)))
         return -1;
 
@@ -346,7 +346,7 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
     int ret;
 
     if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
-                                                "src",
+                                                abs_topbuilddir "/src",
                                                 LIBEXECDIR)))
         return -1;
 
index 1b004d69b898e17765bd8af6612bf03883f600df..c528a1c01a06879cc97ff08298f9e3bfc0b7c272 100644 (file)
@@ -248,7 +248,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
     }
 
     if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
-                                              "src",
+                                              abs_topbuilddir "/src",
                                               LIBEXECDIR)))
         goto error;
 
@@ -1618,7 +1618,8 @@ static bool useDirOverride;
  * @filename: libvirt distributed filename without any path
  * @prefix: optional string to prepend to filename
  * @suffix: optional string to append to filename
- * @builddir: location of the binary in the source tree build tree
+ * @builddir: location of the filename in the build tree including
+ *            abs_topsrcdir or abs_topbuilddir prefix
  * @installdir: location of the installed binary
  * @envname: environment variable used to override all dirs
  *
@@ -1628,7 +1629,7 @@ static bool useDirOverride;
  * path in the installed location.
  *
  * If @envname is non-NULL it will override all other
- * directory lookup
+ * directory lookup.
  *
  * Only use this with @filename files that are part of
  * the libvirt tree, not 3rd party binaries/files.
@@ -1645,22 +1646,22 @@ virFileFindResourceFull(const char *filename,
 {
     char *ret = NULL;
     const char *envval = envname ? virGetEnvBlockSUID(envname) : NULL;
+    const char *path;
 
     if (!prefix)
         prefix = "";
     if (!suffix)
         suffix = "";
 
-    if (envval) {
-        if (virAsprintf(&ret, "%s/%s%s%s", envval, prefix, filename, suffix) < 0)
-            return NULL;
-    } else if (useDirOverride) {
-        if (virAsprintf(&ret, "%s/%s/%s%s%s", abs_topbuilddir, builddir, prefix, filename, suffix) < 0)
-            return NULL;
-    } else {
-        if (virAsprintf(&ret, "%s/%s%s%s", installdir, prefix, filename, suffix) < 0)
-            return NULL;
-    }
+    if (envval)
+        path = envval;
+    else if (useDirOverride)
+        path = builddir;
+    else
+        path = installdir;
+
+    if (virAsprintf(&ret, "%s/%s%s%s", path, prefix, filename, suffix) < 0)
+        return NULL;
 
     VIR_DEBUG("Resolved '%s' to '%s'", filename, ret);
     return ret;