[libvirt] [PATCH 0/9] Standardize on lookup of resources in build dir

Instead of having a bunch of custom override functions for each different area of code, standardize on one set of helper APIs for loading resources. This is derived from Nehal's proposal, based on my / Eric's feedback https://www.redhat.com/archives/libvir-list/2014-March/msg01544.html Daniel P. Berrange (5): Add helpers for resolving path to resources in build tree Activate build dir overrides in libvirtd, virtlockd & tests Use virFileFindResource to locate lock manager plugins Use virFileFindResource to locate driver plugins Use virFileFindResource to locate CPU map XML Nehal J Wani (4): Use virFileFindResource to locate iohelper for virFileWrapperFdNew Use virFileFindResource to locate libvirt_lxc for capabilities Use virFileFindResource to locate parthelper for storage backend Use virFileFindResource to locate iohelper for fdstream daemon/libvirtd.c | 31 +----------- src/Makefile.am | 2 + src/cpu/cpu_map.c | 31 ++++-------- src/cpu/cpu_map.h | 3 -- src/driver.c | 26 +++-------- src/driver.h | 1 - src/fdstream.c | 21 ++++----- src/fdstream.h | 3 -- src/libvirt_private.syms | 4 +- src/locking/lock_daemon.c | 2 + src/locking/lock_manager.c | 28 ++++------- src/locking/lock_manager.h | 1 - src/lxc/lxc_conf.c | 14 +++++- src/storage/storage_backend_disk.c | 31 +++++++++--- src/util/virfile.c | 96 +++++++++++++++++++++++++++++++++++++- src/util/virfile.h | 11 +++++ tests/cputest.c | 14 ------ tests/fdstreamtest.c | 3 -- tests/qemuxml2argvtest.c | 7 --- tests/qemuxmlnstest.c | 7 --- tests/testutils.c | 2 + tests/virdrivermoduletest.c | 2 - 22 files changed, 187 insertions(+), 153 deletions(-) -- 1.9.0

Add virFileFindResource which will try to locate files in the local build tree if the calling binary (eg libvirtd or test suite) is being run from the build tree. The corresponding virFileActivateDirOverride should be called at startup passing in argv[0]. This will be examined for evidence of libtool magic binary prefix / sub-directory in order to activate the override. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/Makefile.am | 2 ++ src/libvirt_private.syms | 3 ++ src/util/virfile.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ src/util/virfile.h | 11 +++++++ 4 files changed, 99 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index 21d56fc..5fb9e88 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ # old automake does not provide abs_{src,build}dir variables abs_builddir = $(shell pwd) +abs_topbuilddir = $(shell cd .. && pwd) abs_srcdir = $(shell cd $(srcdir) && pwd) # No libraries with the exception of LIBXML should be listed @@ -30,6 +31,7 @@ INCLUDES = -I../gnulib/lib \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src/util \ -DIN_LIBVIRT \ + -Dabs_topbuilddir="\"$(abs_topbuilddir)\"" \ $(GETTEXT_CPPFLAGS) AM_CFLAGS = $(LIBXML_CFLAGS) \ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 53dbdb4..1c7dd72 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1222,6 +1222,7 @@ virBuildPathInternal; virDirCreate; virFileAbsPath; virFileAccessibleAs; +virFileActivateDirOverride; virFileBuildPath; virFileClose; virFileDeleteTree; @@ -1230,6 +1231,8 @@ virFileExists; virFileFclose; virFileFdopen; virFileFindMountPoint; +virFileFindResource; +virFileFindResourceFull; virFileGetMountReverseSubtree; virFileGetMountSubtree; virFileHasSuffix; diff --git a/src/util/virfile.c b/src/util/virfile.c index cffcbc1..c7cf84a 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1542,6 +1542,89 @@ virFindFileInPath(const char *file) return fullpath; } + +static bool useDirOverride = false; + +/** + * virFileFindResourceFull: + * @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 + * @installdir: location of the installed binary + * @envname: environment variable used to override all dirs + * + * A helper which will return a path to @filename within + * the current build tree, if the calling binary is being + * run from the source tree. Otherwise it will return the + * path in the installed location. + * + * If @envname is none-NULL it will override all other + * directory lookup + * + * Only use this with @filename files that are part of + * the libvirt tree, not 3rd party binaries/files. + */ +char *virFileFindResourceFull(const char *filename, + const char *prefix, + const char *suffix, + const char *builddir, + const char *installdir, + const char *envname) +{ + char *ret = NULL; + const char *envval = envname ? virGetEnvBlockSUID(envname) : NULL; + + 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; + } + + VIR_DEBUG("Resolved '%s' to '%s'", filename, ret); + return ret; +} + +char * +virFileFindResource(const char *filename, + const char *builddir, + const char *installdir) +{ + return virFileFindResourceFull(filename, NULL, NULL, builddir, installdir, NULL); +} + + +/** + * virFileActivateDirOverride: + * @argv0: argv[0] of the calling program + * + * Look at @argv0 and try to detect if running from + * a build directory, by looking for a 'lt-' prefix + * on the binary name, or '/.libs/' in the path + */ +void virFileActivateDirOverride(const char *argv0) +{ + char *file = strrchr(argv0, '/'); + if (!file || file[1] == '\0') + return; + file++; + if (STRPREFIX(file, "lt-") || + strstr(argv0, "/.libs/")) { + useDirOverride = true; + VIR_DEBUG("Activating build dir override for %s", argv0); + } +} + bool virFileIsDir(const char *path) { diff --git a/src/util/virfile.h b/src/util/virfile.h index 46ef781..d5227d1 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -160,6 +160,17 @@ int virFileIsLink(const char *linkpath) char *virFindFileInPath(const char *file); +char *virFileFindResource(const char *filename, + const char *builddir, + const char *installdir); +char *virFileFindResourceFull(const char *filename, + const char *prefix, + const char *suffix, + const char *builddir, + const char *installdir, + const char *envname); +void virFileActivateDirOverride(const char *argv0); + bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1); bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1); bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1); -- 1.9.0

