[PATCH 2/3] Allow the iohelper path to be customized by test programs

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Currently the fdstream function hardcodes the location
of the iohelper to LIBEXECDIR "/libvirt_iohelper". This
is not convenient when trying to write test cases which
use this code. Add a virFDStreamSetIOHelper method to
allow the test cases to point to the location of the
un-installed iohelper binary.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/fdstream.c           | 14 +++++++++++++-
 src/fdstream.h           |  3 +++
 src/libvirt_private.syms |  1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/fdstream.c b/src/fdstream.c
index a9a4851..d5e5aaf 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -74,6 +74,18 @@ struct virFDStreamData {
     virMutex lock;
 };
 
+
+static const char *iohelper_path = LIBEXECDIR "/libvirt_iohelper";
+
+void virFDStreamSetIOHelper(const char *path)
+{
+    if (path == NULL)
+        iohelper_path = LIBEXECDIR "/libvirt_iohelper";
+    else
+        iohelper_path = path;
+}
+
+
 static int virFDStreamRemoveCallback(virStreamPtr stream)
 {
     struct virFDStreamData *fdst = stream->privateData;
@@ -634,7 +646,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
             goto error;
         }
 
-        cmd = virCommandNewArgList(LIBEXECDIR "/libvirt_iohelper",
+        cmd = virCommandNewArgList(iohelper_path,
                                    path,
                                    NULL);
         virCommandAddArgFormat(cmd, "%llu", length);
diff --git a/src/fdstream.h b/src/fdstream.h
index d6f5a7a..3ca6256 100644
--- a/src/fdstream.h
+++ b/src/fdstream.h
@@ -33,6 +33,9 @@ typedef void (*virFDStreamInternalCloseCb)(virStreamPtr st, void *opaque);
 typedef void (*virFDStreamInternalCloseCbFreeOpaque)(void *opaque);
 
 
+/* Only for use by test suite */
+void virFDStreamSetIOHelper(const char *path);
+
 int virFDStreamOpen(virStreamPtr st,
                     int fd);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index bb70595..3cf0bcb 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -699,6 +699,7 @@ virFDStreamConnectUNIX;
 virFDStreamCreateFile;
 virFDStreamOpen;
 virFDStreamOpenFile;
+virFDStreamSetIOHelper;
 
 
 # libvirt_internal.h
-- 
1.8.2.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]