[PATCHv2 3/6] Use virGetUninstalledDir() in src/lxc/lxc_conf.c

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

 



src/lxc/lxc_conf.c:
   *Check if libvirtd is running uninstalled from a build tree and change
    lxc_path accordingly

---
 src/lxc/lxc_conf.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index d4432cf..ad8f78a 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -66,6 +66,8 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
     virCapsPtr caps;
     virCapsGuestPtr guest;
     virArch altArch;
+    char *uninstalledDir = NULL;
+    char *lxc_path = NULL;
 
     if ((caps = virCapabilitiesNew(virArchFromHost(),
                                    0, 0)) == NULL)
@@ -89,10 +91,20 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
         goto error;
     }
 
+    uninstalledDir = virGetUninstalledDir();
+
+    if (uninstalledDir && virAsprintf(&lxc_path,
+                                      "%s/../../src/libvirt_lxc",
+                                      uninstalledDir) < 0)
+        goto error;
+    else if (virAsprintf(&lxc_path,
+                         LIBEXECDIR "/libvirt_lxc") < 0)
+        goto error;
+
     if ((guest = virCapabilitiesAddGuest(caps,
                                          "exe",
                                          caps->host.arch,
-                                         LIBEXECDIR "/libvirt_lxc",
+                                         lxc_path,
                                          NULL,
                                          0,
                                          NULL)) == NULL)
@@ -111,7 +123,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
         if ((guest = virCapabilitiesAddGuest(caps,
                                              "exe",
                                              altArch,
-                                             LIBEXECDIR "/libvirt_lxc",
+                                             lxc_path,
                                              NULL,
                                              0,
                                              NULL)) == NULL)
@@ -126,6 +138,8 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
             goto error;
     }
 
+    VIR_FREE(lxc_path);
+
     if (driver) {
         /* Security driver data */
         const char *doi, *model, *label, *type;
@@ -158,6 +172,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
     return caps;
 
 error:
+    VIR_FREE(lxc_path);
     virObjectUnref(caps);
     return NULL;
 }
-- 
1.7.1

--
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]