mirror of https://gitee.com/openkylin/libvirt.git
Search for schemas and cpu_map.xml in source tree
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>
This commit is contained in:
parent
80c5f10e86
commit
bc6e206322
|
@ -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) \
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -641,7 +641,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
|
|||
}
|
||||
|
||||
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
|
||||
"src",
|
||||
abs_topbuilddir "/src",
|
||||
LIBEXECDIR)))
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -94,7 +94,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
|
|||
}
|
||||
|
||||
if (!(lxc_path = virFileFindResource("libvirt_lxc",
|
||||
"src",
|
||||
abs_topbuilddir "/src",
|
||||
LIBEXECDIR)))
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue