mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
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_builddir = $(shell pwd)
|
||||||
abs_topbuilddir = $(shell cd .. && pwd)
|
abs_topbuilddir = $(shell cd .. && pwd)
|
||||||
abs_srcdir = $(shell cd $(srcdir) && pwd)
|
abs_srcdir = $(shell cd $(srcdir) && pwd)
|
||||||
|
abs_topsrcdir = $(shell cd $(srcdir)/.. && pwd)
|
||||||
|
|
||||||
# No libraries with the exception of LIBXML should be listed
|
# No libraries with the exception of LIBXML should be listed
|
||||||
# here. List them against the individual XXX_la_CFLAGS targets
|
# here. List them against the individual XXX_la_CFLAGS targets
|
||||||
@ -32,6 +33,7 @@ INCLUDES = -I../gnulib/lib \
|
|||||||
-I$(srcdir)/util \
|
-I$(srcdir)/util \
|
||||||
-DIN_LIBVIRT \
|
-DIN_LIBVIRT \
|
||||||
-Dabs_topbuilddir="\"$(abs_topbuilddir)\"" \
|
-Dabs_topbuilddir="\"$(abs_topbuilddir)\"" \
|
||||||
|
-Dabs_topsrcdir="\"$(abs_topsrcdir)\"" \
|
||||||
$(GETTEXT_CPPFLAGS)
|
$(GETTEXT_CPPFLAGS)
|
||||||
|
|
||||||
AM_CFLAGS = $(LIBXML_CFLAGS) \
|
AM_CFLAGS = $(LIBXML_CFLAGS) \
|
||||||
|
@ -12887,7 +12887,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
|
|
||||||
if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE) {
|
if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE) {
|
||||||
char *schema = virFileFindResource("domain.rng",
|
char *schema = virFileFindResource("domain.rng",
|
||||||
"docs/schemas",
|
abs_topsrcdir "/docs/schemas",
|
||||||
PKGDATADIR "/schemas");
|
PKGDATADIR "/schemas");
|
||||||
if (!schema)
|
if (!schema)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -87,7 +87,7 @@ int cpuMapLoad(const char *arch,
|
|||||||
char *mapfile;
|
char *mapfile;
|
||||||
|
|
||||||
if (!(mapfile = virFileFindResource("cpu_map.xml",
|
if (!(mapfile = virFileFindResource("cpu_map.xml",
|
||||||
"src/cpu",
|
abs_topsrcdir "/src/cpu",
|
||||||
PKGDATADIR)))
|
PKGDATADIR)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ virDriverLoadModule(const char *name)
|
|||||||
if (!(modfile = virFileFindResourceFull(name,
|
if (!(modfile = virFileFindResourceFull(name,
|
||||||
"libvirt_driver_",
|
"libvirt_driver_",
|
||||||
".so",
|
".so",
|
||||||
"src/.libs",
|
abs_topbuilddir "/src/.libs",
|
||||||
LIBDIR "/libvirt/connection-driver",
|
LIBDIR "/libvirt/connection-driver",
|
||||||
"LIBVIRT_DRIVER_DIR")))
|
"LIBVIRT_DRIVER_DIR")))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -641,7 +641,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
|
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
|
||||||
"src",
|
abs_topbuilddir "/src",
|
||||||
LIBEXECDIR)))
|
LIBEXECDIR)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ static virNetClientPtr virLockManagerLockDaemonConnectionNew(bool privileged,
|
|||||||
if (!privileged &&
|
if (!privileged &&
|
||||||
!(daemonPath = virFileFindResourceFull("virtlockd",
|
!(daemonPath = virFileFindResourceFull("virtlockd",
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
"src",
|
abs_topbuilddir "/src",
|
||||||
SBINDIR,
|
SBINDIR,
|
||||||
"VIRTLOCKD_PATH")))
|
"VIRTLOCKD_PATH")))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -142,7 +142,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
|||||||
if (!(modfile = virFileFindResourceFull(name,
|
if (!(modfile = virFileFindResourceFull(name,
|
||||||
NULL,
|
NULL,
|
||||||
".so",
|
".so",
|
||||||
"src/.libs",
|
abs_topbuilddir "/src/.libs",
|
||||||
LIBDIR "/libvirt/lock-driver",
|
LIBDIR "/libvirt/lock-driver",
|
||||||
"LIBVIRT_LOCK_MANAGER_PLUGIN_DIR")))
|
"LIBVIRT_LOCK_MANAGER_PLUGIN_DIR")))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -94,7 +94,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(lxc_path = virFileFindResource("libvirt_lxc",
|
if (!(lxc_path = virFileFindResource("libvirt_lxc",
|
||||||
"src",
|
abs_topbuilddir "/src",
|
||||||
LIBEXECDIR)))
|
LIBEXECDIR)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -1289,7 +1289,7 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network,
|
|||||||
|
|
||||||
/* This helper is used to create custom leases file for libvirt */
|
/* This helper is used to create custom leases file for libvirt */
|
||||||
if (!(leaseshelper_path = virFileFindResource("libvirt_leaseshelper",
|
if (!(leaseshelper_path = virFileFindResource("libvirt_leaseshelper",
|
||||||
"src",
|
abs_topbuilddir "/src",
|
||||||
LIBEXECDIR)))
|
LIBEXECDIR)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -887,7 +887,7 @@ doRemoteOpen(virConnectPtr conn,
|
|||||||
if ((flags & VIR_DRV_OPEN_REMOTE_AUTOSTART) &&
|
if ((flags & VIR_DRV_OPEN_REMOTE_AUTOSTART) &&
|
||||||
!(daemonPath = virFileFindResourceFull("libvirtd",
|
!(daemonPath = virFileFindResourceFull("libvirtd",
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
"daemon",
|
abs_topbuilddir "/daemon",
|
||||||
SBINDIR,
|
SBINDIR,
|
||||||
"LIBVIRTD_PATH")))
|
"LIBVIRTD_PATH")))
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -301,7 +301,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
|
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
|
||||||
"src",
|
abs_topbuilddir "/src",
|
||||||
LIBEXECDIR)))
|
LIBEXECDIR)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -346,7 +346,7 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
|
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
|
||||||
"src",
|
abs_topbuilddir "/src",
|
||||||
LIBEXECDIR)))
|
LIBEXECDIR)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
|
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
|
||||||
"src",
|
abs_topbuilddir "/src",
|
||||||
LIBEXECDIR)))
|
LIBEXECDIR)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -1618,7 +1618,8 @@ static bool useDirOverride;
|
|||||||
* @filename: libvirt distributed filename without any path
|
* @filename: libvirt distributed filename without any path
|
||||||
* @prefix: optional string to prepend to filename
|
* @prefix: optional string to prepend to filename
|
||||||
* @suffix: optional string to append 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
|
* @installdir: location of the installed binary
|
||||||
* @envname: environment variable used to override all dirs
|
* @envname: environment variable used to override all dirs
|
||||||
*
|
*
|
||||||
@ -1628,7 +1629,7 @@ static bool useDirOverride;
|
|||||||
* path in the installed location.
|
* path in the installed location.
|
||||||
*
|
*
|
||||||
* If @envname is non-NULL it will override all other
|
* If @envname is non-NULL it will override all other
|
||||||
* directory lookup
|
* directory lookup.
|
||||||
*
|
*
|
||||||
* Only use this with @filename files that are part of
|
* Only use this with @filename files that are part of
|
||||||
* the libvirt tree, not 3rd party binaries/files.
|
* the libvirt tree, not 3rd party binaries/files.
|
||||||
@ -1645,22 +1646,22 @@ virFileFindResourceFull(const char *filename,
|
|||||||
{
|
{
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
const char *envval = envname ? virGetEnvBlockSUID(envname) : NULL;
|
const char *envval = envname ? virGetEnvBlockSUID(envname) : NULL;
|
||||||
|
const char *path;
|
||||||
|
|
||||||
if (!prefix)
|
if (!prefix)
|
||||||
prefix = "";
|
prefix = "";
|
||||||
if (!suffix)
|
if (!suffix)
|
||||||
suffix = "";
|
suffix = "";
|
||||||
|
|
||||||
if (envval) {
|
if (envval)
|
||||||
if (virAsprintf(&ret, "%s/%s%s%s", envval, prefix, filename, suffix) < 0)
|
path = envval;
|
||||||
return NULL;
|
else if (useDirOverride)
|
||||||
} else if (useDirOverride) {
|
path = builddir;
|
||||||
if (virAsprintf(&ret, "%s/%s/%s%s%s", abs_topbuilddir, builddir, prefix, filename, suffix) < 0)
|
else
|
||||||
return NULL;
|
path = installdir;
|
||||||
} else {
|
|
||||||
if (virAsprintf(&ret, "%s/%s%s%s", installdir, prefix, filename, suffix) < 0)
|
if (virAsprintf(&ret, "%s/%s%s%s", path, prefix, filename, suffix) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
VIR_DEBUG("Resolved '%s' to '%s'", filename, ret);
|
VIR_DEBUG("Resolved '%s' to '%s'", filename, ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user