+ * virFileFindResourceFull: + * @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 + * @installdir: location of the installed binary + * @envname: environment variable used to override all dirs + * + * A helper which will return a path to @filename within + * the current build tree, if the calling binary is being + * run from the source tree. Otherwise it will return the + * path in the installed location. + * + * If @envname is none-NULL it will override all other + * directory lookup + * + * Only use this with @filename files that are part of + * the libvirt tree, not 3rd party binaries/files. + */
Shouldn't we be mentioning here that its caller's responsibility to free the returned value?
+char *virFileFindResourceFull(const char *filename, + const char *prefix, + const char *suffix, + const char *builddir, + const char *installdir, + const char *envname) +{
char *virFindFileInPath(const char *file);
+char *virFileFindResource(const char *filename, + const char *builddir, + const char *installdir); +char *virFileFindResourceFull(const char *filename, + const char *prefix, + const char *suffix, + const char *builddir, + const char *installdir, + const char *envname); +void virFileActivateDirOverride(const char *argv0); +
I really liked the generalization. I have gone through each patch of this series and have only one question. The recursive grep: grep "main(int argc" -r ./* in libvirt's root directory, gives the following files: ./daemon/libvirtd.c ./examples/domsuspend/suspend.c ./examples/hellolibvirt/hellolibvirt.c ./examples/openauth/openauth.c ./examples/object-events/event-test.c ./src/lxc/lxc_controller.c ./src/security/virt-aa-helper.c ./src/locking/lock_daemon.c ./src/locking/sanlock_helper.c ./src/util/iohelper.c ./src/storage/parthelper.c ./tests/test_conf.c ./tests/testutils.h ./tests/testutils.h ./tests/commandhelper.c ./tests/shunloadtest.c ./tests/ssh.c ./tests/seclabeltest.c ./tools/virt-host-validate.c ./tools/virt-login-shell.c ./tools/virsh.c Shouldn't we be calling virFileActivateDirOverride(argv[0]) in all of them? Regards, Nehal J Wani

On 04/24/2014 01:21 PM, Nehal J Wani wrote:
+ * virFileFindResourceFull: + * @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 + * @installdir: location of the installed binary + * @envname: environment variable used to override all dirs + * + * A helper which will return a path to @filename within + * the current build tree, if the calling binary is being + * run from the source tree. Otherwise it will return the + * path in the installed location. + * + * If @envname is none-NULL it will override all other
s/none/non/
+ * directory lookup + * + * Only use this with @filename files that are part of + * the libvirt tree, not 3rd party binaries/files. + */
Shouldn't we be mentioning here that its caller's responsibility to free the returned value?
Wouldn't hurt; although we tend in general to use 'char *' as a return of something malloc'd (caller frees) vs. 'const char *' as a return of something that the caller must not free.
+char *virFileFindResource(const char *filename, + const char *builddir, + const char *installdir);
Worth ATTRIBUTE_NONNULL for 1, 2, and 3?
+char *virFileFindResourceFull(const char *filename, + const char *prefix, + const char *suffix, + const char *builddir, + const char *installdir, + const char *envname);
Worth ATTRIBUTE_NONNULL for 1, 4, and 5?
I really liked the generalization. I have gone through each patch of this series and have only one question. The recursive grep: grep "main(int argc" -r ./* in libvirt's root directory, gives the following files: ./daemon/libvirtd.c ./examples/domsuspend/suspend.c ./examples/hellolibvirt/hellolibvirt.c ./examples/openauth/openauth.c ./examples/object-events/event-test.c ./src/lxc/lxc_controller.c ./src/security/virt-aa-helper.c ./src/locking/lock_daemon.c ./src/locking/sanlock_helper.c ./src/util/iohelper.c ./src/storage/parthelper.c ./tests/test_conf.c ./tests/testutils.h ./tests/testutils.h ./tests/commandhelper.c ./tests/shunloadtest.c ./tests/ssh.c ./tests/seclabeltest.c ./tools/virt-host-validate.c ./tools/virt-login-shell.c ./tools/virsh.c Shouldn't we be calling virFileActivateDirOverride(argv[0]) in all of them?
We really only need to call it within binaries that are themselves attempting to locate another resource. This rules out all of examples/ (those should be stand-alone, and not trying to use libvirt internals), as well as any of the test binaries that don't link against libvirt.so (commandhelper.c, ssh.c). testutils.h doesn't matter (we only care about the .c, not the macro magic in the .h). tools/virsh.c is borderline - we tried to write it as an example program that sticks to public libvirt interfaces rather than mucking with libvirt internals so that other clients could copy from it. It's also fairly easy to see that some others are standalone (iohelper.c and parthelper.c don't call out to many libvirt functions). Really, the easiest way to test whether this patch does the right thing, at least for what currently matters, is to copy libvirt.git into a virgin machine that lacks any installed libvirt, and prove that 'make check', './run daemon/libvirtd', and './run tools/virsh' still work; I'm in the middle of trying to set up a VM for just that purpose. But I'm okay with this patch series going in now, even if we missed something that could also benefit from using this API - we can do followup patches before 1.2.4 is actually released if we can spot any further problems, and I'd like to maximize the testing time before we freeze for release. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Fri, Apr 25, 2014 at 12:51:54AM +0530, Nehal J Wani wrote:
+ * virFileFindResourceFull: + * @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 + * @installdir: location of the installed binary + * @envname: environment variable used to override all dirs + * + * A helper which will return a path to @filename within + * the current build tree, if the calling binary is being + * run from the source tree. Otherwise it will return the + * path in the installed location. + * + * If @envname is none-NULL it will override all other + * directory lookup + * + * Only use this with @filename files that are part of + * the libvirt tree, not 3rd party binaries/files. + */
Shouldn't we be mentioning here that its caller's responsibility to free the returned value?
Yes, though any time 'char *' is returned the caller is expected to free the result. If the function owns the pointer it should always use 'const char *' instead.
I really liked the generalization. I have gone through each patch of this series and have only one question. The recursive grep: grep "main(int argc" -r ./* in libvirt's root directory, gives the following files: ./daemon/libvirtd.c ./examples/domsuspend/suspend.c ./examples/hellolibvirt/hellolibvirt.c ./examples/openauth/openauth.c ./examples/object-events/event-test.c ./src/lxc/lxc_controller.c ./src/security/virt-aa-helper.c ./src/locking/lock_daemon.c ./src/locking/sanlock_helper.c ./src/util/iohelper.c ./src/storage/parthelper.c ./tests/test_conf.c ./tests/testutils.h ./tests/testutils.h ./tests/commandhelper.c ./tests/shunloadtest.c ./tests/ssh.c ./tests/seclabeltest.c ./tools/virt-host-validate.c ./tools/virt-login-shell.c ./tools/virsh.c Shouldn't we be calling virFileActivateDirOverride(argv[0]) in all of them?
The examples need to stick to public libvirt APIs only. With the exception of probably virsh.c none of the others should need to load resources. So I think virsh is the only important one here - since it can autospawn libvirtd, so I'll look at making that work. 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 :|

On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
Add virFileFindResource which will try to locate files in the local build tree if the calling binary (eg libvirtd or test suite) is being run from the build tree. The corresponding virFileActivateDirOverride should be called at startup passing in argv[0]. This will be examined for evidence of libtool magic binary prefix / sub-directory in order to activate the override.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/Makefile.am | 2 ++ src/libvirt_private.syms | 3 ++ src/util/virfile.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ src/util/virfile.h | 11 +++++++ 4 files changed, 99 insertions(+)
+ +static bool useDirOverride = false;
C99 guarantees that static variables will initialize false, without an explicit initializer.
+char *virFileFindResourceFull(const char *filename,
+char * +virFileFindResource(const char *filename,
+void virFileActivateDirOverride(const char *argv0)
Not very consistent on whether to have a line break between return type and function name.
+{ + char *file = strrchr(argv0, '/'); + if (!file || file[1] == '\0') + return;
If file[1] == '\0', someone is playing nasty games with their exec() call, because you can't exec a directory :) At least your code is defensive against it. In addition to the 's/none/non/' pointed out in the other thread, ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Add calls to virFileActivateDirOverride so that the build dir overrides are activated. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 2 ++ src/locking/lock_daemon.c | 2 ++ tests/testutils.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index e197db4..b4e9c1f 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1156,6 +1156,8 @@ int main(int argc, char **argv) { virUpdateSelfLastChanged(argv[0]); + virFileActivateDirOverride(argv[0]); + if (strstr(argv[0], "lt-libvirtd") || strstr(argv[0], "/daemon/.libs/libvirtd")) { char *tmp = strrchr(argv[0], '/'); diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 455cc88..969f901 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -1271,6 +1271,8 @@ int main(int argc, char **argv) { } } + virFileActivateDirOverride(argv[0]); + if (!(config = virLockDaemonConfigNew(privileged))) { VIR_ERROR(_("Can't create initial configuration")); exit(EXIT_FAILURE); diff --git a/tests/testutils.c b/tests/testutils.c index 9767a78..7d27582 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -678,6 +678,8 @@ int virtTestMain(int argc, char *oomstr; #endif + virFileActivateDirOverride(argv[0]); + if (!virFileExists(abs_srcdir)) return EXIT_AM_HARDFAIL; -- 1.9.0

On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
Add calls to virFileActivateDirOverride so that the build dir overrides are activated.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 2 ++ src/locking/lock_daemon.c | 2 ++ tests/testutils.c | 2 ++ 3 files changed, 6 insertions(+)
I stepped through 'cd tests; ../run gdb cputest' to ensure that virFileActivateDirOverride() is indeed called, and that (thanks to how we build with libvirt) it picked up that the test was an in-tree binary. ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: Nehal J Wani <nehaljw.kkd1@gmail.com> Instead of hardcoding LIBEXECDIR as the location of the libvirt_iohelper binary, use virFileFindResource to optionally find it in the current build directory. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virfile.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index c7cf84a..47f413b 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -200,6 +200,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags) bool output = false; int pipefd[2] = { -1, -1 }; int mode = -1; + char *iohelper_path = NULL; if (!flags) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -243,8 +244,15 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags) goto error; } - ret->cmd = virCommandNewArgList(LIBEXECDIR "/libvirt_iohelper", - name, "0", NULL); + if (!(iohelper_path = virFileFindResource("libvirt_iohelper", + "src", + LIBEXECDIR))) + goto error; + + ret->cmd = virCommandNewArgList(iohelper_path, name, "0", NULL); + + VIR_FREE(iohelper_path); + if (output) { virCommandSetInputFD(ret->cmd, pipefd[0]); virCommandSetOutputFD(ret->cmd, fd); @@ -275,6 +283,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags) return ret; error: + VIR_FREE(iohelper_path); VIR_FORCE_CLOSE(pipefd[0]); VIR_FORCE_CLOSE(pipefd[1]); virFileWrapperFdFree(ret); -- 1.9.0

On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
From: Nehal J Wani <nehaljw.kkd1@gmail.com>
Instead of hardcoding LIBEXECDIR as the location of the libvirt_iohelper binary, use virFileFindResource to optionally find it in the current build directory.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virfile.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: Nehal J Wani <nehaljw.kkd1@gmail.com> Instead of hardcoding LIBEXECDIR as the location of the libvirt_lxc binary set in the LXC driver capabilities, use virFileFindResource to optionally find it in the current build directory. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/lxc/lxc_conf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index edc0b68..a35a5e0 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -38,6 +38,7 @@ #include "lxc_container.h" #include "virnodesuspend.h" #include "virstring.h" +#include "virfile.h" #define VIR_FROM_THIS VIR_FROM_LXC @@ -66,6 +67,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) virCapsPtr caps; virCapsGuestPtr guest; virArch altArch; + char *lxc_path = NULL; if ((caps = virCapabilitiesNew(virArchFromHost(), 0, 0)) == NULL) @@ -89,10 +91,15 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) goto error; } + if (!(lxc_path = virFileFindResource("libvirt_lxc", + "src", + LIBEXECDIR))) + goto error; + if ((guest = virCapabilitiesAddGuest(caps, "exe", caps->host.arch, - LIBEXECDIR "/libvirt_lxc", + lxc_path, NULL, 0, NULL)) == NULL) @@ -111,7 +118,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) if ((guest = virCapabilitiesAddGuest(caps, "exe", altArch, - LIBEXECDIR "/libvirt_lxc", + lxc_path, NULL, 0, NULL)) == NULL) @@ -126,6 +133,8 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) goto error; } + VIR_FREE(lxc_path); + if (driver) { /* Security driver data */ const char *doi, *model, *label, *type; @@ -158,6 +167,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) return caps; error: + VIR_FREE(lxc_path); virObjectUnref(caps); return NULL; } -- 1.9.0

