[PATCH 4/9] Use virFileFindResource to locate libvirt_lxc for capabilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nehal J Wani <nehaljw.kkd1@xxxxxxxxx>

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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]