[PATCHv2 2/6] Use virGetUninstalledDir() in src/util/virfile.c

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

 



src/util/virfile.c
   *Check if libvirtd is running uninstalled from a build tree and change
    iohelper_path accordingly

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

diff --git a/src/util/virfile.c b/src/util/virfile.c
index fefc3fb..813ad86 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -193,6 +193,8 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
     bool output = false;
     int pipefd[2] = { -1, -1 };
     int mode = -1;
+    char *uninstalledDir = NULL;
+    char *iohelper_path = NULL;
 
     if (!flags) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -236,8 +238,20 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
         goto error;
     }
 
-    ret->cmd = virCommandNewArgList(LIBEXECDIR "/libvirt_iohelper",
-                                    name, "0", NULL);
+    uninstalledDir = virGetUninstalledDir();
+
+    if (uninstalledDir && virAsprintf(&iohelper_path,
+                                      "%s/../../src/libvirt_iohelper",
+                                      uninstalledDir) < 0)
+        goto error;
+    else if (virAsprintf(&iohelper_path,
+                         LIBEXECDIR "/libvirt_iohelper") < 0)
+        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);
@@ -268,6 +282,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.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]