From: Nehal J Wani <nehaljw.kkd1@gmail.com> Instead of hardcoding LIBEXECDIR as the location of the libvirt_parthelper binary, use virFileFindResource to optionally find it in the current build directory. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/storage/storage_backend_disk.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 9cebcca..71634c6 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -40,8 +40,6 @@ VIR_LOG_INIT("storage.storage_backend_disk"); -#define PARTHELPER LIBEXECDIR "/libvirt_parthelper" - #define SECTOR_SIZE 512 static int @@ -262,15 +260,24 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool, * - normal metadata 100027630080 100030242304 2612736 * */ - virCommandPtr cmd = virCommandNewArgList(PARTHELPER, - pool->def->source.devices[0].path, - NULL); + + char *parthelper_path; + virCommandPtr cmd; struct virStorageBackendDiskPoolVolData cbdata = { .pool = pool, .vol = vol, }; int ret; + if (!(parthelper_path = virFileFindResource("libvirt_parthelper", + "src", + LIBEXECDIR))) + return -1; + + cmd = virCommandNewArgList(parthelper_path, + pool->def->source.devices[0].path, + NULL); + pool->def->allocation = pool->def->capacity = pool->def->available = 0; ret = virCommandRunNul(cmd, @@ -278,6 +285,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool, virStorageBackendDiskMakeVol, &cbdata); virCommandFree(cmd); + VIR_FREE(parthelper_path); return ret; } @@ -302,17 +310,26 @@ virStorageBackendDiskMakePoolGeometry(size_t ntok ATTRIBUTE_UNUSED, static int virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool) { - virCommandPtr cmd = virCommandNewArgList(PARTHELPER, + char *parthelper_path; + virCommandPtr cmd; + int ret; + + if (!(parthelper_path = virFileFindResource("libvirt_parthelper", + "src", + LIBEXECDIR))) + return -1; + + cmd = virCommandNewArgList(parthelper_path, pool->def->source.devices[0].path, "-g", NULL); - int ret; ret = virCommandRunNul(cmd, 3, virStorageBackendDiskMakePoolGeometry, pool); virCommandFree(cmd); + VIR_FREE(parthelper_path); return ret; } -- 1.9.0

