From 89de838f1b636c443c9b7fcb6a625323ea5d58b2 Mon Sep 17 00:00:00 2001 From: Nehal J Wani Date: Tue, 25 Mar 2014 13:53:13 +0530 Subject: [PATCH] Use virFileFindResource to locate libvirt_lxc for capabilities 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 --- 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 edc0b68d32..a35a5e04b9 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; } -- GitLab