[libvirt] [PATCHv2 5/6] Use virGetUninstalledDir() in src/fdstream.c

Nehal J Wani nehaljw.kkd1 at gmail.com
Tue Mar 25 08:23:15 UTC 2014


src/storage/storage_backend_disk.c:
   *Check if libvirtd is running uninstalled from a build tree and change
    parthelper_path accordingly

---
 src/fdstream.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/fdstream.c b/src/fdstream.c
index d0435c7..031d9f5 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -593,6 +593,8 @@ virFDStreamOpenFileInternal(virStreamPtr st,
     struct stat sb;
     virCommandPtr cmd = NULL;
     int errfd = -1;
+    char *uninstalledDir = NULL;
+    char *iohelper_path = NULL;
 
     VIR_DEBUG("st=%p path=%s oflags=%x offset=%llu length=%llu mode=%o",
               st, path, oflags, offset, length, mode);
@@ -648,9 +650,22 @@ virFDStreamOpenFileInternal(virStreamPtr st,
             goto error;
         }
 
+        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;
+
         cmd = virCommandNewArgList(iohelper_path,
                                    path,
                                    NULL);
+
+        VIR_FREE(iohelper_path);
+
         virCommandAddArgFormat(cmd, "%llu", length);
         virCommandPassFD(cmd, fd,
                          VIR_COMMAND_PASS_FD_CLOSE_PARENT);
@@ -683,6 +698,7 @@ error:
     VIR_FORCE_CLOSE(fd);
     VIR_FORCE_CLOSE(childfd);
     VIR_FORCE_CLOSE(errfd);
+    VIR_FREE(iohelper_path);
     if (oflags & O_CREAT)
         unlink(path);
     return -1;
-- 
1.7.1




More information about the libvir-list mailing list