On Mon, Feb 16, 2015 at 03:11:29PM +0100, Jiri Denemark wrote: > Not all file 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. > > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> > --- > src/Makefile.am | 2 ++ > src/driver.c | 1 + > src/locking/lock_driver_lockd.c | 1 + > src/locking/lock_manager.c | 1 + > src/remote/remote_driver.c | 1 + > src/util/virfile.c | 39 ++++++++++++++++++++++++++++++--------- > src/util/virfile.h | 8 +++++++- > 7 files changed, 43 insertions(+), 10 deletions(-) > > diff --git a/src/Makefile.am b/src/Makefile.am > index b41c6d4..a938d7e 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -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) \ > diff --git a/src/driver.c b/src/driver.c > index 1be32ef..1271597 100644 > --- a/src/driver.c > +++ b/src/driver.c > @@ -57,6 +57,7 @@ virDriverLoadModule(const char *name) > "libvirt_driver_", > ".so", > "src/.libs", > + VIR_FILE_FIND_RESOURCE_VPATH_BUILD, Instead of adding yet another parameter, why don't we just change the calling convention of virFileFindResource so that instead of assuming abs_topbuilddir we just make the caller prepend the builddir. eg instead of pasing 'src/.libs' we pass abs_topbuilddir "/src/.libs" letting the compiler concatenate these. The enum you define is basically doing exactly that but with an extra level of indirection which doesn't seem to buy us anything > @@ -1640,11 +1647,14 @@ virFileFindResourceFull(const char *filename, > const char *prefix, > const char *suffix, > const char *builddir, > + virFileFindResourceVPath vpath, > const char *installdir, > const char *envname) > { > char *ret = NULL; > const char *envval = envname ? virGetEnvBlockSUID(envname) : NULL; > + const char *base = ""; > + const char *path = ""; > > if (!prefix) > prefix = ""; > @@ -1652,16 +1662,25 @@ virFileFindResourceFull(const char *filename, > suffix = ""; > > if (envval) { > - if (virAsprintf(&ret, "%s/%s%s%s", envval, prefix, filename, suffix) < 0) > - return NULL; > + base = envval; > } else if (useDirOverride) { > - if (virAsprintf(&ret, "%s/%s/%s%s%s", abs_topbuilddir, builddir, prefix, filename, suffix) < 0) > - return NULL; eg, simply change this to be if (virAsprintf(&ret, "%s/%s/%s%s%s", builddir, prefix, filename, suffix) < 0) return NULL; Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list