From: Nehal J Wani <nehaljw.kkd1@gmail.com> Instead of hardcoding LIBEXECDIR as the location of the libvirt_iohelper binary, use virFileFindResource to optionally find it in the current build directory. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/fdstream.c | 21 ++++++++++----------- src/fdstream.h | 3 --- src/libvirt_private.syms | 1 - tests/fdstreamtest.c | 3 --- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/fdstream.c b/src/fdstream.c index a244bb0..fd576ef 100644 --- a/src/fdstream.c +++ b/src/fdstream.c @@ -78,17 +78,6 @@ struct virFDStreamData { }; -static const char *iohelper_path = LIBEXECDIR "/libvirt_iohelper"; - -void virFDStreamSetIOHelper(const char *path) -{ - if (path == NULL) - iohelper_path = LIBEXECDIR "/libvirt_iohelper"; - else - iohelper_path = path; -} - - static int virFDStreamRemoveCallback(virStreamPtr stream) { struct virFDStreamData *fdst = stream->privateData; @@ -593,6 +582,7 @@ virFDStreamOpenFileInternal(virStreamPtr st, struct stat sb; virCommandPtr cmd = NULL; int errfd = -1; + char *iohelper_path = NULL; VIR_DEBUG("st=%p path=%s oflags=%x offset=%llu length=%llu mode=%o", st, path, oflags, offset, length, mode); @@ -648,9 +638,17 @@ virFDStreamOpenFileInternal(virStreamPtr st, goto error; } + if (!(iohelper_path = virFileFindResource("libvirt_iohelper", + "src", + LIBEXECDIR))) + goto error; + cmd = virCommandNewArgList(iohelper_path, path, NULL); + + VIR_FREE(iohelper_path); + virCommandAddArgFormat(cmd, "%llu", length); virCommandPassFD(cmd, fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); @@ -683,6 +681,7 @@ virFDStreamOpenFileInternal(virStreamPtr st, VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(childfd); VIR_FORCE_CLOSE(errfd); + VIR_FREE(iohelper_path); if (oflags & O_CREAT) unlink(path); return -1; diff --git a/src/fdstream.h b/src/fdstream.h index 9c7295d..69d8328 100644 --- a/src/fdstream.h +++ b/src/fdstream.h @@ -33,9 +33,6 @@ typedef void (*virFDStreamInternalCloseCb)(virStreamPtr st, void *opaque); typedef void (*virFDStreamInternalCloseCbFreeOpaque)(void *opaque); -/* Only for use by test suite */ -void virFDStreamSetIOHelper(const char *path); - int virFDStreamOpen(virStreamPtr st, int fd); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1c7dd72..7415b17 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -786,7 +786,6 @@ virFDStreamCreateFile; virFDStreamOpen; virFDStreamOpenFile; virFDStreamOpenPTY; -virFDStreamSetIOHelper; # libvirt_internal.h diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c index d52b77b..56ba5d9 100644 --- a/tests/fdstreamtest.c +++ b/tests/fdstreamtest.c @@ -321,9 +321,6 @@ mymain(void) { char scratchdir[] = SCRATCHDIRTEMPLATE; int ret = 0; - const char *iohelper = abs_builddir "/../src/libvirt_iohelper"; - - virFDStreamSetIOHelper(iohelper); if (!mkdtemp(scratchdir)) { virFilePrintf(stderr, "Cannot create fakesysfsdir"); -- 1.9.0

Replace virLockManagerSetPluginDir with virFileFindResource usage. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 1 - src/locking/lock_manager.c | 28 +++++++++------------------- src/locking/lock_manager.h | 1 - 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index b4e9c1f..c5915bd 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1179,7 +1179,6 @@ int main(int argc, char **argv) { argv[0], driverdir); exit(EXIT_FAILURE); } - virLockManagerSetPluginDir(driverdir); #ifdef WITH_DRIVER_MODULES virDriverModuleInitialize(driverdir); #endif diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c index 5093739..ec90d04 100644 --- a/src/locking/lock_manager.c +++ b/src/locking/lock_manager.c @@ -24,6 +24,7 @@ #include "lock_manager.h" #include "lock_driver_nop.h" #include "virerror.h" +#include "virfile.h" #include "virlog.h" #include "viralloc.h" #include "viruuid.h" @@ -64,18 +65,6 @@ struct _virLockManagerPlugin { int refs; }; -#define DEFAULT_LOCK_MANAGER_PLUGIN_DIR LIBDIR "/libvirt/lock-driver" - -static const char *virLockManagerPluginDir = DEFAULT_LOCK_MANAGER_PLUGIN_DIR; - -void -virLockManagerSetPluginDir(const char *dir) -{ - if (dir) - virLockManagerPluginDir = dir; -} - - static void virLockManagerLogParams(size_t nparams, virLockManagerParamPtr params) { @@ -137,7 +126,6 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name, void *handle = NULL; virLockDriverPtr driver; virLockManagerPluginPtr plugin = NULL; - const char *moddir = virGetEnvBlockSUID("LIBVIRT_LOCK_MANAGER_PLUGIN_DIR"); char *modfile = NULL; char *configFile = NULL; @@ -151,14 +139,16 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name, if (STREQ(name, "nop")) { driver = &virLockDriverNop; } else { - if (moddir == NULL) - moddir = virLockManagerPluginDir; - - VIR_DEBUG("Module load %s from %s", name, moddir); - - if (virAsprintf(&modfile, "%s/%s.so", moddir, name) < 0) + if (!(modfile = virFileFindResourceFull(name, + NULL, + ".so", + "src/.libs", + LIBDIR "/libvirt/lock-driver", + "LIBVIRT_LOCK_MANAGER_PLUGIN_DIR"))) goto cleanup; + VIR_DEBUG("Module load %s from %s", name, modfile); + if (access(modfile, R_OK) < 0) { virReportSystemError(errno, _("Plugin %s not accessible"), diff --git a/src/locking/lock_manager.h b/src/locking/lock_manager.h index fea9db8..4189759 100644 --- a/src/locking/lock_manager.h +++ b/src/locking/lock_manager.h @@ -28,7 +28,6 @@ typedef struct _virLockManagerPlugin virLockManagerPlugin; typedef virLockManagerPlugin *virLockManagerPluginPtr; -void virLockManagerSetPluginDir(const char *dir); virLockManagerPluginPtr virLockManagerPluginNew(const char *name, const char *driverName, const char *configDir, -- 1.9.0

On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
Replace virLockManagerSetPluginDir with virFileFindResource usage.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 1 - src/locking/lock_manager.c | 28 +++++++++------------------- src/locking/lock_manager.h | 1 - 3 files changed, 9 insertions(+), 21 deletions(-)
ACK for 4-6. ACK to this one if you also delete the reference to virLockManagerSetPluginDir in libvirt_private.syms. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Replace virDriverModuleInitialize with virFileFindResource usage. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 13 +------------ src/driver.c | 26 +++++++------------------- src/driver.h | 1 - tests/virdrivermoduletest.c | 2 -- 4 files changed, 8 insertions(+), 34 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index c5915bd..e549783 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1167,25 +1167,14 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } *tmp = '\0'; - char *driverdir; - if (virAsprintfQuiet(&driverdir, "%s/../../src/.libs", argv[0]) < 0 || - virAsprintfQuiet(&cpumap, "%s/../../src/cpu/cpu_map.xml", + if (virAsprintfQuiet(&cpumap, "%s/../../src/cpu/cpu_map.xml", argv[0]) < 0) { fprintf(stderr, _("%s: initialization failed\n"), argv[0]); exit(EXIT_FAILURE); } - if (access(driverdir, R_OK) < 0) { - fprintf(stderr, _("%s: expected driver directory '%s' is missing\n"), - argv[0], driverdir); - exit(EXIT_FAILURE); - } -#ifdef WITH_DRIVER_MODULES - virDriverModuleInitialize(driverdir); -#endif cpuMapOverride(cpumap); VIR_FREE(cpumap); *tmp = '/'; - /* Must not free 'driverdir' - it is still used */ } while (1) { diff --git a/src/driver.c b/src/driver.c index 6b79b5e..9e3a2eb 100644 --- a/src/driver.c +++ b/src/driver.c @@ -26,6 +26,7 @@ #include "driver.h" #include "viralloc.h" +#include "virfile.h" #include "virlog.h" #include "virutil.h" #include "configmake.h" @@ -41,21 +42,6 @@ VIR_LOG_INIT("driver"); # include <dlfcn.h> -static const char *moddir = NULL; - -void -virDriverModuleInitialize(const char *defmoddir) -{ - const char *custommoddir = virGetEnvBlockSUID("LIBVIRT_DRIVER_DIR"); - if (custommoddir) - moddir = custommoddir; - else if (defmoddir) - moddir = defmoddir; - else - moddir = DEFAULT_DRIVER_DIR; - VIR_DEBUG("Module dir %s", moddir); -} - void * virDriverLoadModule(const char *name) { @@ -63,12 +49,14 @@ virDriverLoadModule(const char *name) void *handle = NULL; int (*regsym)(void); - if (moddir == NULL) - virDriverModuleInitialize(NULL); - VIR_DEBUG("Module load %s", name); - if (virAsprintfQuiet(&modfile, "%s/libvirt_driver_%s.so", moddir, name) < 0) + if (!(modfile = virFileFindResourceFull(name, + "libvirt_driver_", + ".so", + "src/.libs", + LIBDIR "/libvirt/connection-driver", + "LIBVIRT_DRIVER_DIR"))) return NULL; if (access(modfile, R_OK) < 0) { diff --git a/src/driver.h b/src/driver.h index e66fc7a..729e743 100644 --- a/src/driver.h +++ b/src/driver.h @@ -2164,7 +2164,6 @@ int virRegisterNWFilterDriver(virNWFilterDriverPtr) ATTRIBUTE_RETURN_CHECK; # ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr) ATTRIBUTE_RETURN_CHECK; # endif -void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name); #endif /* __VIR_DRIVER_H__ */ diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c index 4203f5b..840fc28 100644 --- a/tests/virdrivermoduletest.c +++ b/tests/virdrivermoduletest.c @@ -65,8 +65,6 @@ mymain(void) ret = -1; \ } while (0) - virDriverModuleInitialize(abs_builddir "/../src/.libs"); - #ifdef WITH_NETWORK # define USE_NETWORK "network" TEST("network", NULL); -- 1.9.0

On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
Replace virDriverModuleInitialize with virFileFindResource usage.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 13 +------------ src/driver.c | 26 +++++++------------------- src/driver.h | 1 - tests/virdrivermoduletest.c | 2 -- 4 files changed, 8 insertions(+), 34 deletions(-)
ACK if you also delete the reference to virDriverModuleInitialize in libvirt_driver_modules.syms. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 04/24/2014 04:11 PM, Eric Blake wrote:
On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
Replace virDriverModuleInitialize with virFileFindResource usage.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 13 +------------ src/driver.c | 26 +++++++------------------- src/driver.h | 1 - tests/virdrivermoduletest.c | 2 -- 4 files changed, 8 insertions(+), 34 deletions(-)
ACK if you also delete the reference to virDriverModuleInitialize in libvirt_driver_modules.syms.
Hmm - that leaves libvirt_driver_modules.syms as exposing exactly one function: virDriverLoadModule. At this point, maybe it's better to just provide a stub function that gets compiled for --without-driver-modules, and just always have the entry point in libvirt_private.syms for one less symbol file to worry about. But that's a separate patch. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Replace use of cpuMapOverride with virFileFindResource to locate CPU map from build dir. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 19 ------------------- src/cpu/cpu_map.c | 31 ++++++++++--------------------- src/cpu/cpu_map.h | 3 --- tests/cputest.c | 14 -------------- tests/qemuxml2argvtest.c | 7 ------- tests/qemuxmlnstest.c | 7 ------- 6 files changed, 10 insertions(+), 71 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index e549783..4c926b3 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1158,25 +1158,6 @@ int main(int argc, char **argv) { virFileActivateDirOverride(argv[0]); - if (strstr(argv[0], "lt-libvirtd") || - strstr(argv[0], "/daemon/.libs/libvirtd")) { - char *tmp = strrchr(argv[0], '/'); - char *cpumap; - if (!tmp) { - fprintf(stderr, _("%s: cannot identify driver directory\n"), argv[0]); - exit(EXIT_FAILURE); - } - *tmp = '\0'; - if (virAsprintfQuiet(&cpumap, "%s/../../src/cpu/cpu_map.xml", - argv[0]) < 0) { - fprintf(stderr, _("%s: initialization failed\n"), argv[0]); - exit(EXIT_FAILURE); - } - cpuMapOverride(cpumap); - VIR_FREE(cpumap); - *tmp = '/'; - } - while (1) { int optidx = 0; int c; diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index fca306e..68d287a 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -24,6 +24,7 @@ #include <config.h> #include "viralloc.h" +#include "virfile.h" #include "cpu.h" #include "cpu_map.h" #include "configmake.h" @@ -34,10 +35,6 @@ VIR_LOG_INIT("cpu.cpu_map"); -#define CPUMAPFILE PKGDATADIR "/cpu_map.xml" - -static char *cpumap; - VIR_ENUM_IMPL(cpuMapElement, CPU_MAP_ELEMENT_LAST, "vendor", "feature", @@ -87,20 +84,25 @@ int cpuMapLoad(const char *arch, char *xpath = NULL; int ret = -1; int element; - const char *mapfile = (cpumap ? cpumap : CPUMAPFILE); + char *mapfile; + + if (!(mapfile = virFileFindResource("cpu_map.xml", + "src/cpu", + PKGDATADIR))) + return -1; VIR_DEBUG("Loading CPU map from %s", mapfile); if (arch == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("undefined hardware architecture")); - return -1; + goto cleanup; } if (cb == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no callback provided")); - return -1; + goto cleanup; } if ((xml = xmlParseFile(mapfile)) == NULL) { @@ -141,6 +143,7 @@ int cpuMapLoad(const char *arch, xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(xpath); + VIR_FREE(mapfile); return ret; @@ -148,17 +151,3 @@ int cpuMapLoad(const char *arch, virReportOOMError(); goto cleanup; } - - -int -cpuMapOverride(const char *path) -{ - char *map; - - if (VIR_STRDUP(map, path) < 0) - return -1; - - VIR_FREE(cpumap); - cpumap = map; - return 0; -} diff --git a/src/cpu/cpu_map.h b/src/cpu/cpu_map.h index 8d27bcd..23ce888 100644 --- a/src/cpu/cpu_map.h +++ b/src/cpu/cpu_map.h @@ -48,7 +48,4 @@ cpuMapLoad(const char *arch, cpuMapLoadCallback cb, void *data); -extern int -cpuMapOverride(const char *path); - #endif /* __VIR_CPU_MAP_H__ */ diff --git a/tests/cputest.c b/tests/cputest.c index 8903f82..3766c2f 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -40,8 +40,6 @@ #include "cpu/cpu_map.h" #include "virstring.h" -static const char *abs_top_srcdir; - #define VIR_FROM_THIS VIR_FROM_CPU enum cpuTestBoolWithError { @@ -504,17 +502,6 @@ static int mymain(void) { int ret = 0; - char *map = NULL; - - abs_top_srcdir = getenv("abs_top_srcdir"); - if (!abs_top_srcdir) - abs_top_srcdir = abs_srcdir "/.."; - - if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 || - cpuMapOverride(map) < 0) { - VIR_FREE(map); - return EXIT_FAILURE; - } #define DO_TEST(arch, api, name, host, cpu, \ models, nmodels, preferred, flags, result) \ @@ -657,7 +644,6 @@ mymain(void) DO_TEST_GUESTDATA("ppc64", "host", "guest", ppc_models, NULL, 0); DO_TEST_GUESTDATA("ppc64", "host", "guest-nofallback", ppc_models, "POWER7_v2.1", -1); - VIR_FREE(map); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d43a4de..a1ef2b8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -483,7 +483,6 @@ static int mymain(void) { int ret = 0; - char *map = NULL; bool skipLegacyCPUs = false; abs_top_srcdir = getenv("abs_top_srcdir"); @@ -530,11 +529,6 @@ mymain(void) driver.config->spiceTLS = 1; if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0) return EXIT_FAILURE; - if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 || - cpuMapOverride(map) < 0) { - VIR_FREE(map); - return EXIT_FAILURE; - } # define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, ...) \ do { \ @@ -1364,7 +1358,6 @@ mymain(void) virObjectUnref(driver.config); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); - VIR_FREE(map); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 30bb723..e8f70d6 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -205,7 +205,6 @@ static int mymain(void) { int ret = 0; - char *map = NULL; bool json = false; abs_top_srcdir = getenv("abs_top_srcdir"); @@ -217,11 +216,6 @@ mymain(void) return EXIT_FAILURE; if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; - if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 || - cpuMapOverride(map) < 0) { - VIR_FREE(map); - return EXIT_FAILURE; - } # define DO_TEST_FULL(name, migrateFrom, migrateFd, expectError, ...) \ do { \ @@ -266,7 +260,6 @@ mymain(void) virObjectUnref(driver.config); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); - VIR_FREE(map); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 1.9.0

On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
Replace use of cpuMapOverride with virFileFindResource to locate CPU map from build dir.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 19 ------------------- src/cpu/cpu_map.c | 31 ++++++++++--------------------- src/cpu/cpu_map.h | 3 --- tests/cputest.c | 14 -------------- tests/qemuxml2argvtest.c | 7 ------- tests/qemuxmlnstest.c | 7 ------- 6 files changed, 10 insertions(+), 71 deletions(-)
I still wonder if we should try to get rid of the automake magic that symlinks the git copy of the file into builddir on a VPATH build, by having virFileFindResource learn how to look in two separate locations for VPATH builds. But it's not a show-stopper, and could certainly be a separate patch.
- if (strstr(argv[0], "lt-libvirtd") || - strstr(argv[0], "/daemon/.libs/libvirtd")) { - char *tmp = strrchr(argv[0], '/'); - char *cpumap; - if (!tmp) { - fprintf(stderr, _("%s: cannot identify driver directory\n"), argv[0]); - exit(EXIT_FAILURE); - } - *tmp = '\0';
Yay - it also gets rid of munging argv[0] in place. ACK to this if you remove the reference to cpuMapOverride from libvirt_private.syms. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Thu, Apr 24, 2014 at 04:18:02PM -0600, Eric Blake wrote:
On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
Replace use of cpuMapOverride with virFileFindResource to locate CPU map from build dir.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- daemon/libvirtd.c | 19 ------------------- src/cpu/cpu_map.c | 31 ++++++++++--------------------- src/cpu/cpu_map.h | 3 --- tests/cputest.c | 14 -------------- tests/qemuxml2argvtest.c | 7 ------- tests/qemuxmlnstest.c | 7 ------- 6 files changed, 10 insertions(+), 71 deletions(-)
I still wonder if we should try to get rid of the automake magic that symlinks the git copy of the file into builddir on a VPATH build, by having virFileFindResource learn how to look in two separate locations for VPATH builds. But it's not a show-stopper, and could certainly be a separate patch.
I considered doing that, but it would imply that this FindResource function has to starting stat()'ing files in dirs to see if they exists, so I decided against that. 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 :|
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Nehal J Wani