]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Use virFileFindResource to locate iohelper for virFileWrapperFdNew
authorNehal J Wani <nehaljw.kkd1@gmail.com>
Tue, 25 Mar 2014 08:23:12 +0000 (13:53 +0530)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 25 Apr 2014 10:59:46 +0000 (11:59 +0100)
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

index 4e2ff328100400edc5f5d4df562fc3b3dbf2217c..da4e0a0c51150949a9887152c875285eac1c3f0d 100644 (file)
@@ -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);